easystats / parameters

:bar_chart: Computation and processing of models' parameters
https://easystats.github.io/parameters/
GNU General Public License v3.0
427 stars 36 forks source link

brms group-level effects (random effects) do not print using parameters::model_parameters(effects = "all") #824

Closed rbcavanaugh closed 1 year ago

rbcavanaugh commented 1 year ago

I didn't see an issue for this, but apologies if I've missed it. I noticed this when trying to print a cumulative probit model. I think this is new as I've fairly positive I've used the model_parameters() with {brms} models in the past. I do notice that the group-level/random effects are saved to a dataframe if you save the result of model_parameters() to a variable so perhaps its just something with the printing function.

As a very minor note, it might be helpful in the documentation for the effects argument of model_parameters() to indicate that you should put effects = "all" instead of "both". Currently, the documentation reads:

"effects: Should results for fixed effects, random effects or both be returned? Only applies to mixed models. May be abbreviated."

Thanks for a great package!

Reprex:

library(lme4)
#> Loading required package: Matrix
library(brms)
#> Loading required package: Rcpp
#> Loading 'brms' package (version 2.18.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 object is masked from 'package:lme4':
#> 
#>     ngrps
#> The following object is masked from 'package:stats':
#> 
#>     ar
library(parameters)

model1 <- lmer(Sepal.Width ~ Petal.Length + (1 | Species), data = iris)
model_parameters(model1, effects = "all")
#> # Fixed Effects
#> 
#> Parameter    | Coefficient |   SE |       95% CI | t(146) |      p
#> ------------------------------------------------------------------
#> (Intercept)  |        2.00 | 0.56 | [0.89, 3.11] |   3.56 | < .001
#> Petal Length |        0.28 | 0.06 | [0.16, 0.40] |   4.75 | < .001
#> 
#> # Random Effects
#> 
#> Parameter               | Coefficient |   SE |       95% CI
#> -----------------------------------------------------------
#> SD (Intercept: Species) |        0.89 | 0.46 | [0.33, 2.43]
#> SD (Residual)           |        0.32 | 0.02 | [0.28, 0.35]
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a Wald t-distribution approximation. Uncertainty intervals for
#>   random effect variances computed using a Wald z-distribution
#>   approximation.

model2 <- brm(Sepal.Width ~ Petal.Length + (1 | Species), data = iris, refresh = 0)
#> Compiling Stan program...
#> Start sampling
#> Warning: There were 39 divergent transitions after warmup. See
#> https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
#> to find out why this is a problem and how to eliminate them.
#> Warning: Examine the pairs() plot to diagnose sampling problems
model_parameters(model2, effects = "all")
#> # Fixed effects
#> 
#> Parameter    | Median |       95% CI |     pd |  Rhat |     ESS
#> ---------------------------------------------------------------
#> (Intercept)  |   2.02 | [0.47, 3.51] | 99.02% | 1.010 |  596.00
#> Petal.Length |   0.28 | [0.17, 0.41] |   100% | 1.001 | 2002.00
#> 
#> # Fixed effects sigma
#> 
#> Parameter | Median |       95% CI |   pd |  Rhat |     ESS
#> ----------------------------------------------------------
#> sigma     |   0.32 | [0.28, 0.36] | 100% | 1.000 | 2308.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 (2022-10-31)
#>  os       macOS Monterey 12.6
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/New_York
#>  date     2022-12-17
#>  pandoc   2.19.2 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package        * version    date (UTC) lib source
#>  abind            1.4-5      2016-07-21 [1] CRAN (R 4.2.0)
#>  assertthat       0.2.1      2019-03-21 [1] CRAN (R 4.2.0)
#>  backports        1.4.1      2021-12-13 [1] CRAN (R 4.2.0)
#>  base64enc        0.1-3      2015-07-28 [1] CRAN (R 4.2.0)
#>  bayesplot        1.10.0     2022-11-16 [1] CRAN (R 4.2.0)
#>  bayestestR       0.13.0.2   2022-11-30 [1] https://easystats.r-universe.dev (R 4.2.2)
#>  boot             1.3-28     2021-05-03 [1] CRAN (R 4.2.2)
#>  bridgesampling   1.1-2      2021-04-16 [1] CRAN (R 4.2.0)
#>  brms           * 2.18.0     2022-09-19 [1] CRAN (R 4.2.0)
#>  Brobdingnag      1.2-9      2022-10-19 [1] CRAN (R 4.2.0)
#>  callr            3.7.3      2022-11-02 [1] CRAN (R 4.2.0)
#>  checkmate        2.1.0      2022-04-21 [1] CRAN (R 4.2.0)
#>  cli              3.4.1      2022-09-23 [1] CRAN (R 4.2.0)
#>  coda             0.19-4     2020-09-30 [1] CRAN (R 4.2.0)
#>  codetools        0.2-18     2020-11-04 [1] CRAN (R 4.2.2)
#>  colorspace       2.0-3      2022-02-21 [1] CRAN (R 4.2.0)
#>  colourpicker     1.2.0      2022-10-28 [1] CRAN (R 4.2.0)
#>  CompQuadForm     1.4.3      2017-04-12 [1] CRAN (R 4.2.0)
#>  crayon           1.5.2      2022-09-29 [1] CRAN (R 4.2.0)
#>  crosstalk        1.2.0      2021-11-04 [1] CRAN (R 4.2.0)
#>  datawizard       0.6.5      2022-12-14 [1] CRAN (R 4.2.2)
#>  DBI              1.1.3      2022-06-18 [1] CRAN (R 4.2.0)
#>  digest           0.6.30     2022-10-18 [1] CRAN (R 4.2.0)
#>  distributional   0.3.1      2022-09-02 [1] CRAN (R 4.2.0)
#>  dplyr            1.0.10     2022-09-01 [1] CRAN (R 4.2.0)
#>  DT               0.26       2022-10-19 [1] CRAN (R 4.2.0)
#>  dygraphs         1.1.1.6    2018-07-11 [1] CRAN (R 4.2.0)
#>  ellipsis         0.3.2      2021-04-29 [1] CRAN (R 4.2.0)
#>  emmeans          1.8.2      2022-10-27 [1] CRAN (R 4.2.0)
#>  estimability     1.4.1      2022-08-05 [1] CRAN (R 4.2.0)
#>  evaluate         0.18       2022-11-07 [1] CRAN (R 4.2.0)
#>  fansi            1.0.3      2022-03-24 [1] CRAN (R 4.2.0)
#>  farver           2.1.1      2022-07-06 [1] CRAN (R 4.2.0)
#>  fastmap          1.1.0      2021-01-25 [1] CRAN (R 4.2.0)
#>  fs               1.5.2      2021-12-08 [1] CRAN (R 4.2.0)
#>  gamm4            0.2-6      2020-04-03 [1] CRAN (R 4.2.0)
#>  generics         0.1.3      2022-07-05 [1] CRAN (R 4.2.0)
#>  ggplot2          3.4.0      2022-11-04 [1] CRAN (R 4.2.0)
#>  glue             1.6.2      2022-02-24 [1] CRAN (R 4.2.0)
#>  gridExtra        2.3        2017-09-09 [1] CRAN (R 4.2.0)
#>  gtable           0.3.1      2022-09-01 [1] CRAN (R 4.2.0)
#>  gtools           3.9.4      2022-11-27 [1] CRAN (R 4.2.0)
#>  highr            0.9        2021-04-16 [1] CRAN (R 4.2.0)
#>  htmltools        0.5.3      2022-07-18 [1] CRAN (R 4.2.0)
#>  htmlwidgets      1.5.4      2021-09-08 [1] CRAN (R 4.2.0)
#>  httpuv           1.6.6      2022-09-08 [1] CRAN (R 4.2.0)
#>  igraph           1.3.5      2022-09-22 [1] CRAN (R 4.2.0)
#>  inline           0.3.19     2021-05-31 [1] CRAN (R 4.2.0)
#>  insight          0.18.8.2   2022-11-26 [1] https://easystats.r-universe.dev (R 4.2.2)
#>  knitr            1.41       2022-11-18 [1] CRAN (R 4.2.0)
#>  later            1.3.0      2021-08-18 [1] CRAN (R 4.2.0)
#>  lattice          0.20-45    2021-09-22 [1] CRAN (R 4.2.2)
#>  lavaan           0.6-12     2022-07-04 [1] CRAN (R 4.2.0)
#>  lifecycle        1.0.3      2022-10-07 [1] CRAN (R 4.2.0)
#>  lme4           * 1.1-31     2022-11-01 [1] CRAN (R 4.2.0)
#>  loo              2.5.1      2022-03-24 [1] CRAN (R 4.2.0)
#>  magrittr         2.0.3      2022-03-30 [1] CRAN (R 4.2.0)
#>  markdown         1.4        2022-11-16 [1] CRAN (R 4.2.0)
#>  MASS             7.3-58.1   2022-08-03 [1] CRAN (R 4.2.2)
#>  Matrix         * 1.5-1      2022-09-13 [1] CRAN (R 4.2.2)
#>  matrixStats      0.63.0     2022-11-18 [1] CRAN (R 4.2.0)
#>  mgcv             1.8-41     2022-10-21 [1] CRAN (R 4.2.2)
#>  mime             0.12       2021-09-28 [1] CRAN (R 4.2.0)
#>  miniUI           0.1.1.1    2018-05-18 [1] CRAN (R 4.2.0)
#>  minqa            1.2.5      2022-10-19 [1] CRAN (R 4.2.0)
#>  mnormt           2.1.1      2022-09-26 [1] CRAN (R 4.2.0)
#>  munsell          0.5.0      2018-06-12 [1] CRAN (R 4.2.0)
#>  mvtnorm          1.1-3      2021-10-08 [1] CRAN (R 4.2.0)
#>  nlme             3.1-160    2022-10-10 [1] CRAN (R 4.2.2)
#>  nloptr           2.0.3      2022-05-26 [1] CRAN (R 4.2.0)
#>  nonnest2         0.5-5      2020-07-05 [1] CRAN (R 4.2.0)
#>  numDeriv         2016.8-1.1 2019-06-06 [1] CRAN (R 4.2.0)
#>  parameters     * 0.20.0.3   2022-11-30 [1] https://easystats.r-universe.dev (R 4.2.2)
#>  pbivnorm         0.6.0      2015-01-23 [1] CRAN (R 4.2.0)
#>  performance      0.10.1.1   2022-11-25 [1] https://easystats.r-universe.dev (R 4.2.2)
#>  pillar           1.8.1      2022-08-19 [1] CRAN (R 4.2.0)
#>  pkgbuild         1.4.0      2022-11-27 [1] CRAN (R 4.2.0)
#>  pkgconfig        2.0.3      2019-09-22 [1] CRAN (R 4.2.0)
#>  plyr             1.8.8      2022-11-11 [1] CRAN (R 4.2.0)
#>  posterior        1.3.1      2022-09-06 [1] CRAN (R 4.2.0)
#>  prettyunits      1.1.1      2020-01-24 [1] CRAN (R 4.2.0)
#>  processx         3.8.0      2022-10-26 [1] CRAN (R 4.2.0)
#>  projpred         2.2.2      2022-11-09 [1] CRAN (R 4.2.0)
#>  promises         1.2.0.1    2021-02-11 [1] CRAN (R 4.2.0)
#>  ps               1.7.2      2022-10-26 [1] CRAN (R 4.2.0)
#>  R6               2.5.1      2021-08-19 [1] CRAN (R 4.2.0)
#>  Rcpp           * 1.0.9      2022-07-08 [1] CRAN (R 4.2.0)
#>  RcppParallel     5.1.5      2022-01-05 [1] CRAN (R 4.2.0)
#>  reprex           2.0.2      2022-08-17 [1] CRAN (R 4.2.0)
#>  reshape2         1.4.4      2020-04-09 [1] CRAN (R 4.2.0)
#>  rlang            1.0.6      2022-09-24 [1] CRAN (R 4.2.0)
#>  rmarkdown        2.18       2022-11-09 [1] CRAN (R 4.2.0)
#>  rstan            2.21.7     2022-09-08 [1] CRAN (R 4.2.0)
#>  rstantools       2.2.0      2022-04-08 [1] CRAN (R 4.2.0)
#>  rstudioapi       0.14       2022-08-22 [1] CRAN (R 4.2.0)
#>  sandwich         3.0-2      2022-06-15 [1] CRAN (R 4.2.0)
#>  scales           1.2.1      2022-08-20 [1] CRAN (R 4.2.0)
#>  sessioninfo      1.2.2      2021-12-06 [1] CRAN (R 4.2.0)
#>  shiny            1.7.3      2022-10-25 [1] CRAN (R 4.2.0)
#>  shinyjs          2.1.0      2021-12-23 [1] CRAN (R 4.2.0)
#>  shinystan        2.6.0      2022-03-03 [1] CRAN (R 4.2.0)
#>  shinythemes      1.2.0      2021-01-25 [1] CRAN (R 4.2.0)
#>  StanHeaders      2.21.0-7   2020-12-17 [1] CRAN (R 4.2.0)
#>  stringi          1.7.8      2022-07-11 [1] CRAN (R 4.2.0)
#>  stringr          1.5.0      2022-12-02 [1] CRAN (R 4.2.0)
#>  tensorA          0.36.2     2020-11-19 [1] CRAN (R 4.2.0)
#>  threejs          0.3.3      2020-01-21 [1] CRAN (R 4.2.0)
#>  tibble           3.1.8      2022-07-22 [1] CRAN (R 4.2.0)
#>  tidyselect       1.2.0      2022-10-10 [1] CRAN (R 4.2.0)
#>  utf8             1.2.2      2021-07-24 [1] CRAN (R 4.2.0)
#>  vctrs            0.5.1      2022-11-16 [1] CRAN (R 4.2.0)
#>  withr            2.5.0      2022-03-03 [1] CRAN (R 4.2.0)
#>  xfun             0.35       2022-11-16 [1] CRAN (R 4.2.0)
#>  xtable           1.8-4      2019-04-21 [1] CRAN (R 4.2.0)
#>  xts              0.12.2     2022-10-16 [1] CRAN (R 4.2.0)
#>  yaml             2.3.6      2022-10-18 [1] CRAN (R 4.2.0)
#>  zoo              1.8-11     2022-09-17 [1] CRAN (R 4.2.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Created on 2022-12-17 with reprex v2.0.2

strengejacke commented 1 year ago

This is due to the new Group column for Bayesian models, which doesn't work nicely with insight::print_parameters(). I think we can just remove the special class for Bayesian models and treat it like any other model (regarding formatting/printing). I'm testing this in PR #825 - you can install from that PR and test some models for yourself and report any issues, if you like.

strengejacke commented 1 year ago

Current state of the PR:

library(parameters)
library(brms)
library(lme4)

data(sleepstudy)
model1 <- lmer(Sepal.Width ~ Petal.Length + (1 | Species), data = iris)
model_parameters(model1, effects = "all")
#> # Fixed Effects
#> 
#> Parameter    | Coefficient |   SE |       95% CI | t(146) |      p
#> ------------------------------------------------------------------
#> (Intercept)  |        2.00 | 0.56 | [0.89, 3.11] |   3.56 | < .001
#> Petal Length |        0.28 | 0.06 | [0.16, 0.40] |   4.75 | < .001
#> 
#> # Random Effects
#> 
#> Parameter               | Coefficient |   SE |       95% CI
#> -----------------------------------------------------------
#> SD (Intercept: Species) |        0.89 | 0.46 | [0.33, 2.43]
#> SD (Residual)           |        0.32 | 0.02 | [0.28, 0.35]
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a Wald t-distribution approximation. Uncertainty intervals for
#>   random effect variances computed using a Wald z-distribution
#>   approximation.

model2 <- suppressWarnings(brm(Sepal.Width ~ Petal.Length + (1 | Species), data = iris, refresh = 0))
model_parameters(model2, effects = "all")
#> # Fixed Effects
#> 
#> Parameter    | Median |       95% CI |     pd |  Rhat |     ESS
#> ---------------------------------------------------------------
#> (Intercept)  |   1.99 | [0.48, 3.55] | 98.98% | 1.009 |  825.00
#> Petal.Length |   0.28 | [0.16, 0.41] |   100% | 1.002 | 1924.00
#> 
#> # Sigma
#> 
#> Parameter | Median |       95% CI |   pd |  Rhat |     ESS
#> ----------------------------------------------------------
#> sigma     |   0.32 | [0.28, 0.36] | 100% | 1.003 | 2188.00
#> 
#> # Random Effects Variances
#> 
#> Parameter               | Median |       95% CI |   pd |  Rhat |     ESS
#> ------------------------------------------------------------------------
#> SD (Intercept: Species) |   1.21 | [0.49, 3.48] | 100% | 1.003 | 1113.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.

model3 <- lmer(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy)
model_parameters(model3, effects = "all")
#> # Fixed Effects
#> 
#> Parameter   | Coefficient |   SE |           95% CI | t(174) |      p
#> ---------------------------------------------------------------------
#> (Intercept) |      251.41 | 6.82 | [237.94, 264.87] |  36.84 | < .001
#> Days        |       10.47 | 1.55 | [  7.42,  13.52] |   6.77 | < .001
#> 
#> # Random Effects
#> 
#> Parameter                     | Coefficient |   SE |         95% CI
#> -------------------------------------------------------------------
#> SD (Intercept: Subject)       |       24.74 | 5.84 | [15.58, 39.28]
#> SD (Days: Subject)            |        5.92 | 1.25 | [ 3.92,  8.95]
#> Cor (Intercept~Days: Subject) |        0.07 | 0.32 | [-0.51,  0.60]
#> SD (Residual)                 |       25.59 | 1.51 | [22.80, 28.72]
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a Wald t-distribution approximation. Uncertainty intervals for
#>   random effect variances computed using a Wald z-distribution
#>   approximation.

model4 <- suppressWarnings(brm(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy, refresh = 0))
model_parameters(model4, effects = "all")
#> # Fixed Effects
#> 
#> Parameter   | Median |           95% CI |   pd |  Rhat |     ESS
#> ----------------------------------------------------------------
#> (Intercept) | 251.13 | [237.02, 264.93] | 100% | 1.001 | 2051.00
#> Days        |  10.44 | [  7.17,  13.81] | 100% | 1.002 | 1611.00
#> 
#> # Sigma
#> 
#> Parameter | Median |         95% CI |   pd |  Rhat |     ESS
#> ------------------------------------------------------------
#> sigma     |  25.80 | [23.09, 29.36] | 100% | 1.002 | 3269.00
#> 
#> # Random Effects Variances
#> 
#> Parameter                     | Median |         95% CI |     pd |  Rhat |     ESS
#> ----------------------------------------------------------------------------------
#> SD (Intercept: Subject)       |  25.90 | [15.34, 41.58] |   100% | 1.001 | 1667.00
#> SD (Days: Subject)            |   6.32 | [ 4.06, 10.01] |   100% | 1.002 | 1592.00
#> Cor (Intercept~Days: Subject) |   0.10 | [-0.47,  0.70] | 62.75% | 1.001 | 1032.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.

Created on 2022-12-21 with reprex v2.0.2

strengejacke commented 1 year ago
library(easystats)
library(brms)

m <- download_model("brms_1")
model_parameters(m, effects = "all", component = "all", centrality = "mean")
#> # Fixed Effects
#> 
#> Parameter   |  Mean |         95% CI |     pd |  Rhat |     ESS
#> ---------------------------------------------------------------
#> (Intercept) | 39.68 | [36.12, 43.27] |   100% | 1.000 | 5242.00
#> wt          | -3.21 | [-4.79, -1.65] | 99.95% | 1.000 | 2071.00
#> cyl         | -1.50 | [-2.36, -0.64] | 99.95% | 1.000 | 1951.00
#> 
#> # Sigma
#> 
#> Parameter | Mean |       95% CI |   pd |  Rhat |     ESS
#> --------------------------------------------------------
#> sigma     | 2.67 | [2.06, 3.51] | 100% | 1.000 | 2390.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.
summary(m)
#>  Family: gaussian 
#>   Links: mu = identity; sigma = identity 
#> Formula: mpg ~ wt + cyl 
#>    Data: mtcars (Number of observations: 32) 
#>   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#>          total post-warmup draws = 4000
#> 
#> Population-Level Effects: 
#>           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept    39.68      1.81    36.12    43.27 1.00     5283     3255
#> wt           -3.21      0.81    -4.79    -1.65 1.00     2120     2003
#> cyl          -1.50      0.44    -2.36    -0.64 1.00     2001     2227
#> 
#> Family Specific Parameters: 
#>       Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sigma     2.67      0.37     2.06     3.51 1.00     2534     2415
#> 
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).

m <- download_model("brms_mixed_1")
model_parameters(m, effects = "all", component = "all", centrality = "mean")
#> # Fixed Effects
#> 
#> Parameter   |  Mean |         95% CI |   pd |  Rhat |   ESS
#> -----------------------------------------------------------
#> (Intercept) | 33.55 | [24.17, 40.87] | 100% | 1.091 | 24.00
#> wt          | -4.49 | [-6.95, -1.68] | 100% | 1.192 | 10.00
#> 
#> # Sigma
#> 
#> Parameter | Mean |       95% CI |   pd |  Rhat |    ESS
#> -------------------------------------------------------
#> sigma     | 2.56 | [1.95, 3.48] | 100% | 1.015 | 454.00
#> 
#> # Random Effects Variances
#> 
#> Parameter                |  Mean |         95% CI |     pd |  Rhat |    ESS
#> ---------------------------------------------------------------------------
#> SD (Intercept: cyl)      |  3.00 | [ 0.39,  9.19] |   100% | 1.080 |  32.00
#> SD (Intercept: gear)     |  3.88 | [ 0.21, 10.30] |   100% | 1.010 | 424.00
#> SD (wt: gear)            |  1.96 | [ 0.06,  5.06] |   100% | 1.385 |   9.00
#> Cor (Intercept~wt: gear) | -0.25 | [-0.99,  0.83] | 62.48% | 1.106 |  36.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.
summary(m)
#>  Family: gaussian 
#>   Links: mu = identity; sigma = identity 
#> Formula: mpg ~ wt + (1 | cyl) + (1 + wt | gear) 
#>    Data: mtcars (Number of observations: 32) 
#>   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#>          total post-warmup draws = 4000
#> 
#> Group-Level Effects: 
#> ~cyl (Number of levels: 3) 
#>               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept)     3.00      2.34     0.39     9.19 1.11       28      575
#> 
#> ~gear (Number of levels: 3) 
#>                   Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept)         3.88      2.84     0.21    10.30 1.28      415      916
#> sd(wt)                1.96      1.60     0.06     5.06 1.22       14      186
#> cor(Intercept,wt)    -0.25      0.57    -0.99     0.83 1.08       43       85
#> 
#> Population-Level Effects: 
#>           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept    33.55      4.23    24.17    40.87 1.09       35      157
#> wt           -4.49      1.44    -6.95    -1.68 1.17       18       81
#> 
#> Family Specific Parameters: 
#>       Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sigma     2.56      0.38     1.95     3.48 1.29      414      541
#> 
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).

m <- download_model("brms_mixed_2")
model_parameters(m, effects = "all", component = "all", centrality = "mean")
#> # Fixed Effects
#> 
#> Parameter   |   Mean |           95% CI |   pd |  Rhat |     ESS
#> ----------------------------------------------------------------
#> (Intercept) | 251.32 | [237.00, 265.98] | 100% | 1.001 | 1621.00
#> Days        |  10.44 | [  6.84,  13.91] | 100% | 1.004 | 1161.00
#> 
#> # Sigma
#> 
#> Parameter |  Mean |         95% CI |   pd |  Rhat |     ESS
#> -----------------------------------------------------------
#> sigma     | 25.94 | [23.05, 29.38] | 100% | 1.000 | 3672.00
#> 
#> # Random Effects Variances
#> 
#> Parameter                     |  Mean |         95% CI |     pd |  Rhat |     ESS
#> ---------------------------------------------------------------------------------
#> SD (Intercept: Subject)       | 26.63 | [15.46, 42.36] |   100% | 1.002 | 1823.00
#> SD (Days: Subject)            |  6.58 | [ 4.12, 10.16] |   100% | 1.000 | 1228.00
#> Cor (Intercept~Days: Subject) |  0.09 | [-0.47,  0.67] | 60.42% | 1.003 |  899.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.
summary(m)
#>  Family: gaussian 
#>   Links: mu = identity; sigma = identity 
#> Formula: Reaction ~ Days + (1 + Days | Subject) 
#>    Data: sleepstudy (Number of observations: 180) 
#>   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#>          total post-warmup draws = 4000
#> 
#> Group-Level Effects: 
#> ~Subject (Number of levels: 18) 
#>                     Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept)          26.63      6.77    15.46    42.36 1.00     1858     2683
#> sd(Days)                6.58      1.59     4.12    10.16 1.00     1355     1961
#> cor(Intercept,Days)     0.09      0.30    -0.47     0.67 1.00      912     1625
#> 
#> Population-Level Effects: 
#>           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept   251.32      7.31   237.00   265.98 1.00     1626     2415
#> Days         10.44      1.75     6.84    13.91 1.00     1224     1641
#> 
#> Family Specific Parameters: 
#>       Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sigma    25.94      1.59    23.05    29.38 1.00     3686     2781
#> 
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).

m <- download_model("brms_mixed_3")
model_parameters(m, effects = "all", component = "all", centrality = "mean")
#> # Fixed Effects
#> 
#> Parameter   |   Mean |           95% CI |   pd |  Rhat |     ESS
#> ----------------------------------------------------------------
#> (Intercept) | 250.84 | [228.76, 272.54] | 100% | 1.003 |  786.00
#> Days        |  10.37 | [  8.77,  11.96] | 100% | 0.999 | 6026.00
#> 
#> # Sigma
#> 
#> Parameter |  Mean |         95% CI |   pd |  Rhat |     ESS
#> -----------------------------------------------------------
#> sigma     | 30.03 | [26.27, 34.03] | 100% | 0.999 | 2102.00
#> 
#> # Random Effects Variances
#> 
#> Parameter                  |  Mean |         95% CI |   pd |  Rhat |     ESS
#> ----------------------------------------------------------------------------
#> SD (Intercept: grp)        |  8.22 | [ 0.44, 25.69] | 100% | 1.000 | 1604.00
#> SD (Intercept: grp:subgrp) |  7.41 | [ 0.44, 16.87] | 100% | 1.003 |  770.00
#> SD (Intercept: Subject)    | 38.51 | [26.89, 55.98] | 100% | 1.003 | 1254.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.
summary(m)
#>  Family: gaussian 
#>   Links: mu = identity; sigma = identity 
#> Formula: Reaction ~ Days + (1 | grp/subgrp) + (1 | Subject) 
#>    Data: sleepstudy (Number of observations: 180) 
#>   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#>          total post-warmup draws = 4000
#> 
#> Group-Level Effects: 
#> ~grp (Number of levels: 5) 
#>               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept)     8.22      6.92     0.44    25.69 1.00     1455     1788
#> 
#> ~grp:subgrp (Number of levels: 70) 
#>               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept)     7.41      4.61     0.44    16.87 1.00      793     1480
#> 
#> ~Subject (Number of levels: 18) 
#>               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept)    38.51      7.48    26.89    55.98 1.00     1243     1893
#> 
#> Population-Level Effects: 
#>           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept   250.84     11.20   228.76   272.54 1.00      803     1607
#> Days         10.37      0.81     8.77    11.96 1.00     6123     2848
#> 
#> Family Specific Parameters: 
#>       Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sigma    30.03      1.99    26.27    34.03 1.00     2150     2289
#> 
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).

m <- download_model("brms_mixed_4")
model_parameters(m, effects = "all", component = "all", centrality = "mean")
#> # Fixed Effects
#> 
#> Parameter   | Mean |       95% CI |     pd |  Rhat |     ESS
#> ------------------------------------------------------------
#> (Intercept) | 2.57 | [0.70, 4.84] | 99.42% | 1.012 |  292.00
#> Petal.Width | 1.05 | [0.73, 1.37] |   100% | 1.002 | 2150.00
#> 
#> # Sigma
#> 
#> Parameter | Mean |       95% CI |   pd |  Rhat |     ESS
#> --------------------------------------------------------
#> sigma     | 0.38 | [0.34, 0.43] | 100% | 1.001 | 2642.00
#> 
#> # Random Effects Variances
#> 
#> Parameter               | Mean |       95% CI |   pd |  Rhat |    ESS
#> ---------------------------------------------------------------------
#> SD (Intercept: Species) | 1.68 | [0.64, 3.64] | 100% | 1.003 | 796.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.
summary(m)
#>  Family: gaussian 
#>   Links: mu = identity; sigma = identity 
#> Formula: Petal.Length ~ Petal.Width + (1 | Species) 
#>    Data: iris (Number of observations: 150) 
#>   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#>          total post-warmup draws = 4000
#> 
#> Group-Level Effects: 
#> ~Species (Number of levels: 3) 
#>               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept)     1.68      0.80     0.64     3.64 1.01     1001      774
#> 
#> Population-Level Effects: 
#>             Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept       2.57      0.96     0.70     4.84 1.01      425      197
#> Petal.Width     1.05      0.16     0.73     1.37 1.00     2191     2213
#> 
#> Family Specific Parameters: 
#>       Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sigma     0.38      0.02     0.34     0.43 1.00     2653     2011
#> 
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).

m <- download_model("brms_mixed_7")
model_parameters(m, effects = "all", component = "all", centrality = "mean")
#> # Fixed Effects
#> 
#> Parameter   |  Mean |         95% CI |     pd |  Rhat |    ESS
#> --------------------------------------------------------------
#> (Intercept) | 33.06 | [24.70, 40.47] |   100% | 1.006 | 744.00
#> wt          | -4.39 | [-6.94, -1.76] | 99.72% | 1.025 |  83.00
#> 
#> # Sigma
#> 
#> Parameter | Mean |       95% CI |   pd |  Rhat |    ESS
#> -------------------------------------------------------
#> sigma     | 2.59 | [1.96, 3.48] | 100% | 1.010 | 608.00
#> 
#> # Random Effects Variances
#> 
#> Parameter                |  Mean |         95% CI |     pd |  Rhat |    ESS
#> ---------------------------------------------------------------------------
#> SD (Intercept: cyl)      |  3.19 | [ 0.49,  9.00] |   100% | 1.001 | 651.00
#> SD (Intercept: gear)     |  3.76 | [ 0.14, 10.13] |   100% | 1.015 | 643.00
#> SD (wt: gear)            |  1.47 | [ 0.06,  3.96] |   100% | 1.039 |  94.00
#> Cor (Intercept~wt: gear) | -0.38 | [-0.99,  0.82] | 76.85% | 1.003 | 854.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.
summary(m)
#>  Family: gaussian 
#>   Links: mu = identity; sigma = identity 
#> Formula: mpg ~ wt + (1 | cyl) + (1 + wt | gear) 
#>    Data: mtcars (Number of observations: 32) 
#>   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#>          total post-warmup draws = 4000
#> 
#> Group-Level Effects: 
#> ~cyl (Number of levels: 3) 
#>               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept)     3.19      2.35     0.49     9.00 1.00      549      350
#> 
#> ~gear (Number of levels: 3) 
#>                   Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept)         3.76      2.76     0.14    10.13 1.02      592     1264
#> sd(wt)                1.47      1.20     0.06     3.96 1.03      115      660
#> cor(Intercept,wt)    -0.38      0.52    -0.99     0.82 1.02      915      893
#> 
#> Population-Level Effects: 
#>           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept    33.06      3.96    24.70    40.47 1.02      712      666
#> wt           -4.39      1.39    -6.94    -1.76 1.02       98      102
#> 
#> Family Specific Parameters: 
#>       Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sigma     2.59      0.38     1.96     3.48 1.01      605      902
#> 
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).

m <- download_model("brms_zi_1")
model_parameters(m, effects = "all", component = "all", centrality = "mean")
#> # Fixed Effects
#> 
#> Parameter   |  Mean |         95% CI |   pd |  Rhat |     ESS
#> -------------------------------------------------------------
#> (Intercept) | -1.07 | [-1.42, -0.73] | 100% | 1.000 | 3259.00
#> persons     |  0.90 | [ 0.81,  0.99] | 100% | 1.000 | 3305.00
#> child       | -1.17 | [-1.37, -0.99] | 100% | 1.000 | 3224.00
#> camper      |  0.74 | [ 0.56,  0.94] | 100% | 1.000 | 4166.00
#> 
#> # Zero-Inflation
#> 
#> Parameter   |  Mean |        95% CI |     pd |  Rhat |     ESS
#> --------------------------------------------------------------
#> (Intercept) | -0.58 | [-1.27, 0.08] | 95.97% | 1.000 | 4494.00
#> child       |  1.24 | [ 0.71, 1.82] |   100% | 1.000 | 4195.00
#> camper      | -0.62 | [-1.38, 0.11] | 94.73% | 1.000 | 4427.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.
#> 
#> The model has a log- or logit-link. Consider using `exponentiate =
#>   TRUE` to interpret coefficients as ratios.
summary(m)
#>  Family: zero_inflated_poisson 
#>   Links: mu = log; zi = logit 
#> Formula: count ~ persons + child + camper 
#>          zi ~ child + camper
#>    Data: zinb (Number of observations: 250) 
#>   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#>          total post-warmup draws = 4000
#> 
#> Population-Level Effects: 
#>              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept       -1.07      0.18    -1.42    -0.73 1.00     3304     2806
#> zi_Intercept    -0.58      0.34    -1.27     0.08 1.00     4543     2969
#> persons          0.90      0.05     0.81     0.99 1.00     3354     3057
#> child           -1.17      0.10    -1.37    -0.99 1.00     3306     2560
#> camper           0.74      0.10     0.56     0.94 1.00     4220     2879
#> zi_child         1.24      0.28     0.71     1.82 1.00     4168     2872
#> zi_camper       -0.62      0.38    -1.38     0.11 1.00     4367     3040
#> 
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).

m <- download_model("brms_zi_3")
model_parameters(m, effects = "all", component = "all", centrality = "mean")
#> # Fixed Effects (Count Model)
#> 
#> Parameter   |  Mean |         95% CI |     pd |  Rhat |    ESS
#> --------------------------------------------------------------
#> (Intercept) |  0.96 | [-0.81,  2.51] | 90.00% | 1.011 | 110.00
#> child       | -1.16 | [-1.36, -0.94] |   100% | 0.996 | 278.00
#> camper      |  0.72 | [ 0.54,  0.91] |   100% | 0.996 | 271.00
#> 
#> # Fixed Effects (Zero-Inflation Component)
#> 
#> Parameter   |  Mean |         95% CI |     pd |  Rhat |    ESS
#> --------------------------------------------------------------
#> (Intercept) | -0.51 | [-2.03,  0.89] | 78.00% | 0.997 | 138.00
#> child       |  1.86 | [ 1.19,  2.54] |   100% | 0.996 | 303.00
#> camper      | -0.86 | [-1.61, -0.07] | 98.40% | 0.996 | 292.00
#> 
#> # Random Effects Variances
#> 
#> Parameter               | Mean |       95% CI |   pd |  Rhat |    ESS
#> ---------------------------------------------------------------------
#> SD (Intercept: persons) | 1.58 | [0.71, 3.58] | 100% | 1.010 | 126.00
#> 
#> # Random Effects (Zero-Inflation Component)
#> 
#> Parameter               | Mean |       95% CI |   pd |  Rhat |    ESS
#> ---------------------------------------------------------------------
#> SD (Intercept: persons) | 1.49 | [0.63, 3.41] | 100% | 0.996 | 129.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.
summary(m)
#>  Family: zero_inflated_poisson 
#>   Links: mu = log; zi = logit 
#> Formula: count ~ child + camper + (1 | persons) 
#>          zi ~ child + camper + (1 | persons)
#>    Data: zinb (Number of observations: 250) 
#>   Draws: 1 chains, each with iter = 500; warmup = 250; thin = 1;
#>          total post-warmup draws = 250
#> 
#> Group-Level Effects: 
#> ~persons (Number of levels: 4) 
#>                  Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept)        1.58      0.74     0.71     3.58 1.01      128      133
#> sd(zi_Intercept)     1.49      0.72     0.63     3.41 1.01      124      161
#> 
#> Population-Level Effects: 
#>              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept        0.96      0.82    -0.81     2.51 1.01      114      152
#> zi_Intercept    -0.51      0.72    -2.03     0.89 1.01      149      161
#> child           -1.16      0.10    -1.36    -0.94 1.00      258      190
#> camper           0.72      0.10     0.54     0.91 1.02      294      113
#> zi_child         1.86      0.33     1.19     2.54 1.00      321      241
#> zi_camper       -0.86      0.40    -1.61    -0.07 1.00      286      137
#> 
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).

m <- download_model("brms_ordinal_1")
model_parameters(m, effects = "all", component = "all", centrality = "mean")
#> Parameter    |   Mean |           95% CI |   pd |  Rhat |     ESS
#> -----------------------------------------------------------------
#> Intercept[1] | -38.42 | [-67.76, -19.66] | 100% | 1.002 |  992.00
#> Intercept[2] | -33.26 | [-59.09, -16.53] | 100% | 1.001 | 1039.00
#> mpg          |  -1.80 | [ -3.20,  -0.90] | 100% | 1.002 | 1021.00
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.
#> 
#> The model has a log- or logit-link. Consider using `exponentiate =
#>   TRUE` to interpret coefficients as ratios.
summary(m)
#>  Family: cumulative 
#>   Links: mu = logit; disc = identity 
#> Formula: cyl_ord ~ mpg 
#>    Data: mtcars (Number of observations: 32) 
#>   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#>          total post-warmup draws = 4000
#> 
#> Population-Level Effects: 
#>              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept[1]   -38.42     12.46   -67.76   -19.66 1.00     1154     1121
#> Intercept[2]   -33.26     11.04   -59.09   -16.53 1.00     1223     1111
#> mpg             -1.80      0.59    -3.20    -0.90 1.00     1197     1172
#> 
#> Family Specific Parameters: 
#>      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> disc     1.00      0.00     1.00     1.00   NA       NA       NA
#> 
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).

Created on 2022-12-21 with reprex v2.0.2

strengejacke commented 1 year ago

@easystats/core-team can we add some snapshot tests for the print-methods? Since we download the models, they shouldn't change in their output.