Docsity

Solved Assignment 3 for Bayesian Inference and Analysis | ST 740, Assignments of Statistics

Toggle sidebar
bg1
ST740 – Assignment 3 – Due 9/29
1. MCMC for Bayesian density estimation: A common way to do density estimation
is to model the density as a mixture of normals. Assume the likelihood is a two-
component mixture
p(yi|µ0, µ1, τ0, τ1, π) = (1 −π)N(µ0, τ0) + πN(µ1, τ1),
where i= 1, ..., n,N(a, b) is the normal density with mean aand variance 1/b (this
parameterization is used throughout the assignment) and the priors are π∼Beta(1,1),
µ0, µ1∼N(0,0.01), and τ0, τ1∼Gamma(0.01,0.01), parameterized (this parameteriza-
tion is used throughout the assignment) to have mean 1 and variance 100. To make
the model fully-conjugate, we introduce the auxiliary variable giand rewrite the model
as
yi|gi, µ0, µ1, τ0, τ1∼N(µgi, τgi) and gi∼Bern(π),
where the remaining parameters have the same priors.
•Marginalize over gito verify that these models are indeed equivalent.
•Specify the full-conditional distributions of gi,π,µ0,µ1,τ0and τ1.
•Write MCMC code for this model. Turn in commented code.
•Generate a data set of size n= 1000 from the model p(y|rest)=0.5∗N(1,1) +
0.5∗N(5,0.1) and analyze it with your MCMC code. Submit a single plot with
a histogram of the data, the true density, and the posterior mean density (that
is, for each sample compute the density on a grid, and record the posterior mean
density at each grid location).
•Postulate a fully-conjugate model for a k > 2 component mixture of normals.
2. MCMC for the balanced one-way random effects model: The balanced one-
way random effects model is yij =µj+εij, where i= 1, ..., n is the replication number
within subject, j= 1, ..., m is the subject number, µj∼N(0, τ1), and εij ∼N(0, τ2).
Use the hyperpriors τ1, τ2∼Gamma(0.01,0.01).
•Specify the full-conditional distributions of µj,τ1, and τ2.
•Write MCMC code for this model. Turn in commented code.
•Analyze these data: first subject y1= (y11, ..., yn1)=(−3,−2,−1,0,1), second
subject y2= (4,5,6,7,8), third subject y3= (−1,0,0,0,1). Summarize the
posteriors of τ1,τ2, and r=τ2/τ1in a table and make a scatter plot of the
posterior draws of (τ1, τ2).
•Give a closed-form expression for p(τ1, τ2|y). Make a contour plot of p(τ1, τ2|y)
on a grid of (τ1, τ2). Does the contour plot resemble the scatter plot from the
previous question?
1

Partial preview of the text

Download Solved Assignment 3 for Bayesian Inference and Analysis | ST 740 and more Assignments Statistics in PDF only on Docsity!

ST740 – Assignment 3 – Due 9/

  1. MCMC for Bayesian density estimation: A common way to do density estimation is to model the density as a mixture of normals. Assume the likelihood is a two- component mixture

p(yi|μ 0 , μ 1 , τ 0 , τ 1 , π) = (1 − π)N (μ 0 , τ 0 ) + πN (μ 1 , τ 1 ),

where i = 1, ..., n, N (a, b) is the normal density with mean a and variance 1/b (this parameterization is used throughout the assignment) and the priors are π ∼Beta(1,1), μ 0 , μ 1 ∼ N(0,0.01), and τ 0 , τ 1 ∼Gamma(0.01,0.01), parameterized (this parameteriza- tion is used throughout the assignment) to have mean 1 and variance 100. To make the model fully-conjugate, we introduce the auxiliary variable gi and rewrite the model as yi|gi, μ 0 , μ 1 , τ 0 , τ 1 ∼ N (μgi , τgi ) and gi ∼ Bern(π), where the remaining parameters have the same priors.

  • Marginalize over gi to verify that these models are indeed equivalent.
  • Specify the full-conditional distributions of gi, π, μ 0 , μ 1 , τ 0 and τ 1.
  • Write MCMC code for this model. Turn in commented code.
  • Generate a data set of size n = 1000 from the model p(y|rest) = 0. 5 ∗ N (1, 1) +
    1. 5 ∗ N (5, 0 .1) and analyze it with your MCMC code. Submit a single plot with a histogram of the data, the true density, and the posterior mean density (that is, for each sample compute the density on a grid, and record the posterior mean density at each grid location).
  • Postulate a fully-conjugate model for a k > 2 component mixture of normals.
  1. MCMC for the balanced one-way random effects model: The balanced one- way random effects model is yij = μj + εij , where i = 1, ..., n is the replication number within subject, j = 1, ..., m is the subject number, μj ∼ N (0, τ 1 ), and εij ∼ N (0, τ 2 ). Use the hyperpriors τ 1 , τ 2 ∼ Gamma(0.01,0.01).
  • Specify the full-conditional distributions of μj , τ 1 , and τ 2.
  • Write MCMC code for this model. Turn in commented code.
  • Analyze these data: first subject y 1 = (y 11 , ..., yn 1 ) = (− 3 , − 2 , − 1 , 0 , 1), second subject y 2 = (4, 5 , 6 , 7 , 8), third subject y 3 = (− 1 , 0 , 0 , 0 , 1). Summarize the posteriors of τ 1 , τ 2 , and r = τ 2 /τ 1 in a table and make a scatter plot of the posterior draws of (τ 1 , τ 2 ).
  • Give a closed-form expression for p(τ 1 , τ 2 |y). Make a contour plot of p(τ 1 , τ 2 |y) on a grid of (τ 1 , τ 2 ). Does the contour plot resemble the scatter plot from the previous question?