Skip to content
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

ROPE range defaults to [-0.1,0.1] instead of '0 +/- .1 * sd(y)' for stan_glm in describe_posterior #589

Merged
merged 12 commits into from
Mar 14, 2023

Conversation

strengejacke
Copy link
Member

Fixes #587

@strengejacke
Copy link
Member Author

library(rstanarm)
d <- data.frame(
  y = c(
    7, 38, 6, 11, 0, 8, 6, 5, 28, 2, 32, 14,
    46, 19, 20, 28, 51, 12, 10, 1, 2, 22
  ),
  x = c(
    46, 41, 30, 30, 61, 42, 63, 13, 52, 59, 42, 45,
    55, 47, 36, 48, 70, 67, 50, 34, 72, 46
  )
)
m <- stan_glm(y ~ x, data = d)
bayestestR::describe_posterior(m)
#> Summary of Posterior Distribution
#> 
#> Parameter   | Median |          95% CI |     pd |          ROPE | % in ROPE |  Rhat |     ESS
#> ---------------------------------------------------------------------------------------------
#> (Intercept) |   9.00 | [-15.60, 33.02] | 77.55% | [-1.48, 1.48] |     7.29% | 1.000 | 3213.00
#> x           |   0.16 | [ -0.32,  0.66] | 76.02% | [-1.48, 1.48] |      100% | 1.000 | 3240.00

Created on 2023-03-14 with reprex v2.0.2

@mattansb
Copy link
Member

What was this doing before?

@strengejacke
Copy link
Member Author

strengejacke commented Mar 14, 2023

It was working several months ago, but then Vincent and I came up with a performance improvement by converting model objects to data frames only once (#532). However, in .describe_posterior(), instead of model objects, a data frame of posteriors was passed to every function (like pd(), rope() etc.). This works well in most situations, except when you want to define the rope range. This PR fixes this issue

@strengejacke
Copy link
Member Author

errors seem unrelated

@strengejacke strengejacke merged commit 6698278 into main Mar 14, 2023
@strengejacke strengejacke deleted the strengejacke/issue587 branch March 14, 2023 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ROPE range defaults to [-0.1,0.1] instead of '0 +/- .1 * sd(y)' for stan_glm in describe_posterior
2 participants