
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Two problems related to statistical modeling. The first problem deals with bayes factors and obtaining the posterior distribution of a regression model with normal priors. The second problem involves implementing the metropolis algorithm to estimate the posterior distribution of logistic regression coefficients. Students are expected to use r for calculations.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Homework 8 Assigned 05/23/ Due 05/30/
M 0 : yi = β 0 + i M 1 : yi = β 0 + β 1 xi + i,
where in each case 1 ,... , n are i.i.d. normal(0, σ^2 ). Let the prior distribution for β 1 be normal(0, τ 2 ).
(a) Obtain p(y 1 ,... , yn|M 1 , β 0 , σ^2 ) as follows: i. Write out the joint distribution of (y 1 ,... , yn, β 1 ) given β 0 and σ^2. Collect together terms that depend on β 1. ii. Write the expression in (i) as some normal distribution for β 1 multiplied by some stuff that doesn’t depend on β 1. To do this you will have to multiply and divide by something that may depend on y 1 ,... , yn, β 0 , σ^2 , τ 2. iii. Integrate this expression. (b) Calculate and simplify the following expression.
p(y 1 ,... , yn|M 1 , β 0 , σ^2 ) p(y 1 ,... , yn|M 0 , β 0 , σ^2 ) Explain why your result makes sense: For what values of y, x is the ratio large? For what what values of y, x is it small? (c) Suppose that a priori p(M 1 ) = w and p(M 0 ) = 1 − w. Show how you could use the result in (b) to obtain p(M 1 |y, β 0 , σ^2 ).
Pr(typei = 1|x, β) = exp{β 0 + β 1 npregi + β 2 bpi + β 3 bmii + β 4 pedi + β 5 agei} 1 + exp{β 0 + β 1 npregi + β 2 bpi + β 3 bmii + β 4 pedi + β 5 agei}
I have converted the data to a binary vector y and a design matrix X in which the predictor variables have been centered and scaled. These objects are in the Hw8 directory. For this problem, the prior distribution β will be such that each component is independent, with β 0 ∼ normal(0, sd=10) and β 0 ∼ normal(0, sd=1).
(a) write down a line of code or a function in R such that when you plug in a single value of β it calculates log p(β) + log p(y|β). Make sure you get this part right. (b) Implement the Metropolis algorithm using the following proposal mechanism: beta.star<-rnorm(6,beta,c(.5,rep(.05,5))) Compute the autocorrelation function, and posterior 2.5,50 and 97.5% posterior quantiles for each component of β. (*) Use a multivariate normal proposal distribution that has the same standard deviation you used in (b), but with a correlation based on your estimate of the posterior correlation. How does the performance of this proposal distribution compare to that of (b)?
*. Prove that the p(θ|y) is the invariant distribution of the Metropolis-Hastings algorithm. You can mimic the proof from class for the Metropolis algorithm.