Description Usage Arguments Details Value References See Also Examples
View source: R/bfactor_to_prob.R
Update the prior probabilities of models/hypotheses to posterior probabilities using Bayes factors.
1 | bfactor_to_prob(bf, prior_prob = 0.5)
|
bf |
A numeric vector of non-negative values. |
prior_prob |
A numeric vector with values in the [0,1] interval. If |
bfactor_to_prob
computes the posterior probability of the null hypothesis using the following equation from \insertCitebergerDelampady1987;textualpcal:
P(null hypothesis | data) = (1 + (1 - prior_prob) / prior_prob * (1 / bf)) ^(-1)
where bf
is a Bayes factor if favor of the null hypothesis and prior_prob
is the prior probability of the null hypothesis. The alternative hypothesis has prior probability 1 - prior_prob
and posterior probability 1 - bfactor_to_prob(bf, prior_prob)
.
The prior_prob
argument is optional and is set to 0.5 by default, implying prior equiprobability of hypotheses. prior_prob
can only be of length
equal to length(bf)
, in which case each prior probability in prior_prob
will be updated using the corresponding element of bf
, or of length
1
, in which case it will be recycled (if length(bf) > 1
) and each element of bf
will update the same prior_prob
value.
If length(bf) > 1
then bfactor_to_prob
returns a numeric vector with the same length
as bf
, otherwise it returns a numeric vector with the same length
as prior_prob
.
bfactor_interpret
and bfactor_interpret_kr
for the interpretation of Bayes factors.
bfactor_log_interpret
and bfactor_log_interpret_kr
for the interpretation of the logarithms of Bayes factors.
bcal
for a p-value calibration that returns lower bounds on Bayes factors in favor of point null hypotheses.
pcal
for a p-value calibration that returns lower bounds on the posterior probabilities of point null hypotheses.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # With a Bayes factor that is indifferent between the null and the alternative hypotheses:
bfactor_to_prob(1)
# Same as above but the null hypothesis has high prior probability:
bfactor_to_prob(1, .99)
# Posterior probability of the null as a function of different prior probabilities:
bfactor_to_prob(1, seq(.5, 1, .1))
# With Bayes factors that favor the null hypothesis:
round(bfactor_to_prob(seq(2, 50, 2.5)), 3)
# Same as above but the null hypothesis has low prior probability:
round(bfactor_to_prob(seq(2, 50, 2.5), prior_prob = .01), 3)
# Posterior probabilities obtained with Bayes factors that favor the alternative hypothesis:
round(bfactor_to_prob(seq(0, 1, .05)), 3)
# Same as above but the null hypothesis has high prior probability:
round(bfactor_to_prob(seq(0, 1, .05), prior_prob = .99), 3)
# Application: chi-squared goodness-of-fit test,
# lower bound on the posterior probability of the null hypothesis:
x <- matrix(c(12, 41, 25, 33), ncol = 2)
bfactor_to_prob(bcal(chisq.test(x)[["p.value"]]), prior_prob = .9)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.