pander icon indicating copy to clipboard operation
pander copied to clipboard

Support for lme4 / lmer models?

Open puterleat opened this issue 8 years ago • 3 comments

puterleat avatar Jun 06 '16 13:06 puterleat

Anything is doable :) Can you please share some example objects and preferred output?

daroczig avatar Jun 06 '16 18:06 daroczig

It's a bit of a mouthful, but I might do something like this:

library(pander)
library(lme4)
library(broom)
library(dplyr)
require(lmerTest)

fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
tab1 <- tidy(fm1) %>% select(-group)

fixedpvals <- coef(summary(fm1))[,5]
tab1$p <- c(fixedpvals, rep(NA, length(tab1$estimate)-length(fixedpvals)))
colnames(tab1) <- c("", "Estimate", "Std. Error", "t", "Pr(>|t|)")
pander(tab1, 
       missing="", 
       justify = c('left', 'center', 'center', 'center', 'center'),
       )

Note you have to use lmerTest for the p values to be present in the coefficients table. Perhaps we need to check whether the library is loaded before grabbing that column...

puterleat avatar Jun 07 '16 08:06 puterleat

might want to coordinate with the broom package ... ? (there are issues there with lmerTest output, too, but might as well not solve the problem twice ...)

bbolker avatar Sep 01 '16 21:09 bbolker