Question

I did some research online and using a combination of estout and tabstat seems like the way to go here.

I am running the following regression

reg subject inSchool#treatment#male

I need the output to display the following

enter image description here

The betas are all in reference to a female, not in school, and in the control group, hence the _cons label.

Is storing the output in a matrix the best way to achieve this display and how would I do this?

Was it helpful?

Solution

Nick is correct that this question is too vague, but this should show you enough so that you can ask specific, answerable questions (just because you're a teacher :) ).

The command you're looking for to easily make nice tables is eststo, which is part of estout (install this package with ssc install estout). Below I store each regression output with eststo and assign a model title with , title(), then include these model titles with esttab, mtitle. Within estout there are enough features and options for at least 1,000 more questions. But this should get you started and find out which of those 1,000+ questions you have.

* I don't understand your data structure, but here's a guess
clear
set obs 2001
generate score = 60 + (100 - 60)*runiform()
generate subject = floor(3 * runiform()) + 1
generate inSchool = floor(2 * runiform())
generate treatment = floor(2 * runiform())
generate male = floor(2 * runiform())

* label 
label define subjects 1 "Math" 2 "Science" 3 "English"
label define males 0 "Female" 1 "Male" 
label define treatments 0 "Control" 1 "Treatment" 
label value subject subjects
label value male males
label value treatment treatments

* loop over combinations
* ssc install esttab
eststo clear
levelsof subject, local(subjects)
forvalues t =0/1 {
    forvalues m = 0/1 {
        foreach s of local subjects {
            * help extended_fcn
            local ss: label subjects `s'        
            local tt: label treatments `t'        
            local mm: label males `m'        
            regress score inSchool ///
                if (subject == `s') ///
                    & (treatment == `t') ///
                    & (male == `m')
            * help eststo        
            eststo, title("`tt', `mm', `ss'")        
        }
    }
}
* to screen
esttab, mtitle
* to files
esttab using "temp.rtf", mtitle
esttab using "temp.csv", mtitle

I guess I should add that this type of regression is usually endogenous unless you've really randomly assigned the treatment variables.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top