Summary of Bayesian Models as HTML Table

Daniel Lüdecke

2018-12-18

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

tab_model(m1)
  count
Predictors Incidence Rate Ratios HDI (50%) HDI (95%)
Intercept 3.59 0.97 – 4.05 0.13 – 42.28
child 0.31 0.30 – 0.34 0.25 – 0.37
camper 2.13 2.03 – 2.31 1.75 – 2.51
Zero-Inflated Model
Intercept 0.51 0.36 – 0.57 0.22 – 0.93
child 3.93 2.97 – 4.25 2.06 – 6.44
camper 0.52 0.30 – 0.56 0.23 – 0.94
Random Effects
σ2    
ICC icc -13.34
ICC tau.00 457.29
ICC resid.var -422.90
ICC total.var 34.39
Observations 250
Bayes R2 / Standard Error 0.183 / 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.

tab_model(m2)
  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.66 30.61 – 43.29 16.60 – 53.76 8.72 8.34 – 9.13 7.52 – 9.92
intermediate level of
education
-1.10 -3.92 – 1.73 -9.14 – 7.55 0.21 -0.01 – 0.41 -0.41 – 0.81
high level of education -7.43 -10.37 – -3.54 -17.55 – 3.08 0.71 0.44 – 0.99 -0.04 – 1.53
slightly dependent 1.10 0.77 – 1.42 0.01 – 2.05
moderately dependent 2.32 2.00 – 2.67 1.36 – 3.28
severely dependent 3.87 3.50 – 4.21 2.73 – 4.86
average number of hours
of care per week
0.01 0.00 – 0.01 -0.00 – 0.01
Random Effects
σ2 12.80
τ00 e15relat 0.52
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.

tab_model(m2, 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.66 16.60 – 53.76 8.72 7.52 – 9.92
intermediate level of
education
-1.10 -9.14 – 7.55 0.21 -0.41 – 0.81
high level of education -7.43 -17.55 – 3.08 0.71 -0.04 – 1.53
slightly dependent 1.10 0.01 – 2.05
moderately dependent 2.32 1.36 – 3.28
severely dependent 3.87 2.73 – 4.86
average number of hours
of care per week
0.01 -0.00 – 0.01
Random Effects
σ2 12.80
τ00 e15relat 0.52
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 column Response is added for the multivariate response model, to indicate the different outcomes.

tab_model(m1, m2, show.hdi50 = F)
  count Negative impact with 7
items
Predictors Incidence Rate Ratios HDI (95%) Estimates HDI (95%) Response
Intercept 3.59 0.13 – 42.28 8.72 7.52 – 9.92 negc7
Intercept 3.59 0.13 – 42.28 35.66 16.60 – 53.76 c12hour
child 0.31 0.25 – 0.37
camper 2.13 1.75 – 2.51
slightly dependent 1.10 0.01 – 2.05 negc7
moderately dependent 2.32 1.36 – 3.28 negc7
severely dependent 3.87 2.73 – 4.86 negc7
average number of hours
of care per week
0.01 -0.00 – 0.01 negc7
intermediate level of
education
0.21 -0.41 – 0.81 negc7
high level of education 0.71 -0.04 – 1.53 negc7
intermediate level of
education
-1.10 -9.14 – 7.55 c12hour
high level of education -7.43 -17.55 – 3.08 c12hour
Zero-Inflated Model
Intercept 0.51 0.22 – 0.93
child 3.93 2.06 – 6.44
camper 0.52 0.23 – 0.94
Random Effects
σ2 12.80
τ00   0.52 e15relat
ICC -13.42 icc 0.04 e15relat
460.38 tau.00  
-426.13 resid.var  
34.25 total.var  
Observations 250 834
Bayes R2 / Standard Error 0.183 / 0.028 0.169 / 0.167