Alright folks, buckle up. Here& #39;s another edition of @Stata tips & tricks.
Today& #39;s topic is estimates - how to access them, how to save them, and how to change them
Today& #39;s topic is estimates - how to access them, how to save them, and how to change them
1) The easiest way to access a regression coefficient in your code is _b[varname]
sysuse auto
reg price mpg
di _b[mpg]
di _se[mpg]
This, btw, also works with factor variables:
reg price i.mpg
di _b[14.mpg]
sysuse auto
reg price mpg
di _b[mpg]
di _se[mpg]
This, btw, also works with factor variables:
reg price i.mpg
di _b[14.mpg]
2) If you want to access the t-statistics, p-values and CIs, they can be found in r(table)
sysuse auto
reg price mpg
matrix list r(table)
H/T @DeNewJohn
sysuse auto
reg price mpg
matrix list r(table)
H/T @DeNewJohn
3) This one may be obvious for many, but bear with me.
To view other estimation details corresponding to your model, type:
ereturn list
This is the information that is saved when you type
estimates save my_estimates_1
To view other estimation details corresponding to your model, type:
ereturn list
This is the information that is saved when you type
estimates save my_estimates_1
4) This is also the information that is used when you export your results to TeX / Excel using commands such as & #39;esttab& #39;, & #39;outreg& #39;, etc.
Knowing that is handy when working with super-large datasets, because exporting results straight after running each model takes AGES.
Knowing that is handy when working with super-large datasets, because exporting results straight after running each model takes AGES.
Better approach is to save estimates for all your models into .ster files (using & #39;estimates save xxxx& #39;), then use a smaller version of your dataset (say, by parsing & #39;sample 1& #39;), and export your results all at once, fast and easy.
^ though I should mention that you should be careful with this shrinkage if you& #39;re using factor variables. Make sure that the observations in your smaller dataset still contain all the possible values of your factor variables.
6) If you need to add non-standard info to your estimates, you can use a simple & #39;eclass& #39; function, such as:
program define EstAdd, eclass
syntax, Add(real) [Name(string)]
ereturn scalar `name& #39; = `add& #39;
end
EstAdd, add(3.14) name(pi)
ereturn list
program define EstAdd, eclass
syntax, Add(real) [Name(string)]
ereturn scalar `name& #39; = `add& #39;
end
EstAdd, add(3.14) name(pi)
ereturn list
Combining points 5 & 6 can make your code very efficient and scalable.
I use 6 to store the titles of my regression table columns, or append marginal effects & other relevant statistics.
I use 6 to store the titles of my regression table columns, or append marginal effects & other relevant statistics.
7) as for the commands that export output to TeX or Excel, I do not have a strong preference.
I use outreg2. It is flexible, supports both sumstats & regression tables, and is able to produce a single XLS file with multiple tabs.
Happy to hear about your preferences, though!
I use outreg2. It is flexible, supports both sumstats & regression tables, and is able to produce a single XLS file with multiple tabs.
Happy to hear about your preferences, though!
Previous batch of tips & tricks for large data can be found here: https://twitter.com/JanKabatek/status/1303209197576663040">https://twitter.com/JanKabate...