## Loading 'brms' package (version 2.22.0). Useful instructions## can be found by typing help('brms'). A more detailed introduction## to the package is available through vignette('brms_overview').## ## Attaching package: 'brms'## The following objects are masked from 'package:rstanarm':## ## dirichlet, exponential, get_y, lasso, ngrps## The following object is masked from 'package:stats':## ## arThis vignette shows examples for usingtab_model() tocreate HTML tables for mixed models. Basically,tab_model()behaves in a very similar way for mixed models as for other, simpleregression models, as shownin thisvignette.
# load required packageslibrary(sjPlot)library(brms)# sample modelszinb<-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())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)For Bayesian regression models, some of the differences to the tableoutput fromsimple models ormixed models oftab_models() arethe use ofHighest Density Intervals instead of confidenceintervals, 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 (95%) | |
| Count Model | |||
| Intercept | 0.42 | 0.22 – 0.88 | |
| persons | 2.32 | 1.86 – 2.93 | |
| child | 0.32 | 0.26 – 0.38 | |
| camper | 2.08 | 1.73 – 2.53 | |
| Zero-Inflated Model | |||
| Intercept | 0.52 | 0.11 – 2.21 | |
| child | 6.44 | 3.46 – 12.95 | |
| camper | 0.43 | 0.21 – 0.87 | |
| Random Effects | |||
| σ2 | 5.58 | ||
| τ00 | 33.62 | ||
| ICC | 0.14 | ||
| Npersons | 4 | ||
| Observations | 250 | ||
| Marginal R2 / Conditional R2 | 0.186 / 0.248 | ||
For multivariate response models, like mediator-analysis-models, itis recommended to print just one model in the table, as each regressionis displayed as own “model” in the output.
| Base | Base2 | |||
|---|---|---|---|---|
| Predictors | Estimates | CI (95%) | Estimates | CI (95%) |
| Intercept | 28.61 | 11.35 – 34.20 | 26.61 | 11.24 – 29.03 |
| z Age | -4.85 | -5.42 – -1.76 | 1.21 | -0.31 – 2.15 |
| count | 0.00 | -0.00 – 0.00 | ||
| Trt: Trt 1 | -0.32 | -4.36 – 1.43 | ||
| Random Effects | ||||
| σ2 | 54.49 | |||
| τ00 | 4.28 | |||
| ICC | 0.96 | |||
| Npatient | 59 | |||
| Observations | 236 | |||
To show a second CI-column, useshow.ci50 = TRUE.
| Base | Base2 | |||||
|---|---|---|---|---|---|---|
| Predictors | Estimates | CI (50%) | CI (95%) | Estimates | CI (50%) | CI (95%) |
| Intercept | 28.61 | 24.07 – 30.23 | 11.35 – 34.20 | 26.61 | 21.53 – 28.45 | 11.24 – 29.03 |
| z Age | -4.85 | -5.17 – -3.89 | -5.42 – -1.76 | 1.21 | 0.74 – 1.54 | -0.31 – 2.15 |
| count | 0.00 | -0.00 – 0.00 | -0.00 – 0.00 | |||
| Trt: Trt 1 | -0.32 | -1.91 – 0.69 | -4.36 – 1.43 | |||
| Random Effects | ||||||
| σ2 | 54.89 | |||||
| τ00 | 4.68 | |||||
| ICC | 0.96 | |||||
| Npatient | 59 | |||||
| Observations | 236 | |||||
When both multivariate and univariate response models are displayedin one table, a columnResponse is added for the multivariateresponse model, to indicate the different outcomes.
| count | Base,Base 2 | ||||
|---|---|---|---|---|---|
| Predictors | Incidence Rate Ratios | CI (95%) | Estimates | CI (95%) | Response |
| Intercept | 0.42 | 0.22 – 0.88 | 28.61 | 11.35 – 34.20 | Base |
| Intercept | 0.42 | 0.22 – 0.88 | 26.61 | 11.24 – 29.03 | Base2 |
| persons | 2.32 | 1.86 – 2.93 | |||
| child | 0.32 | 0.26 – 0.38 | |||
| camper | 2.08 | 1.73 – 2.53 | |||
| z Age | -4.85 | -5.42 – -1.76 | Base | ||
| count | 0.00 | -0.00 – 0.00 | Base | ||
| z Age | 1.21 | -0.31 – 2.15 | Base2 | ||
| Trt: Trt 1 | -0.32 | -4.36 – 1.43 | Base2 | ||
| Zero-Inflated Model | |||||
| Intercept | 0.52 | 0.11 – 2.21 | |||
| child | 6.44 | 3.46 – 12.95 | |||
| camper | 0.43 | 0.21 – 0.87 | |||
| Random Effects | |||||
| σ2 | 5.65 | 53.91 | |||
| τ00 | 33.45 | 4.58 | |||
| ICC | 0.14 | 0.96 | |||
| N | 4persons | 59patient | |||
| Observations | 250 | 236 | |||
| Marginal R2 / Conditional R2 | 0.186 / 0.248 | NA | |||