5

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?

asked May 25, 2016 at 19:00
1
  • If you want to output a "clean" file, ready to be used by another software, I suggest postfileing yor results. Commented Jun 3, 2016 at 22:19

1 Answer 1

5

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/

answered May 25, 2016 at 19:07
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.