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
)
Bayesian models summaries as HTML table
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).
|
count
|
Predictors
|
Incidence Rate Ratios
|
HDI (50%)
|
HDI (95%)
|
Intercept
|
3.12
|
1.73 – 5.23
|
0.32 – 22.60
|
child
|
0.31
|
0.29 – 0.33
|
0.25 – 0.37
|
camper
|
2.09
|
1.98 – 2.23
|
1.74 – 2.50
|
Zero-Inflated Model
|
Intercept
|
0.53
|
0.43 – 0.67
|
0.28 – 0.98
|
child
|
3.83
|
3.05 – 4.51
|
2.17 – 7.09
|
camper
|
0.49
|
0.39 – 0.66
|
0.24 – 1.05
|
Random Effects
|
σ2
|
1.00
|
τ00persons
|
5.02
|
ICC persons
|
0.72
|
Observations
|
250
|
Bayes R2 / Standard Error
|
0.187 / 0.028
|
Multivariate response models
For multivariate response models, like mediator-analysis-models, it is recommended to print just one model in the table, as each regression is displayed as own “model” in the output.
|
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
|
35.43
|
30.47 – 42.58
|
17.83 – 54.11
|
8.70
|
8.40 – 9.19
|
7.56 – 9.94
|
intermediate level of education
|
-0.96
|
-3.85 – 1.78
|
-9.04 – 7.54
|
0.21
|
-0.06 – 0.40
|
-0.43 – 0.83
|
high level of education
|
-7.31
|
-9.53 – -2.47
|
-17.72 – 3.33
|
0.72
|
0.40 – 0.93
|
-0.04 – 1.53
|
slightly dependent
|
|
|
|
1.10
|
0.68 – 1.41
|
0.05 – 2.13
|
moderately dependent
|
|
|
|
2.31
|
1.97 – 2.69
|
1.22 – 3.26
|
severely dependent
|
|
|
|
3.87
|
3.43 – 4.18
|
2.80 – 4.98
|
average number of hours of care per week
|
|
|
|
0.01
|
0.00 – 0.01
|
0.00 – 0.01
|
Random Effects
|
σ2
|
12.80
|
τ00e15relat
|
0.57
|
ICC e15relat
|
0.04
|
Observations
|
834
|
Bayes R2 / Standard Error
|
0.169 / 0.167
|
Just show one HDI-column
To show just one HDI-column, use show.hdi50 = FALSE
.
|
average number of hours of care per week
|
Negative impact with 7 items
|
Predictors
|
Estimates
|
HDI (95%)
|
Estimates
|
HDI (95%)
|
Intercept
|
35.43
|
17.83 – 54.11
|
8.70
|
7.56 – 9.94
|
intermediate level of education
|
-0.96
|
-9.04 – 7.54
|
0.21
|
-0.43 – 0.83
|
high level of education
|
-7.31
|
-17.72 – 3.33
|
0.72
|
-0.04 – 1.53
|
slightly dependent
|
|
|
1.10
|
0.05 – 2.13
|
moderately dependent
|
|
|
2.31
|
1.22 – 3.26
|
severely dependent
|
|
|
3.87
|
2.80 – 4.98
|
average number of hours of care per week
|
|
|
0.01
|
0.00 – 0.01
|
Random Effects
|
σ2
|
12.80
|
τ00e15relat
|
0.57
|
ICC e15relat
|
0.04
|
Observations
|
834
|
Bayes R2 / Standard Error
|
0.169 / 0.167
|
Mixing multivariate and univariate response models
When both multivariate and univariate response models are displayed in one table, a columns Response is added for the multivariate response model, to indicate the different outcomes.
|
count
|
Negative impact with 7 items
|
Predictors
|
Incidence Rate Ratios
|
HDI (95%)
|
Estimates
|
HDI (95%)
|
Response
|
Intercept
|
3.12
|
0.32 – 22.60
|
8.70
|
7.56 – 9.94
|
negc7
|
Intercept
|
3.12
|
0.32 – 22.60
|
35.43
|
17.83 – 54.11
|
c12hour
|
child
|
0.31
|
0.25 – 0.37
|
|
|
|
camper
|
2.09
|
1.74 – 2.50
|
|
|
|
slightly dependent
|
|
|
1.10
|
0.05 – 2.13
|
negc7
|
moderately dependent
|
|
|
2.31
|
1.22 – 3.26
|
negc7
|
severely dependent
|
|
|
3.87
|
2.80 – 4.98
|
negc7
|
average number of hours of care per week
|
|
|
0.01
|
0.00 – 0.01
|
negc7
|
intermediate level of education
|
|
|
0.21
|
-0.43 – 0.83
|
negc7
|
high level of education
|
|
|
0.72
|
-0.04 – 1.53
|
negc7
|
intermediate level of education
|
|
|
-0.96
|
-9.04 – 7.54
|
c12hour
|
high level of education
|
|
|
-7.31
|
-17.72 – 3.33
|
c12hour
|
Zero-Inflated Model
|
Intercept
|
0.53
|
0.28 – 0.98
|
|
|
|
child
|
3.83
|
2.17 – 7.09
|
|
|
|
camper
|
0.49
|
0.24 – 1.05
|
|
|
|
Random Effects
|
σ2
|
1.00
|
12.80
|
τ00
|
5.02 persons
|
0.57 e15relat
|
ICC
|
0.72 persons
|
0.04 e15relat
|
Observations
|
250
|
834
|
Bayes R2 / Standard Error
|
0.187 / 0.028
|
0.169 / 0.167
|