bill999
bill999

Reputation: 2540

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?

Upvotes: 1

Views: 3002

Answers (2)

Sourav Prasad
Sourav Prasad

Reputation: 11

Suppose, I am using global macro to define control variables. Then for exporting there is an issue.

sysuse nlsw88, clear
global controls i.industry i.occupation
reg wage grade $controls, robust coefl
. esttab, indicate(control = $controls)
coefficient i.industry not found
r(111);

In this case use the following code

sysuse nlsw88, clear
global controls "i.industry i.occupation"
reg wage grade $controls
local controls_indication "*industry *occupation"
esttab, indicate(control = `controls_indication')

Upvotes: 1

dimitriy
dimitriy

Reputation: 9470

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

Upvotes: 3

Related Questions