Model summaries with variance decomposition for brms models

model_summary(brmsfit)

Arguments

brmsfit

The output of a brms model. You can use VarDecomp::brms_model() to produce a brmsfit.

Value

Returns a data frame with the summaries of posterior estimates.

Examples


# Simulate data
md = tibble::tibble(
  group = factor(sample(1:10, 1000, replace = TRUE)),
  f_var = factor(sample(1:3, 1000, replace = TRUE)),
  n_var = rnorm(1000, mean = 0, sd = 1),
  resp = rnorm(1000, mean = 10, sd = 3))

# Run model
mod = brms_model(Response = "resp", 
                 FixedEffect = c("f_var","n_var"), 
                 RandomEffect = "group", 
                 Family = "gaussian", 
                 Data = md)
#> [1] "No problems so far 🤓"
#> Compiling Stan program...
#> Start sampling

# Model summary

model_summary(mod)
#> # A tibble: 11 × 6
#>    variable           mean median     sd lower_HPD upper_HPD
#>    <chr>             <dbl>  <dbl>  <dbl>     <dbl>     <dbl>
#>  1 Intercept        9.97   9.96   0.219      9.52    10.4   
#>  2 f_var2           0.0128 0.0115 0.234     -0.450    0.488 
#>  3 f_var3           0.111  0.107  0.231     -0.354    0.540 
#>  4 n_var            0.0281 0.0276 0.0938    -0.160    0.202 
#>  5 R2_n_var         0.0011 0.0005 0.0016     0        0.0041
#>  6 R2_f_var2        0.0013 0.0006 0.0019     0        0.0052
#>  7 R2_f_var3        0.0016 0.0007 0.0022     0        0.006 
#>  8 R2_FixedEffects  0.004  0.003  0.0036     0        0.0108
#>  9 R2_group         0.0214 0.0162 0.02       0        0.0576
#> 10 R2_RandomEffects 0.0214 0.0162 0.02       0        0.0576
#> 11 R2_residual      0.975  0.980  0.0201     0.939    0.999 
#> hain 1:                37.301 seconds (Sampling)
#> Chain 1:                93.42 seconds (Total)
#> Chain 1: 
#> Chain 2: Iteration: 30000 / 30000 [100%]  (Sampling)
#> Chain 2: 
#> Chain 2:  Elapsed Time: 59.492 seconds (Warm-up)
#> Chain 2:                36.013 seconds (Sampling)
#> Chain 2:                95.505 seconds (Total)
#> Chain 2: