# # # data ex1_3<-c(1245,5) step<-0.01 a<-0.01 b<-0.01 apost <- ex1_3[2]+a bpost <- ex1_3[1]+b x<-seq(step, 10, step) y <-dbeta( x/1000, apost, bpost ) y2 <-dbeta( x/1000, ex1_3[2]+1, ex1_3[1]+1 ) postscript('chap1_ex02_plot1.ps', width = 10.0, height = 6.0, horizontal=FALSE) par( xaxs='i', yaxs='i', bty='l' , cex=1.3) plot(x,y,type='l', ylab='Posterior density', xlab='Prevalence', ylim=c( min(c(y,y2)), max(c(y,y2))+0.1 ) ) lines(x,y2,col=2,lty=2, xlab='Season', ylab='Field Goals Percentage', xlim=c(0,10)) graphics.off() # posterior mean # 1000*apost/(apost+bpost) # posterior sd # 1000*sqrt(apost*bpost/( (apost+bpost)^2 * (apost+bpost+1) ) ) # 2.5 % quantile # 1000*qbeta( 0.025, apost, bpost) # 97.5 % quantile # 1000*qbeta( 0.975, apost, bpost)