sergiocorreia / reghdfe

Linear, IV and GMM Regressions With Any Number of Fixed Effects
http://scorreia.com/software/reghdfe/
MIT License
218 stars 57 forks source link

[BUG] estfe gives invalid syntax #243

Open venividivi opened 2 years ago

venividivi commented 2 years ago

Stata version: Stata/SE 17.0 OS: Windows 11 (but before Windows 10) reghdfe version: 6.12.2 02Nov2021 (same issue with the stable version)

I run a regression

eststo column1: reghdfe stock_weight i.cat_distance##i.cat_disaster, absorb(year disaster_quarter num_county) vce(cluster county)
eststo column2: reghdfe stock_weight i.cat_distance##i.cat_disaster `firmcontrols', absorb(year disaster_quarter num_county) vce(cluster county)

and then want to create an output table using esttab

estfe column*, labels(year "Year FE" disaster_quarter "Disaster quarter FE" num_county "County FE")
return list
esttab column1 column2 using "05_tables\table 11.rtf", nobaselevels interaction(" x ") indicate("Year FE=0.year" "Disaster quarter FE=0.disaster_quarter" "County FE=0.num_county") drop("0._cons") label replace

Sometimes, and only sometimes however, I get the error message "invalid syntax" r(198). I tried uninstalling and installing again the reghdfe, the estout and the erepost (necessary for estfe) packages, closening and opening Stata and restarting my laptop to solve the error. This works sometimes, however I cannot narrow down what exact measure fixes the issue.

sergiocorreia commented 2 years ago

Do you get the error when running the estfe line, or the esttab line?

Assuming the former, something that helps _a lot to pinpoint the error is to do:

set trace on
set tracedepth 1
estfe ...

By setting trace on with a depth of one, Stata will output all the commands ran by estfe and show exactly in what line it fails (which helps to solve the problem)

venividivi commented 2 years ago

I get the error on the estfe line.

As soon as I execute: set trace on set tracedepth 1 estfe ... the command goes through without any error and the trace command does not provide any additional information.