This vignette shows examples for using tab_model()
to create HTML tables for mixed models. Basically, tab_model()
behaves in a very similar way for mixed models as for other, simple regression models, as shown in this vignette.
# load required packages
library(sjPlot)
library(sjmisc)
library(brms)
# load sample datasets
data("efc")
efc <- to_factor(efc, e42dep, c172code, c161sex, e15relat)
zinb <- read.csv("http://stats.idre.ucla.edu/stat/data/fish.csv")
# fit two sample models
m1 <- brm(
bf(count ~ child + camper + (1 | persons),
zi ~ child + camper),
data = zinb,
family = zero_inflated_poisson(),
cores = 4,
iter = 1000
)
f1 <- bf(neg_c_7 ~ e42dep + c12hour + c172code + (1 |ID| e15relat))
f2 <- bf(c12hour ~ c172code + (1 |ID| e15relat))
m2 <- brm(
f1 + f2 + set_rescor(FALSE),
data = efc,
cores = 4,
iter = 1000
)
For Bayesian regression models, some of the differences to the table output from simple models or mixed models of tab_models()
are the use of Highest Density Intervals instead of confidence intervals, the Bayes-R-squared values, and a different “point estimate” (which is, by default, the median from the posterior draws).
tab_model(m1)
count | ||||||
---|---|---|---|---|---|---|
Predictors | Incidence Rate Ratios | HDI (50%) | HDI (95%) | |||
Intercept | 3.08 | 1.72 – 4.81 | 0.42 – 24.50 | |||
child | 0.31 | 0.29 – 0.33 | 0.25 – 0.37 | |||
camper | 2.10 | 1.99 – 2.24 | 1.79 – 2.51 | |||
Zero-Inflated Model | ||||||
Intercept | 0.53 | 0.42 – 0.67 | 0.27 – 1.04 | |||
child | 3.81 | 3.20 – 4.81 | 2.20 – 7.29 | |||
camper | 0.50 | 0.38 – 0.62 | 0.25 – 1.06 | |||
Random Effects | ||||||
σ2 | 1.00 | |||||
τ00 persons | 4.62 | |||||
ICC persons | 0.72 | |||||
Observations | 250 | |||||
Bayes R2 / Standard Error | 0.185 / 0.028 |
average number of hours of care per week |
Negative impact with 7 items |
|||||
---|---|---|---|---|---|---|
Predictors | Estimates | HDI (50%) | HDI (95%) | Estimates | HDI (50%) | HDI (95%) |
Intercept | 36.10 | 31.38 – 43.26 | 17.41 – 54.74 | 8.70 | 8.39 – 9.16 | 7.55 – 9.85 |
intermediate level of education |
-1.11 | -4.00 – 1.46 | -8.89 – 7.15 | 0.20 | 0.01 – 0.43 | -0.39 – 0.83 |
high level of education | -7.51 | -11.30 – -4.45 | -16.79 – 3.09 | 0.71 | 0.47 – 1.00 | -0.07 – 1.52 |
slightly dependent | 1.12 | 0.84 – 1.51 | 0.13 – 2.06 | |||
moderately dependent | 2.31 | 1.93 – 2.58 | 1.33 – 3.24 | |||
severely dependent | 3.88 | 3.61 – 4.33 | 2.82 – 4.83 | |||
average number of hours of care per week |
0.01 | 0.00 – 0.01 | 0.00 – 0.01 | |||
Random Effects | ||||||
σ2 | 12.81 | |||||
τ00 e15relat | 0.51 | |||||
ICC e15relat | 0.04 | |||||
Observations | 834 | |||||
Bayes R2 / Standard Error | 0.169 / 0.166 |
average number of hours of care per week |
Negative impact with 7 items |
||||
---|---|---|---|---|---|
Predictors | Estimates | HDI (95%) | Estimates | HDI (95%) | |
Intercept | 36.10 | 17.41 – 54.74 | 8.70 | 7.55 – 9.85 | |
intermediate level of education |
-1.11 | -8.89 – 7.15 | 0.20 | -0.39 – 0.83 | |
high level of education | -7.51 | -16.79 – 3.09 | 0.71 | -0.07 – 1.52 | |
slightly dependent | 1.12 | 0.13 – 2.06 | |||
moderately dependent | 2.31 | 1.33 – 3.24 | |||
severely dependent | 3.88 | 2.82 – 4.83 | |||
average number of hours of care per week |
0.01 | 0.00 – 0.01 | |||
Random Effects | |||||
σ2 | 12.81 | ||||
τ00 e15relat | 0.51 | ||||
ICC e15relat | 0.04 | ||||
Observations | 834 | ||||
Bayes R2 / Standard Error | 0.169 / 0.166 |
count |
Negative impact with 7 items |
||||
---|---|---|---|---|---|
Predictors | Incidence Rate Ratios | HDI (95%) | Estimates | HDI (95%) | Response |
Intercept | 3.08 | 0.42 – 24.50 | 8.70 | 7.55 – 9.85 | negc7 |
Intercept | 3.08 | 0.42 – 24.50 | 36.10 | 17.41 – 54.74 | c12hour |
child | 0.31 | 0.25 – 0.37 | |||
camper | 2.10 | 1.79 – 2.51 | |||
slightly dependent | 1.12 | 0.13 – 2.06 | negc7 | ||
moderately dependent | 2.31 | 1.33 – 3.24 | negc7 | ||
severely dependent | 3.88 | 2.82 – 4.83 | negc7 | ||
average number of hours of care per week |
0.01 | 0.00 – 0.01 | negc7 | ||
intermediate level of education |
0.20 | -0.39 – 0.83 | negc7 | ||
high level of education | 0.71 | -0.07 – 1.52 | negc7 | ||
intermediate level of education |
-1.11 | -8.89 – 7.15 | c12hour | ||
high level of education | -7.51 | -16.79 – 3.09 | c12hour | ||
Zero-Inflated Model | |||||
Intercept | 0.53 | 0.27 – 1.04 | |||
child | 3.81 | 2.20 – 7.29 | |||
camper | 0.50 | 0.25 – 1.06 | |||
Random Effects | |||||
σ2 | 1.00 | 12.81 | |||
τ00 | 4.62 persons | 0.51 e15relat | |||
ICC | 0.72 persons | 0.04 e15relat | |||
Observations | 250 | 834 | |||
Bayes R2 / Standard Error | 0.185 / 0.028 | 0.169 / 0.166 |