I would like to save regression coefficients in order to plot them in a different software (pgfplots under LaTeX, see this example).
More specifically, I'm trying to plot bars for the estimated coefficients on a factor variable, e.g.:
use http://www.stata-press.com/data/r14/cholesterol.dta, clear
reg chol i.agegrp
I would like to store each age group and the associated regression coefficient in a .csv file, so that I could plot them in a bar chart using pgfplot.
If possible, I would even like the set of coefficients saved to be limited to those of the factor variable, here i.agegrp (and not include other coefficients, such as _cons).
I saw the option text for outreg2 but didn't manage to get a flat file. Is there any other solution?
1 Answer 1
ssc install estout
and there you go
reg y x
eststo mycoeftable
## that saves your coefficients for later use
esttab mycoeftable using "C:/table.csv"
look at the documentation for more detailed options http://repec.org/bocode/e/estout/
postfileing yor results.