easystats / bayestestR

:ghost: Utilities for analyzing Bayesian models and posterior distributions
https://easystats.github.io/bayestestR/
GNU General Public License v3.0
563 stars 55 forks source link

Example broken #584

Closed etiennebacher closed 1 year ago

etiennebacher commented 1 year ago

In ci.R:

suppressPackageStartupMessages({
  library(bayestestR)
  library(rstanarm)
})

packageVersion("bayestestR")
#> [1] '0.13.0.2'

model <- stan_glm(mpg ~ wt, data = mtcars, chains = 2, iter = 200, refresh = 0)
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#tail-ess

ci(model, method = "ETI", ci = c(0.80, 0.89))
#> Equal-Tailed Interval
#>
#> Parameter   |        80% ETI |        89% ETI | Effects |   Component
#> ---------------------------------------------------------------------
#> (Intercept) | [34.17, 39.67] | [33.66, 40.39] |   fixed | conditional
#> wt          | [-6.13, -4.40] | [-6.23, -4.23] |   fixed | conditional

ci(model, method = "HDI", ci = c(0.80, 0.89))
#> Highest Density Interval
#>
#> Parameter   |        80% HDI |        89% HDI
#> ---------------------------------------------
#> (Intercept) | [34.18, 39.69] | [33.63, 40.38]
#> wt          | [-6.04, -4.38] | [-6.20, -4.21]

ci(model, method = "SI")
#> Error in match.arg(component): 'arg' must be of length 1

Cf https://github.com/easystats/easystats/issues/326