-
I know that |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If you have a priori assumption the effect must be positive, this can be tested to be true with library(rstanarm)
library(bayestestR)
mod <- stan_glm(mpg ~ qsec, data = mtcars)
p_direction(mod)
#> Probability of Direction
#>
#> Parameter | pd
#> --------------------
#> (Intercept) | 67.88%
#> qsec | 99.20%
p_rope(mod, range = c(-Inf, 0.5))
#> Proportion of samples inside the ROPE [-0.10, 0.10]
#>
#>
#> Parameter | p (ROPE)
#> ----------------------
#> (Intercept) | 0.696
#> qsec | 0.062 Or together in describe_posterior(mod, rope_ci = 1, rope_range = c(-Inf, 0.5))
#> Summary of Posterior Distribution
#>
#> Parameter | Median | 95% CI | pd | ROPE | % in ROPE | Rhat | ESS
#> --------------------------------------------------------------------------------------------
#> (Intercept) | -4.91 | [-25.37, 15.93] | 67.88% | [-Inf, 0.50] | 69.58% | 1.001 | 3213.00
#> qsec | 1.39 | [ 0.25, 2.55] | 99.20% | [-Inf, 0.50] | 6.15% | 1.001 | 3158.00 This would be reported as:
Alternatively, this a-priori information can be incorporated into the model in one of few ways. Here is an example, but see that link for more info and details. library(posterior)
posteriors <- as_draws_rvars(mod)
iS <- posteriors$qsec > 0
posteriors_S <- lapply(posteriors, function(p) p[iS]) |> do.call(what = "c")
describe_posterior(posteriors_S, rope_ci = 1, rope_range = c(0, 0.5))
#> Summary of Posterior Distribution
#>
#> Parameter | Median | 95% CI | pd | ROPE | % in ROPE
#> -----------------------------------------------------------------------------
#> x[(Intercept)] | -5.01 | [-25.39, 14.61] | 68.42% | [0.00, 0.50] | 1.71%
#> x[qsec] | 1.40 | [ 0.32, 2.55] | 100% | [0.00, 0.50] | 5.39%
#> x[sigma] | 5.65 | [ 4.44, 7.49] | 100% | [0.00, 0.50] | 0% (Note that the probability of direction is trivially 100% now). This would be reported as:
|
Beta Was this translation helpful? Give feedback.
-
Thanks very much for this great answer! The order constraints blog post, and your example from it, are exactly what I was looking for. I see that it involves "manually" truncating the posterior to remove all negative values. That was what I was thinking, but I didn't know if Anyway, I am not planning to go out and apply this technique right away; I am just going to give a presentation on Bayesian hypothesis testing to some stats folks soon, and I wanted to make sure I am covering all bases! Thanks again for your help. |
Beta Was this translation helpful? Give feedback.
bayesfactor_rope()
has adirection
to allow for comparing different hypotheses in the posterior(/prior)space.p_rope()
does not compare different hypotheses, it "simply" computes the posterior probability of the parameter being in the ROPE.If you have a priori assumption the effect must be positive, this can be tested to be true with
p_direction()
, and the ROPE can be defined with a lower bound of-Inf
.