library(lme4)
library(sjmisc)
data(efc)
# prepare group variable
efc$grp = as.factor(efc$e15relat)
levels(x = efc$grp) <- get_val_labels(efc$e15relat)
efc$care.level <- as.factor(sjmisc::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 two 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)
# print summary table
sjt.lmer(fit1, fit2)
sjt.lmer(fit1, fit2,
showAIC = TRUE,
showConfInt = FALSE,
showStdError = TRUE,
pvaluesAsNumbers = FALSE)
sjt.lmer(fit1, fit2, fit3,
showAIC = TRUE,
separateConfColumn = FALSE,
newLineConf = FALSE)
Run the code above in your browser using DataLab