+ Reply to Thread
Results 1 to 6 of 6

Thread: Metropolis Hastings

  1. #1
    Points: 993, Level: 16
    Level completed: 93%, Points required for next Level: 7

    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Metropolis Hastings



    So I am given data of y and x. I am told that
    y_i|g_i, x_i \mbox{ follows a poisson}(g_ix_i)
    g_i|a, b \mbox{ follows a gamma}(a,b)
    a \mbox{ follows a gamma}(1,1)
    b \mbox{ follows a gamma}(10,1)

    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.
    Last edited by Dason; 05-04-2011 at 07:17 PM.

  2. #2
    RotParaTon
    Points: 46,105, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardFrequent PosterActivity AwardCommunity Award
    Dason's Avatar
    Location
    Ames, IA
    Posts
    9,063
    Thanks
    211
    Thanked 1,605 Times in 1,375 Posts

    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. #3
    Points: 993, Level: 16
    Level completed: 93%, Points required for next Level: 7

    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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. #4
    RotParaTon
    Points: 46,105, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardFrequent PosterActivity AwardCommunity Award
    Dason's Avatar
    Location
    Ames, IA
    Posts
    9,063
    Thanks
    211
    Thanked 1,605 Times in 1,375 Posts

    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. #5
    Points: 993, Level: 16
    Level completed: 93%, Points required for next Level: 7

    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Metropolis Hastings

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

  6. #6
    Points: 993, Level: 16
    Level completed: 93%, Points required for next Level: 7

    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Metropolis Hastings


    Ok, I am confused.
    I have already calculated p(g_i|a,b,x_1,...,x_n,y_1,...,y_n,g_1,...,g_(i-1),g_(i+1),...,g_n)

    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?

+ Reply to Thread

Posting Permissions

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








Advertise on Talk Stats