Solved Gibbs Sampling and Metropolis-Hastings Algorithm MATH8050: Homework 7

$30.00

Original Work ?
Category: Tags: , , You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

R Working Environment

Please load all the packages used in the following R chunk before the function sessionInfo()
# load packages
sessionInfo()
Total points on assignment: 10 (reproducibility) + 45 (Q1) + 45 (Q2)

Reproducibility component: 10 points.
1. (45pts in total, equally weighted) Suppose that we want to generate a truncated beta distribution
Beta(2.7, 6.3) restricted to the interval (c, d) with c, d ∈ (0, 1). Assume that c = 0.1 and d = 0.9.
(a) Implement a Metropolis-Hastings algorithm based on a Beta(2, 6) proposal, and provide convergence
diagnostics and acceptance ratio

(b) Implement a Metropolis-Hastings algorithm based on a U(c, d) proposal, and provide convergence
diagnostics and acceptance ratio.
(c) Compute P(X > 0.5) using the samples obtained in part (a) and (b).

2. (45pts in total, equally weighted) We call X ∼ Tν is a Student’s t random variable with ν degrees of
freedom, that is, its pdf is given by
f(x|ν) = Γ( ν+1
2
)
Γ( ν
2
)
1

νπ 
1 +
x
2
ν
−(ν+1)/2
.

Assume that ν = 4. Make sure that you need to perform convergence diagnostics.
(a) Implement a Metropolis-Hastings algorithm with normal distribution N (0, 1) as the proposal distribution.

(b) Implement a Metropolis-Hastings algorithm with t distribution T2 as the proposal distribution.
(c) Calculate E(X) and the 95% credible interval for X using the MCMC samplers in part (a) and (b).