Created
August 17, 2017 09:41
-
-
Save twolodzko/2c593d1b5711fbb6850c4cdb1aef4aa7 to your computer and use it in GitHub Desktop.
Examples of uninformative beta priors for binomial distribution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
priors <- c(0, 0.001, 0.333, 0.5, 1) | |
s <- c(0, 1, 1, 5, 5) | |
f <- c(1, 1, 2, 1, 25) | |
dbeta2 <- function(x, prior1, prior2 = prior1) { | |
if (prior1 == 0) | |
x^-1 * (1-x)^-1 | |
else | |
dbeta(x, prior1, prior2) | |
} | |
pardef <- par(mfrow = c(length(s)+1, length(priors)), mar = c(2,1.5,2,1.5)) | |
for (i in seq_along(priors)) { | |
curve(dbeta2(x, priors[i]), 0, 1, n = 1001, xlab = "", ylab = "", | |
axes = FALSE, col = "lightblue", lwd = 2) | |
title(substitute(list(paste(alpha == x), paste(beta == y)), | |
list(x = priors[i], y = priors[i]))) | |
legend("bottomright", "y=0,\nn=0", | |
bty = "n") | |
axis(1, at = c(0, 0.5, 1)) | |
} | |
for (j in seq_along(s)) { | |
for (i in seq_along(priors)) { | |
curve(dbeta(x, s[j] + priors[i], f[j] + priors[i]), 0, 1, | |
n = 1001, xlab = "", ylab = "", axes = FALSE, | |
col = "lightblue", lwd = 2) | |
axis(1, at = c(0, 0.5, 1)) | |
legend("bottomright", paste0("y=", s[j], "\nn=", s[j]+f[j]), | |
bty = "n") | |
} | |
} | |
par(pardef) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment