The current version 1.8.1 of my sjPlot package has two new functions to easily summarize mixed effects models as HTML-table: `sjt.lmer`

and `sjt.glmer`

. Both are very similar, so I focus on showing how to use `sjt.lmer`

here.

# load required packages library(sjPlot) # table functions library(sjmisc) # sample data library(lme4) # fitting models

## Linear mixed models summaries as HTML table

The `sjt.lmer`

function prints summaries of linear mixed models (fitted with the `lmer`

function of the lme4-package) as nicely formatted html-tables. First, some sample models are fitted:

# load sample data data(efc) # prepare grouping variables efc$grp = as.factor(efc$e15relat) levels(x = efc$grp) <- get_val_labels(efc$e15relat) efc$care.level <- as.factor(rec(efc$n4pstu, "0=0;1=1;2=2;3:4=4")) levels(x = efc$care.level) <- c("none", "I", "II", "III") # data frame for fitted model mydf <- data.frame(neg_c_7 = as.numeric(efc$neg_c_7), sex = as.factor(efc$c161sex), c12hour = as.numeric(efc$c12hour), barthel = as.numeric(efc$barthtot), education = as.factor(efc$c172code), grp = efc$grp, carelevel = efc$care.level) # fit sample models fit1 <- lmer(neg_c_7 ~ sex + c12hour + barthel + (1|grp), data = mydf) fit2 <- lmer(neg_c_7 ~ sex + c12hour + education + barthel + (1|grp), data = mydf) fit3 <- lmer(neg_c_7 ~ sex + c12hour + education + barthel + (1|grp) + (1|carelevel), data = mydf)

The simplest way of producing the table output is by passing the fitted models as parameter. By default, estimates (B), confidence intervals (CI) and p-values (p) are reported. The models are named Model 1 and Model 2. The resulting table is divided into three parts:

- Fixed parts – the model’s fixed effects coefficients, including confidence intervals and p-values.
- Random parts – the model’s group count (amount of random intercepts) as well as the Intra-Class-Correlation-Coefficient ICC.
- Summary – Observations, AIC etc.

Continue reading “Beautiful table-outputs: Summarizing mixed effects models #rstats”