# NOT RUN {
# 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)
# }
Run the code above in your browser using DataLab