1. ## Metropolis Hastings

So I am given data of y and x. I am told that

Now I need to implement a Metropolis-Hastings to update a and b and gibbs to update g.
I know how to go about updating g, but am uncertain to update a and b.

So I know that I need a proposed distribution, say a normal (a(t-1),5) and normal(b(t-1),5) where a(t-1) represents the previous iteration.

I am having trouble with my acceptance ratio, since the formula is based off of the posterior f(a|y) and f(b|y) (at least I think) which I am not sure how to calculate.

Any help would be appreciated. Thank you in advance.

2. ## Re: Metropolis Hastings

One nice way to get a decent approximation to a variance that will give you a good acceptance rate (between 25-40%) is to figure out a normal approximation to the posterior distribution. It's not too hard to do in practice but I know of a couple VERY easy ways to accomplish this in R. What are you using to program your algorithm?

3. ## Re: Metropolis Hastings

I am using R.

Also, am I right in assuming that I need to find the posteriors f(a|y) and f(b|y)?
And if so how would I go about doing this, since it does not seem apparent to me.

4. ## Re: Metropolis Hastings

Well what you're doing is a metropolis within Gibbs step so what you really need is the conditional posterior distribution which is easy because it's just proportional to the joint posterior. So really you just need something is proportional to the joint posterior which is itself just proportional to the likelihood times the priors which is easy to get.

5. ## Re: Metropolis Hastings

So, f(a|y) is proportional to f(y|g_i,x_i) times f(a)?

6. ## Re: Metropolis Hastings

Ok, I am confused.

I know that with this I can implement the Gibbs sampler to sample new values of the g_i's.

What I am stuck on is implementing the Metropolis-Hastings to sample new values of a and b.
I know that I need to get a proposed distribution let us G centered at the previous a^(t-1). Then we sample a^t from this and calculate the acceptance ratio. Then we sample u from a uniform(0,1) and if u < R we accept a^t else we set it as the previous value.

So my problem is in calculating R. The formula for R is [p(a*|y)/p(a^(t-1)|y)][G(a^(t-1)|a*)/G(a*|a^(t-1)].

So my problem is in calculating p(a|y).

Or based on the information given to me, since we have g_i|a,b and the priors a,b,
would we just find a|g_i and b|g_i then use this for our acceptance ratio?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts