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(insight)
library(brms)
# load sample models
# zinb <- read.csv("http://stats.idre.ucla.edu/stat/data/fish.csv")
# set.seed(123)
# m1 <- brm(bf(
# count ~ persons + child + camper + (1 | persons),
# zi ~ child + camper + (1 | persons)
# ),
# data = zinb,
# family = zero_inflated_poisson()
# )
m1 <- insight::download_model("brms_zi_2")
# data(epilepsy)
# set.seed(123)
# epilepsy$visit <- as.numeric(epilepsy$visit)
# epilepsy$Base2 <- sample(epilepsy$Base, nrow(epilepsy), replace = TRUE)
# f1 <- bf(Base ~ zAge + count + (1 |ID| patient))
# f2 <- bf(Base2 ~ zAge + Trt + (1 |ID| patient))
# m2 <- brm(f1 + f2 + set_rescor(FALSE), data = epilepsy)
m2 <- insight::download_model("brms_mv_3")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 | CI (50%) | CI (95%) |
| Intercept | 0.43 | 0.36 – 0.52 | 0.21 – 1.06 |
| persons | 2.31 | 2.18 – 2.45 | 1.70 – 2.99 |
| child | 0.32 | 0.30 – 0.34 | 0.26 – 0.39 |
| camper | 2.08 | 1.95 – 2.20 | 1.73 – 2.52 |
| Random Effects | |||
| σ2 | 5.33 | ||
| τ00 | 33.97 | ||
| ICC | 0.13 | ||
| N persons | 4 | ||
| Observations | 250 | ||
| Marginal R2 / Conditional R2 | 0.188 / 0.248 | ||
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.
| Base | Base 2 | |||||
|---|---|---|---|---|---|---|
| Predictors | Estimates | CI (50%) | CI (95%) | Estimates | CI (50%) | CI (95%) |
| Intercept | 24.33 | 19.40 – 33.81 | 12.60 – 54.21 | -15.22 | -22.98 – -3.37 | -24.86 – 10.73 |
| Age | -0.14 | -0.64 – 0.05 | -1.59 – 0.09 | 0.96 | 0.68 – 1.12 | 0.32 – 1.14 |
| count | 0.00 | -0.00 – 0.00 | -0.00 – 0.00 | |||
| Trt 1 | 0.90 | 0.41 – 1.49 | -0.85 – 3.11 | |||
| Random Effects | ||||||
| σ2 | 128.12 | |||||
| τ00 | 1.31 | |||||
| ICC | 0.98 | |||||
| N patient | 59 | |||||
| Observations | 236 | |||||
To show just one CI-column, use show.ci50 = FALSE.
| Base | Base 2 | |||
|---|---|---|---|---|
| Predictors | Estimates | CI (95%) | Estimates | CI (95%) |
| Intercept | 24.33 | 12.60 – 54.21 | -15.22 | -24.86 – 10.73 |
| Age | -0.14 | -1.59 – 0.09 | 0.96 | 0.32 – 1.14 |
| count | 0.00 | -0.00 – 0.00 | ||
| Trt 1 | 0.90 | -0.85 – 3.11 | ||
| Random Effects | ||||
| σ2 | 130.77 | |||
| τ00 | 1.33 | |||
| ICC | 0.98 | |||
| N patient | 59 | |||
| Observations | 236 | |||
When both multivariate and univariate response models are displayed in one table, a column Response is added for the multivariate response model, to indicate the different outcomes.
| count | Base,Base 2 | ||||
|---|---|---|---|---|---|
| Predictors | Incidence Rate Ratios | CI (95%) | Estimates | CI (95%) | Response |
| Intercept | 0.43 | 0.21 – 1.06 | 24.33 | 12.60 – 54.21 | Base |
| Intercept | 0.43 | 0.21 – 1.06 | -15.22 | -24.86 – 10.73 | Base2 |
| persons | 2.31 | 1.70 – 2.99 | |||
| child | 0.32 | 0.26 – 0.39 | |||
| camper | 2.08 | 1.73 – 2.52 | |||
| Age | -0.14 | -1.59 – 0.09 | Base | ||
| count | 0.00 | -0.00 – 0.00 | Base | ||
| Age | 0.96 | 0.32 – 1.14 | Base2 | ||
| Trt 1 | 0.90 | -0.85 – 3.11 | Base2 | ||
| Random Effects | |||||
| σ2 | 5.23 | 131.02 | |||
| τ00 | 33.92 | 1.24 | |||
| ICC | 0.13 | 0.98 | |||
| N | 4 persons | 59 patient | |||
| Observations | 250 | 236 | |||
| Marginal R2 / Conditional R2 | 0.188 / 0.248 | NA | |||