betaPlot()
betaPlot(2,1)
betaPlot(0.5, 2)
# overview of parameters beta distribution:
# a bigger: HDI (Highest Density Interval) more to the left
# b bigger: HDI left, lower values
# both bigger: narrower HDI
a <- b <- c(0.5, 1:4)
par(mfrow=c(length(b), length(a)), yaxt="n", xaxt="n",
oma=c(2,2,4.5,2), mgp=c(3,0.7,0))
for(y in b)
for(x in a)
{
betaPlot(x,y, main="", ylim=c(0.12,3), mar=rep(0,4), xaxs="r")
mtext(text=paste("a=",x,", b=",y, sep=""), side=3, line=-1.5, cex=0.7)
if(y==min(b)) mtext(paste("a =",x), side=3, line=0.5)
if(x==min(a)) mtext(paste("b =",y), side=2, line=0.5)
if(y==max(b) & x==median(a)) axis(1, at=c(0,0.5,1), xaxt="s", las=1)
if(x==max(a) & y==median(b)) axis(4, at=0:3, yaxt="s", las=1)
}
mtext("beta density distribution", line=2.5, outer=TRUE, cex=1.2, font=2)
box("outer")
Run the code above in your browser using DataLab