Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding interaction terms #29

Open
QLgogo opened this issue Jun 16, 2023 · 0 comments
Open

Adding interaction terms #29

QLgogo opened this issue Jun 16, 2023 · 0 comments

Comments

@QLgogo
Copy link

QLgogo commented Jun 16, 2023

Hi, thanks for this great estimator. I encountered problems when I tried to add interaction terms into the regression estimated by "fect" function. I tried different ways:

Way 1:
out.mc <- fect(formula = DV ~ IV1 + IV2 + IV1:IV2 + controls,
data = df, index = c("newid", "year"), force = "two-way",
lambda = c(0.5), method = "mc", CV = TRUE, pre.period = NULL,
se = TRUE, nboots = 100, parallel = FALSE, seed = 9799)
The results did not report the coefficient of the interaction term but showed coefficients of IV1 and IV2.

Way2:
df <- transform(df, inter = IV1*IV2)
out.mc <- fect(formula = DV ~ IV1 + IV2 + inter + controls,
data = df, index = c("newid", "year"), force = "two-way",
lambda = c(0.5), method = "mc", CV = TRUE, pre.period = NULL,
se = TRUE, nboots = 100, parallel = FALSE, seed = 9799)
The results returned errors (copied below) and said interaction terms has collinearity issues. However, I did not see collinearity issues when estimating the regression with xtreg or reghdfe.

"The variable 'x.7' has been removed because of collinearity (see $collin.var).
Error in beta0CV[, , i] <- beta0cv :
number of items to replace is not a multiple of replacement length"

Could you help with this interaction issue? Many thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant