Closed TaneishaArora closed 4 years ago
#Code author: Taneisha Arora bayes_hypothesis <- function(prior_alpha, prior_beta, n, x, h_pi){ posterior_alpha <- prior_alpha+x posterior_beta <- prior_beta+n-x prior_odds <- pbeta(h_pi, prior_alpha, prior_beta, lower.tail = FALSE)/ (1-pbeta(h_pi, prior_alpha, prior_beta, lower.tail = FALSE)) posterior_odds <- pbeta(h_pi, posterior_alpha, posterior_beta, lower.tail = FALSE)/ (1-pbeta(h_pi, posterior_alpha, posterior_beta, lower.tail = FALSE)) bayes_factor <- posterior_odds/prior_odds c("prior odds" = prior_odds, "posterior odds" = posterior_odds, "bayes factor" = bayes_factor) }
Thank you Taneisha, I will incorporate this with few changes.
Code to compute the prior odds, posterior odds, and Baye's Factor