Search code examples
labellatexregressionstata

Stata - How to get Indicator Variable Indicators (Yes/No) to Appear in esttab LaTeX Output


Suppose I use this dataset:

sysuse nlsw88, clear

I want to run a regression and save it to a .tex file using esttab. The regression is this:

reg wage grade i.industry i.occupation, robust

Importantly, I want to indicate that I am using industry and occupation dummies, but I do not want any of the coefficients to appear in the table.

One way to do this is to hardcode industry and occupation indicators:

eststo clear
eststo: reg wage grade, robust
estadd local industry "No"
estadd local occupation "No"
eststo: reg wage grade i.industry i.occupation, robust
estadd local industry "Yes"
estadd local occupation "Yes"
esttab est* using "${path}/regress_wage.tex", r2 ar2 b(3) se label booktabs ///
    replace nodepvars nomtitles drop(*industry *occupation) ///
    scalars("industry Industry" "occupation Occupation") 

But I would really like to not have to manually put these in. I found out about the indicate option, but I can't get it to work with i. variables. I have tried:

eststo clear
eststo: reg wage grade, robust
eststo: reg wage grade i.industry i.occupation, robust
esttab est* using "${path}/regress_wage.tex", r2 ar2 b(3) se label booktabs ///
    replace nodepvars nomtitles drop(*industry *occupation) ///
    indicate(Industry = *industry*)

I have also tried swapping the last line out for:

    indicate(Industry = _Iindustry*)
    indicate(Industry = industry*)  
    indicate(Industry = *industry)

But nothing works. What to do?

Also, is there a way to get the Industry and Occupation indicators to appear right below the constant as opposed to below the adjusted R-squared?


Solution

  • You can use the coefl option to see how coefficients are named, which will be useful for referring to them in the indicate():

    sysuse nlsw88, clear
    reg wage grade i.industry i.occupation, robust coefl
    esttab, indicate("Industry = *.industry" "Occupation = *.occupation")
    esttab, indicate("Industry = *.industry" "Occupation = *.occupation", labels("In"))
    

    The last command will produce the following table:

    ----------------------------
                          (1)   
                         wage   
    ----------------------------
    grade               0.561***
                       (9.69)   
    
    _cons               2.128   
                       (1.94)   
    
    Industry               In   
    
    Occupation             In   
    ----------------------------
    N                    2226   
    ----------------------------
    t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001