Summary of Baysian Models as HTML Table

Daniel Lüdecke

2018-08-23

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 2.87 1.76 – 5.72 0.31 – 29.63
child 0.31 0.29 – 0.33 0.26 – 0.37
camper 2.10 1.96 – 2.24 1.75 – 2.55
Zero-Inflated Model
Intercept 0.53 0.42 – 0.67 0.26 – 1.01
child 3.85 2.98 – 4.37 2.16 – 6.77
camper 0.51 0.38 – 0.65 0.24 – 1.10
Random Effects
σ2 1.00
τ00 persons 4.92
ICC persons 0.72
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.52 29.21 – 41.02 19.38 – 57.07 8.71 8.31 – 9.08 7.48 – 9.75
intermediate level of
education
-1.10 -3.84 – 1.45 -9.76 – 6.35 0.18 -0.02 – 0.39 -0.45 – 0.80
high level of education -7.44 -11.03 – -4.52 -17.28 – 2.77 0.70 0.39 – 0.92 -0.09 – 1.53
slightly dependent 1.12 0.85 – 1.54 0.10 – 2.12
moderately dependent 2.33 2.05 – 2.74 1.35 – 3.31
severely dependent 3.89 3.48 – 4.19 2.93 – 4.99
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.53
ICC e15relat 0.04
Observations 834
Bayes R2 / Standard Error 0.169 / 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.52 19.38 – 57.07 8.71 7.48 – 9.75
intermediate level of
education
-1.10 -9.76 – 6.35 0.18 -0.45 – 0.80
high level of education -7.44 -17.28 – 2.77 0.70 -0.09 – 1.53
slightly dependent 1.12 0.10 – 2.12
moderately dependent 2.33 1.35 – 3.31
severely dependent 3.89 2.93 – 4.99
average number of hours
of care per week
0.01 -0.00 – 0.01
Random Effects
σ2 12.80
τ00 e15relat 0.53
ICC e15relat 0.04
Observations 834
Bayes R2 / Standard Error 0.169 / 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 2.87 0.31 – 29.63 8.71 7.48 – 9.75 negc7
Intercept 2.87 0.31 – 29.63 35.52 19.38 – 57.07 c12hour
child 0.31 0.26 – 0.37
camper 2.10 1.75 – 2.55
slightly dependent 1.12 0.10 – 2.12 negc7
moderately dependent 2.33 1.35 – 3.31 negc7
severely dependent 3.89 2.93 – 4.99 negc7
average number of hours
of care per week
0.01 -0.00 – 0.01 negc7
intermediate level of
education
0.18 -0.45 – 0.80 negc7
high level of education 0.70 -0.09 – 1.53 negc7
intermediate level of
education
-1.10 -9.76 – 6.35 c12hour
high level of education -7.44 -17.28 – 2.77 c12hour
Zero-Inflated Model
Intercept 0.53 0.26 – 1.01
child 3.85 2.16 – 6.77
camper 0.51 0.24 – 1.10
Random Effects
σ2 1.00 12.80
τ00 4.92 persons 0.53 e15relat
ICC 0.72 persons 0.04 e15relat
Observations 250 834
Bayes R2 / Standard Error 0.185 / 0.028 0.169 / 0.166