Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to produce a LaTeX table from an lme4 mer model fit object?

Tags:

r

latex

lme4

Does anyone know a way to produce a nice publication quality LaTeX table from an lme4 mer object? Neither the xtable method (package xtable) nor the latex method (package Hmisc) know how to deal with mer objects.

For example, given this fit:

library(lme4)    
fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)

Are there any options for producing a nice LaTeX table of the coefficient estimates for both the fixed and random effects?

EDIT:

Because this is somewhat buried in the comment threads below, note that a community wiki is in development for R LaTeX tables: Tools for making latex tables in R

like image 560
Ryan Avatar asked Mar 28 '11 15:03

Ryan


3 Answers

The answer may be a bit late, but perhaps somebody may find it interesting:

library("texreg")
texreg(fm1)

To typeset multiple lme4 or other models side by side, use something like this:

texreg(list(fm1, fm2))
like image 52
Philip Leifeld Avatar answered Nov 15 '22 00:11

Philip Leifeld


Here is a blog post that seems tailor made for this situation Latex Tables for lme4 Models

like image 10
Ramnath Avatar answered Nov 15 '22 01:11

Ramnath


I may have a hacky solution. I wanted the same thing, specifically the table of coefficients from a glmer model fit (the estimates, SEs, z, and p values). Finding the right part of the summary output and feeding that into xtable seems to have done the trick. Apologies for not supplying reproducible code & data, but from your original example:

fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
xtable(summary(fm1)@coef)

Should give you the table of coefficients, SEs, etc. Note that it just gives the values, not the extra dressing-up of significance stars, etc.

like image 6
Scott Avatar answered Nov 15 '22 02:11

Scott