-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix print() method for model_parameters.stanmvreg()
#173
Labels
Bug 🐛
Something isn't working
Comments
most likely related to easystats/bayestestR#31. |
strengejacke
changed the title
Fix print() method for Dec 26, 2019
model_parameters
fails with Bayesian multivariate glmer modelmodel_parameters.stanmvreg()
set.seed(123)
library(rstanarm)
pbcLong$ybern <- as.integer(pbcLong$logBili >= mean(pbcLong$logBili))
# model
mod <-
rstanarm::stan_mvmer(
formula = list(
ybern ~ year + (1 | id),
albumin ~ sex + year + (year | id)
),
data = pbcLong,
family = list(binomial, gaussian),
chains = 1, cores = 1, seed = 12345, iter = 1000
)
# summary
parameters::model_parameters(mod)
#> Parameter | Median | CI | 89% CI | pd | Rhat | ESS | Prior | Prior_Response
#> ------------------------------------------------------------------------------------------------------------
#> | -0.15 | 89.00 | [-1.99, 1.63] | 55.60% | 1.027 | 81 | NA ( +- ) |
#> | 0.41 | 89.00 | [ 0.28, 0.56] | 100% | 0.998 | 1251 | NA ( +- ) |
#> | 3.46 | 89.00 | [ 3.06, 3.79] | 100% | 1.018 | 142 | NA ( +- ) |
#> | 0.07 | 89.00 | [-0.27, 0.45] | 62.60% | 1.005 | 214 | NA ( +- ) |
#> | -0.13 | 89.00 | [-0.16, -0.10] | 100% | 1.011 | 183 | NA ( +- ) |
#> (Intercept) | | | | | | | Normal (0 +- 10.00) | y1
#> (Intercept) | | | | | | | Normal (0 +- 0.70) | y1
#> sexf | | | | | | | Normal (0 +- 1.39) | y2
#> year | | | | | | | Normal (0 +- 5.57) | y2
#> year | | | | | | | Normal (0 +- 0.39) | y2 Created on 2019-12-26 by the reprex package (v0.3.0) |
# setup
set.seed(123)
library(rstanarm)
#> Loading required package: Rcpp
#> Registered S3 method overwritten by 'xts':
#> method from
#> as.zoo.xts zoo
#> rstanarm (Version 2.19.2, packaged: 2019-10-01 20:20:33 UTC)
#> - Do not expect the default priors to remain the same in future rstanarm versions.
#> Thus, R scripts should specify priors explicitly, even if they are just the defaults.
#> - For execution on a local, multicore CPU with excess RAM we recommend calling
#> options(mc.cores = parallel::detectCores())
#> - bayesplot theme set to bayesplot::theme_default()
#> * Does _not_ affect other ggplot2 plots
#> * See ?bayesplot_theme_set for details on theme setting
pbcLong$ybern <- as.integer(pbcLong$logBili >= mean(pbcLong$logBili))
# model
mod <-
rstanarm::stan_mvmer(
formula = list(
ybern ~ year + (1 | id),
albumin ~ sex + year + (year | id)
),
data = pbcLong,
family = list(binomial, gaussian),
chains = 1, cores = 1, seed = 12345, iter = 1000
)
#> Fitting a multivariate glmer model.
#>
#> Please note the warmup may be much slower than later iterations!
#>
#> SAMPLING FOR MODEL 'mvmer' NOW (CHAIN 1).
#> Chain 1:
#> Chain 1: Gradient evaluation took 0 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1:
#> Chain 1:
#> Chain 1: Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1: Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1: Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1: Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1: Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1: Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1: Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1: Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1: Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1: Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1: Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1: Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 1:
#> Chain 1: Elapsed Time: 5.158 seconds (Warm-up)
#> Chain 1: 2.81 seconds (Sampling)
#> Chain 1: 7.968 seconds (Total)
#> Chain 1:
#> 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
#> http://mc-stan.org/misc/warnings.html#bulk-ess
library(parameters)
model_parameters(mod)
#> # y1 response
#>
#> Parameter | Median | 89% CI | pd | Rhat | ESS | Prior
#> ----------------------------------------------------------------------------------
#> (Intercept) | -0.15 | [-1.99, 1.63] | 55.60% | 1.027 | 81 | Normal (0 +- 10.00)
#> year | 0.41 | [ 0.28, 0.56] | 100% | 0.998 | 1251 | Normal (0 +- 0.70)
#>
#> # y2 response
#>
#> Parameter | Median | 89% CI | pd | Rhat | ESS | Prior
#> ---------------------------------------------------------------------------------
#> (Intercept) | 3.46 | [ 3.06, 3.79] | 100% | 1.018 | 142 | Normal (0 +- 5.57)
#> sexf | 0.07 | [-0.27, 0.45] | 62.60% | 1.005 | 214 | Normal (0 +- 1.39)
#> year | -0.13 | [-0.16, -0.10] | 100% | 1.011 | 183 | Normal (0 +- 0.39) Created on 2019-12-30 by the reprex package (v0.3.0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created on 2019-12-24 by the reprex package (v0.3.0)
Session info
Trace
The text was updated successfully, but these errors were encountered: