Summary of Bayesian Models as HTML Table

Daniel Lüdecke

2018-10-14

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.11 1.72 – 5.71 0.32 – 33.43
child 0.31 0.29 – 0.33 0.26 – 0.37
camper 2.10 1.99 – 2.26 1.74 – 2.56
Zero-Inflated Model
Intercept 0.53 0.41 – 0.64 0.25 – 1.00
child 3.82 3.02 – 4.47 2.26 – 7.04
camper 0.50 0.40 – 0.66 0.24 – 1.06
Random Effects
σ2 1.00
τ00 persons 5.81
ICC persons 0.73
Observations 250
Bayes R2 / Standard Error 0.185 / 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.54 29.05 – 40.89 16.76 – 53.27 8.73 8.35 – 9.14 7.55 – 9.93
intermediate level of
education
-0.91 -3.73 – 1.63 -9.86 – 6.36 0.19 0.01 – 0.41 -0.46 – 0.78
high level of education -7.30 -11.15 – -4.31 -18.03 – 2.77 0.71 0.44 – 0.99 -0.09 – 1.49
slightly dependent 1.08 0.70 – 1.38 0.10 – 2.10
moderately dependent 2.32 2.02 – 2.72 1.32 – 3.24
severely dependent 3.86 3.54 – 4.28 2.79 – 4.97
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.170 / 0.166

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.54 16.76 – 53.27 8.73 7.55 – 9.93
intermediate level of
education
-0.91 -9.86 – 6.36 0.19 -0.46 – 0.78
high level of education -7.30 -18.03 – 2.77 0.71 -0.09 – 1.49
slightly dependent 1.08 0.10 – 2.10
moderately dependent 2.32 1.32 – 3.24
severely dependent 3.86 2.79 – 4.97
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.170 / 0.166

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.11 0.32 – 33.43 8.73 7.55 – 9.93 negc7
Intercept 3.11 0.32 – 33.43 35.54 16.76 – 53.27 c12hour
child 0.31 0.26 – 0.37
camper 2.10 1.74 – 2.56
slightly dependent 1.08 0.10 – 2.10 negc7
moderately dependent 2.32 1.32 – 3.24 negc7
severely dependent 3.86 2.79 – 4.97 negc7
average number of hours
of care per week
0.01 0.00 – 0.01 negc7
intermediate level of
education
0.19 -0.46 – 0.78 negc7
high level of education 0.71 -0.09 – 1.49 negc7
intermediate level of
education
-0.91 -9.86 – 6.36 c12hour
high level of education -7.30 -18.03 – 2.77 c12hour
Zero-Inflated Model
Intercept 0.53 0.25 – 1.00
child 3.82 2.26 – 7.04
camper 0.50 0.24 – 1.06
Random Effects
σ2 1.00 12.80
τ00 5.81 persons 0.52 e15relat
ICC 0.73 persons 0.04 e15relat
Observations 250 834
Bayes R2 / Standard Error 0.185 / 0.028 0.170 / 0.166