Skip to content

Instantly share code, notes, and snippets.

@nickbloom
Created March 21, 2014 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickbloom/9697001 to your computer and use it in GitHub Desktop.
Save nickbloom/9697001 to your computer and use it in GitHub Desktop.
Getting xtable to play nicely with lmer output in R
library(arm)
library(lmer)
library(xtable)
# This is only for fixed effects, so it's kind of a hacky solution. I'm working (slowly) on an alternative that includes more info.
mlm1<-lmer(Your Equation Here)
outmat<-cbind(fixed(mlm1), se.fixef(mlm1))
outmat<-cbind(outmat, se <- sqrt(diag(mixed.1$vcov)))
outmat<-cbind(outmat, (outmat[,1]/outmat[,2]))
outmat<-cbind(outmat, 2*pnorm(-abs(outmat[,3])))
outmat<-round(outmat, 4)
# then you can just output using xtable, but you have to name your columns and rows
mlm1.out<-xtable(outmat)
col.names(mlm1.out)<-c("Coef.", "SE", "t-value", "p")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment