Movatterモバイル変換


[0]ホーム

URL:


Summary of Bayesian Models as HTMLTable

Daniel Lüdecke

2025-07-10

## 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':## ##     ar

This 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)

Bayesian models summaries as HTML table

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).

tab_model(m1)
 count
PredictorsIncidence Rate RatiosCI (95%)
Count Model
Intercept0.420.22 – 0.88
persons2.321.86 – 2.93
child0.320.26 – 0.38
camper2.081.73 – 2.53
Zero-Inflated Model
Intercept0.520.11 – 2.21
child6.443.46 – 12.95
camper0.430.21 – 0.87
Random Effects
σ25.58
τ0033.62
ICC0.14
Npersons4
Observations250
Marginal R2 / Conditional R20.186 / 0.248

Multivariate response models

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.

tab_model(m2)
 BaseBase2
PredictorsEstimatesCI (95%)EstimatesCI (95%)
Intercept28.6111.35 – 34.2026.6111.24 – 29.03
z Age-4.85-5.42 – -1.761.21-0.31 – 2.15
count0.00-0.00 – 0.00
Trt: Trt 1-0.32-4.36 – 1.43
Random Effects
σ254.49
τ004.28
ICC0.96
Npatient59
Observations236

Show two Credible Interval-column

To show a second CI-column, useshow.ci50 = TRUE.

tab_model(m2,show.ci50 =TRUE)
 BaseBase2
PredictorsEstimatesCI (50%)CI (95%)EstimatesCI (50%)CI (95%)
Intercept28.6124.07 – 30.2311.35 – 34.2026.6121.53 – 28.4511.24 – 29.03
z Age-4.85-5.17 – -3.89-5.42 – -1.761.210.74 – 1.54-0.31 – 2.15
count0.00-0.00 – 0.00-0.00 – 0.00
Trt: Trt 1-0.32-1.91 – 0.69-4.36 – 1.43
Random Effects
σ254.89
τ004.68
ICC0.96
Npatient59
Observations236

Mixing multivariate and univariate response models

When both multivariate and univariate response models are displayedin one table, a columnResponse is added for the multivariateresponse model, to indicate the different outcomes.

tab_model(m1, m2)
 countBase,Base 2
PredictorsIncidence Rate RatiosCI (95%)EstimatesCI (95%)Response
Intercept0.420.22 – 0.8828.6111.35 – 34.20Base
Intercept0.420.22 – 0.8826.6111.24 – 29.03Base2
persons2.321.86 – 2.93
child0.320.26 – 0.38
camper2.081.73 – 2.53
z Age-4.85-5.42 – -1.76Base
count0.00-0.00 – 0.00Base
z Age1.21-0.31 – 2.15Base2
Trt: Trt 1-0.32-4.36 – 1.43Base2
Zero-Inflated Model
Intercept0.520.11 – 2.21
child6.443.46 – 12.95
camper0.430.21 – 0.87
Random Effects
σ25.6553.91
τ0033.454.58
ICC0.140.96
N4persons59patient
Observations250236
Marginal R2 / Conditional R20.186 / 0.248NA

[8]ページ先頭

©2009-2025 Movatter.jp