#make a visualization of the posterior densities, quick and dirty example #http://andrewgelman.com/2015/10/13/what-do-you-learn-from-p-05-this-example-from-carl-morris-will-blow-your-mind/#comment-247116 #calculate posterior probabilities library(BayesFactor) bf1 <- proportionBF(y = 15, N = 20, p = .5, posterior = TRUE, iterations = 10000) bf2 <- proportionBF(y = 115, N = 200, p = .5, posterior = TRUE, iterations = 10000) bf3 <- proportionBF(y = 1046, N = 2000, p = .5, posterior = TRUE, iterations = 10000) #estimate the densities of each den1 <- density(bf1[,"p"]) den2 <- density(bf2[,"p"]) den3 <- density(bf3[,"p"]) #make the plot plot(den3,xlim=c(0,1)) lines(den2$x,den2$y,col='red') lines(den1$x,den1$y,col='blue') axis(1,at=0:10/10)