Moving from Stata to R

There are a few resources available for users who are familiar with Stata but want to move to R for one reason or another.

This particular page contains a useful reference of common Stata commands, along with comparable R commands for achieving the same task. Of course, the R commands will behave in slightly different ways than the Stata commands, so reading the documentation for each R command will be a prerequisite to using it. Note also that some of the commands are not included in the basic installation but will need to be installed before using them (typically through the install.packages() command).

Other useful resources include “The Stata Demo with R”, and the “Algorithm for selection of statistical methods”:

The Stata Demo with R

The Stata Demo with R is a replication of a Stata demo which users the “auto.dta” dataset to demonstrate the use of common statistical procedures. The demonstration session - as it looks when implemented in R - is available here:

Algorithm for selection of statistical methods

To find an R command using knowledge about the structure of a particular statistical problem, rather than the corresponding Stata command, you can use the algorithm for selection of statistical methods , which lists appropriate R commands by outcome variables and predictors. The algorithm is available here:

note: where the algorithm says glm(family=gaussian) it would probably be better just to use lm(). glm(family=gaussian) should work, but will be slightly less efficient etc.. (Perhaps this recommendation stems from a confusion between generalized linear models and general linear models?)

Translations of Common Stata Commands

Help

Stata R
help help.start(utils)
help topic ?topic(utils)
search ,local help.search(utils)
search ,net RSiteSearch(utils)

Univariate statistics

Stata R
summarize summary(base)

Bivariate analysis

Stata R
correlate cor(stats)
anova anova(stats)
ttest t.test(stats)
tabulate, chi2 chisq.test(stats)

Modeling

Stata R
regress lm(stats)
glm glm(stats)
logistic lrm(Design)
xtreg plm(plm)
ologit or oprobit polr(MASS)
nbregglm.nb(MASS)
mlogit multinom(nnet)
heckman heckit(micEcon)
xtmixed lme(nlme)
qreg rq(quantreg)
zipzeroinfl(pscl)
ivregtsls(sem)

Regression Diagnostics

Stata R
avplot av.plot(car)
crplot cr.plot(car)
estat vif vif(car)
estat hettest bptest(lmtest)
estat ovtest resettest(lmtest)

Other

Stata R
egen ...,by() transformBy(doBy)

 
getting-started\translations\stata2r.txt · Last modified: 2009/06/17
 
Recent changes RSS feed R Wiki powered by Driven by DokuWiki and optimized for Firefox Creative Commons License