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.

Heisenberg
  • 8,386
  • 12
  • 53
  • 102
  • 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. – Carl Nov 03 '15 at 00:44
  • http://www.ats.ucla.edu/stat/r/faq/svy_r_regest.htm – Carl Nov 03 '15 at 00: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... – Heisenberg Nov 03 '15 at 00:48
  • I have never run direct Stata to R survey comparisons, but I have run R survey to SAS survey comparisons. In general point estimates are identical and SEs vary slightly, but not too significantly. Note: my comparisons only used replicate weights. – Carl Nov 03 '15 at 00:50
  • 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? – Roberto Ferrer Nov 03 '15 at 02: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. – Heisenberg Nov 03 '15 at 02:16

2 Answers2

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.

Community
  • 1
  • 1
Roberto Ferrer
  • 11,024
  • 1
  • 21
  • 23
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.

0response
  • 21
  • 1