Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
There are now quite a few R packages to turn cross-tables and fitted models into nicely formatted latex. In a previous post I showed how to use one of them to display regression tables on the fly. In this post I summarise what types of R object each of the major packages can deal with.
Unsurprisingly, there’s quite some variation…
The packages I’m looking at here are: apsrtable (v0.8-8), xtable (v1.7-1), stargazer (v3.0.1), memisc (v0.96-3) and texreg (v1.22).
I should note that all of these packages also allow users to add their own latex representation for new R objects. For example, here’s an addition to memisc to cover mer objects from the lme4 package (now included in memisc). However, I couldn’t be bothered to track down all these additions, so this post only deals with what each package can do without any extra work.
Also, several of these packages can typeset data.frame and matrix objects too. While that can be incredibly handy, it is outside the focus of this post so I’ve left it out. Cross-tables are only just processed enough to deserve a mention. And we won’t even talk about generating HTML (well, not until the notes anyway).
Finally, I haven’t checked all of this information. The table is filled on the basis of my experience and the package documentation. If something is wrong or incomplete then please let me know in the comments.
Package | Model | xtable | memisc | texreg | stargazer | apsrtable |
---|---|---|---|---|---|---|
AER | ivreg | Y | Y | |||
tobit | Y | Y | Y | Y | ||
base | table | Y | Y | |||
ftable | Y | |||||
betareg | betareg | Y | Y | |||
dynlm | dynlm | Y | Y | |||
eha | aftreg | Y | ||||
phreg | Y | |||||
weibreg | Y | |||||
ergm | ergm | Y | Y | |||
gee | gee | Y | Y | Y (in ‘skeleton’ form) | ||
gmm | gmm | Y | ||||
lme4 | glmerMod | Y | Y | |||
lmerMod | Y | Y | ||||
nlmerMod | Y | Y | ||||
MASS | polr | Y | Y | Y | ||
rlm | Y | Y | ||||
negbin | Y | Y | Y | |||
mgcv | gam | Y | ||||
nlme | gls | Y | Y | |||
lme | Y | |||||
nnet | multinom | Y | Y | |||
ordinal | clm | Y | Y | Y | ||
sclm | Y | |||||
plm | plm | Y | Y | |||
pmg | Y | Y | ||||
pscl | hurdle | Y | Y | |||
zeroinfl | Y | Y | ||||
quantreg | rq | Y | ||||
relevent | rem.dyad | Y | ||||
rms | lrm | Y | Y | |||
robustbase | lmrob | Y | Y | |||
simex | simex | Y | Y | |||
sna | lnam | Y | ||||
stats | glm | Y | Y | Y | Y | Y |
lm | Y | Y | Y | Y | Y | |
aov | Y | |||||
anova | Y | |||||
prcomp | Y | |||||
ts | Y | |||||
survey | svyglm | Y | Y | Y (in ‘skeleton’ form) | ||
survival | coxph | Y | Y | Y | Y | |
clogit | Y | Y | Y | |||
survreg | Y | Y | ||||
coxph.penal | Y | |||||
systemfit | systemfit | Y | ||||
termgm | stergm | Y | ||||
Zelig | zeroinfl | Y | ||||
cloglog.net | Y | |||||
gamma.net | Y | |||||
probit.net | Y | |||||
logit.net | Y | |||||
Relogit | Y |
Notes
In case you are curious, a first version of this table was generated using the print.xtable function of the xtable package with type=html before being adjusted in place. If these posts haven’t given you the idea yet: I detest doing this sort of thing by hand.
Liviu (in the comments) also mentions the estout package. I’ve never used it, but apparently it deals with lm and plm models and is modeled after a Stata command of the same name.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.