hw1_sol

# 8 linestheta dgammatheta a rateb colgray lwd2

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

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=&quot;l&quot;, xlab=expression(theta), ylab=&quot;Density&quot;, col=&quot;black&quot;, lwd=2, ylim=c(0,.8)) lines(theta, dgamma(theta, a, rate=b), col=&quot;gray&quot;, lwd=2) legend(&quot;topright&quot;, c(expression(p(theta)), expression(paste(p,&quot;(&quot;,theta, &quot;|&quot;, lwd=c(2,2), col=c(&quot;gray&quot;, &quot;black&quot;), bty=&quot;n&quot;) 5 y,&quot;)&quot;))), 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 predeﬁned 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