Let the observed data be y = (6, 4, 9, 2, 0, 3), a random sample from the Poisson distribution with mean A, where A> 0 is unknown. Suppose that we assume a Gamma(1, 1) prior distribution for A. The posterior density, p(A | y), for λ is Gamma (1+ S, 1 + n), where S = ₁ and n = 6. Suppose that you want to construct a symmetric Metropolis-Hastings on the log-scale to generate a sample from this posterior distribution by using a normal proposal distribution with standard deviation b = 0.2. (a) Write down the steps in this symmetric Metropolis-Hastings (on the log-scale) to simulate realisations from the posterior density p(x|y). (b) Implement the algorithm in R. and plot the observations as a function of the iter- ations. Use M = 5000 for the number of iterations. (c) To assess the accuracy compare the empirical distribution of the sample with the exact posterior density, Gamma(1 + S, 1 + n). (d) Rerun the algorithm in R using a smaller b = 0.01 and a larger b = 20. What are the effects on the behaviour of the algorithm of making b smaller? What are the

Calculus For The Life Sciences
2nd Edition
ISBN:9780321964038
Author:GREENWELL, Raymond N., RITCHEY, Nathan P., Lial, Margaret L.
Publisher:GREENWELL, Raymond N., RITCHEY, Nathan P., Lial, Margaret L.
Chapter13: Probability And Calculus
Section13.CR: Chapter 13 Review
Problem 40CR
icon
Related questions
Question

all parts please

Let the observed data be y = (6, 4, 9, 2, 0, 3), a random sample from the
Poisson distribution with mean A, where A> 0 is unknown. Suppose that we assume a
Gamma(1, 1) prior distribution for A. The posterior density, p(A | y), for A is Gamma(1+
S, 1 + n), where S = ₁₁y₁ and n = 6. Suppose that you want to construct a
symmetric Metropolis-Hastings on the log-scale to generate a sample from this posterior
distribution by using a normal proposal distribution with standard deviation b = 0.2.
(a) Write down the steps in this symmetric Metropolis-Hastings (on the log-scale) to
simulate realisations from the posterior density p(x|y).
(b) Implement the algorithm in R. and plot the observations as a function of the iter-
ations. Use M = 5000 for the number of iterations.
(c) To assess the accuracy compare the empirical distribution of the sample with the
exact posterior density, Gamma(1 + S, 1 + n).
(d) Rerun the algorithm in R using a smaller b = 0.01 and a larger b = 20. What are
the effects on the behaviour of the algorithm of making b smaller? What are the
effects of making it larger?
(e) Add code to count how many times the proposed value for À was accepted. Rerun
the algorithm using values of b = 0.01, b = 0.2 and b = 20, and each time calculate
the proportion of steps that were accepted. Then plot this acceptance probability
against b. Examine how the acceptance probability for this algorithm depends b.
Transcribed Image Text:Let the observed data be y = (6, 4, 9, 2, 0, 3), a random sample from the Poisson distribution with mean A, where A> 0 is unknown. Suppose that we assume a Gamma(1, 1) prior distribution for A. The posterior density, p(A | y), for A is Gamma(1+ S, 1 + n), where S = ₁₁y₁ and n = 6. Suppose that you want to construct a symmetric Metropolis-Hastings on the log-scale to generate a sample from this posterior distribution by using a normal proposal distribution with standard deviation b = 0.2. (a) Write down the steps in this symmetric Metropolis-Hastings (on the log-scale) to simulate realisations from the posterior density p(x|y). (b) Implement the algorithm in R. and plot the observations as a function of the iter- ations. Use M = 5000 for the number of iterations. (c) To assess the accuracy compare the empirical distribution of the sample with the exact posterior density, Gamma(1 + S, 1 + n). (d) Rerun the algorithm in R using a smaller b = 0.01 and a larger b = 20. What are the effects on the behaviour of the algorithm of making b smaller? What are the effects of making it larger? (e) Add code to count how many times the proposed value for À was accepted. Rerun the algorithm using values of b = 0.01, b = 0.2 and b = 20, and each time calculate the proportion of steps that were accepted. Then plot this acceptance probability against b. Examine how the acceptance probability for this algorithm depends b.
Expert Solution
steps

Step by step

Solved in 7 steps with 36 images

Blurred answer
Recommended textbooks for you
Calculus For The Life Sciences
Calculus For The Life Sciences
Calculus
ISBN:
9780321964038
Author:
GREENWELL, Raymond N., RITCHEY, Nathan P., Lial, Margaret L.
Publisher:
Pearson Addison Wesley,
Glencoe Algebra 1, Student Edition, 9780079039897…
Glencoe Algebra 1, Student Edition, 9780079039897…
Algebra
ISBN:
9780079039897
Author:
Carter
Publisher:
McGraw Hill