4

My colleague and I chose Stata for regression analysis due to good handling of survey data. We also want to use R for graphics, but do not know how to export Stata regression model.

Within Stata, of course there is return list and ereturn list. But what's the best way to export these results outside of Stata? Direct to R would be ideal, but any intermediate format would be fine as well.

asked Nov 2, 2015 at 23:31
6
  • Stata output is just a text log file, so I think you should consider doing your survey regressions in R using the survey package. I will write an example below. Commented Nov 3, 2015 at 0:44
  • ats.ucla.edu/stat/r/faq/svy_r_regest.htm Commented Nov 3, 2015 at 0:45
  • @Carl Thanks for the suggestion! In your experience does R survey give identical result as Stata? My co-author only knows Stata, so he would be skeptical and unwilling to read R code... Commented Nov 3, 2015 at 0:48
  • 2
    It's not really clear what you mean by "exporting Stata regression results". Stata is a professional statistical environment, and although I accept R can make for really impressive graphs, Stata has an ample repertoire of professional-looking graphs. Is there some specific reason for wanting to produce graphs in R, given that the analysis is done in Stata? Commented Nov 3, 2015 at 2:12
  • 1
    "Exporting Stata regression result" means exporting the coefficients, the standard error, the t-statistic, etc. in such a manner that can be imported into other programs (R in this case). I think the reason for exporting in my case is simply that I'm much more competent with R graphics. I've also seen papers using both R and Stata (judging from graph and table style), so I'm curious how it's done. Commented Nov 3, 2015 at 2:16

2 Answers 2

3

If I were to do this, I would create a Stata dataset with all the regression results using postfile. Then import it into R using, for example, some technique from here. Manipulate within R at your convenience.

See also the user-written command rsource: ssc describe rsource.

Disclaimer: my knowledge of R is rather limited.

answered Nov 3, 2015 at 4:01
Sign up to request clarification or add additional context in comments.

Comments

2

I would advise using regsave

ssc install regsave

E.g. after a regression command you could use

regsave, tstat pval ci

to replace the current dataset by the estimation results and save it afterwards.

answered Aug 22, 2017 at 9:48

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.