Hi all,
I am writing for a syntax-related issue I would like to get some opinion on as I could not find any other posts addressing this specific questions. The issue relates to the interacton between a first differenced and a categorical variables in an OLS regression (using reghdfe from Sergio Correia but I guess this is a general issue). When I try doing this I get the error "the 'D' operator is not allowed with factor variables". Specficallly I ran the following code:
I have read this post by Jeff Wooldridge and I understand the STATA logic. However, in my case I am not trying to difference the categorical variable, but I just want to interact it with a different FD variables.
Since I imagine this is due to the D. operator being distriuted over the interaction, I have also tried the following alternative syntaxes:
Which yields the same error as before and:
Which yields the previous error plus: "invalid interaction specification".
Of course I can overcome this issue by manually FDing the "category" variable, but it would be interesting to know whether there is a more elegant solution and/or I am missing something here.
Thenks in advance
I am writing for a syntax-related issue I would like to get some opinion on as I could not find any other posts addressing this specific questions. The issue relates to the interacton between a first differenced and a categorical variables in an OLS regression (using reghdfe from Sergio Correia but I guess this is a general issue). When I try doing this I get the error "the 'D' operator is not allowed with factor variables". Specficallly I ran the following code:
Code:
reghdfe d.log_GO d.yearly_avg_t#i.category d.yearly_avg_t_sq#i.category
Since I imagine this is due to the D. operator being distriuted over the interaction, I have also tried the following alternative syntaxes:
Code:
reghdfe d.log_GO d.(yearly_avg_t)#i.category d.(yearly_avg_t_sq)#i.category
Code:
reghdfe d.log_GO (d.yearly_avg_t)#i.category (d.yearly_avg_t_sq)#i.category
Of course I can overcome this issue by manually FDing the "category" variable, but it would be interesting to know whether there is a more elegant solution and/or I am missing something here.
Thenks in advance
Comment