8 linestheta dgammatheta a rateb colgray lwd2

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 16 = 2.67 Mode(θ|y ) = 6 a−1 b 15 6 a =3 b2 16 = 2.5 Var(θ|y ) = 2 = 0.44 6 =2 Var(θ) = The 95% credible interval for θ is given by (2.19, 4.12). qgamma(c(.025,.975),16, rate=6) [1] 1.524230 4.123370 The following R code can be used to plot the prior and posterior distributions of θ: theta = seq(0, 10, length=5000) a=3; b=1; n=5; sy=13 plot(theta, dgamma(theta, a+sy, rate=b+n), type="l", xlab=expression(theta), ylab="Density", col="black", lwd=2, ylim=c(0,.8)) lines(theta, dgamma(theta, a, rate=b), col="gray", lwd=2) legend("topright", c(expression(p(theta)), expression(paste(p,"(",theta, "|", lwd=c(2,2), col=c("gray", "black"), bty="n") 5 y,")"))), 0.8 0.4 0.0 0.2 Density 0.6 p(θ) p(θ|y) 0 2 4 6 8 10 θ (b) Let z be a future observation. Determine the posterior predictive distribution, p(z |y1 , . . . , y5 ). p( z | y ) = = = = = ￿ Θ p( z | θ ) p ( θ | y ) d θ ￿n ￿ ∞ z −θ θ e (b + n)a+ i=1 yi a+￿n yi −1 −θ(b+n) i=1 ￿ θ e z ! Γ(a + n yi ) 0 i=1 ￿n ￿ (b + n)a+ i=1 yi ∞ z +a+￿n yi −1 −θ(b+n+1) i=1 ￿n θ e z !Γ(a + i=1 yi ) 0 ￿n ￿ (b + n)a+ i=1 yi Γ(a + n yi + z ) i=1 ￿ ￿ n z !Γ(a + n yi ) (b + n + 1)z +a+ i=1 yi i=1 ￿ z+a+ ￿n i=1 yi z Thus, ￿￿ −1 ￿ b+n b+n+1 ￿ a + ￿ n yi ￿ i=1 ￿ n ￿ b+n p(z |y ) ∼ Neg-Binomial a + yi , , b+n+1 i=1 1 b+n+1 ￿z z = 0, 1, . . . This is the negative binomial parametrization for number of failures until a predefined number ￿ bn of successes (here, a + n yi ) are observed and the probability of success is b+++1 . i=1 n For the observed data, n = 5 and thus, ￿5 i=1 yi = 13, and the...
View Full Document

This note was uploaded on 02/22/2013 for the course MATH 604 taught by Professor Tadasee during the Spring '13 term at Georgetown.

Ask a homework question - tutors are online