Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please explain your code so I can learn. Thank you! Problem 4: Consider simulation of the bivariate normal distribution with mean / = (1, 2)

Please explain your code so I can learn. Thank you!

image text in transcribedimage text in transcribed
Problem 4: Consider simulation of the bivariate normal distribution with mean / = (1, 2) and covariance matrix = = 10.9 1). by the Metropolis-Hastings algorithm, using a random walk chain. Specifically, let each new value x* in the chain be generates by x* = x() + e where E ~ N2(0, D) with D being a diagonal matrix with diagonal elements o, and 62. Note that o, and 62 control the spread of values generated along the first and second coordinate axes, respectively. a) [5 points] Code the Metropolis-Hastings algorithm in R, with o, and oz being part of the input parameters to your function. Let o, = 0.001 and 62 = 0.001, and generate a chain, starting at x(0) = (0,0), of size 10,000. Give a summary of your chain using the coda package. b) [2 points] Compute the acceptance rate, and comment on the acceptance rate. c) [2 points] Burn 1000 points, and draw the trace plot and the density plot for the chain for each of the variables. You may use the coda package. Comment on mixing and the density plots. d) [3 points] Obtain a sample of 9000 from the multivariate normal with # = (1, 2) and covariance matrix E = 10.9 1 0.9) 1 )using the function that I provided In class or a package In R. Draw the points that you obtain on a scatterplot, and overlay this plot by the last 9000 pairs that you generated using the M-H algorithm in part {b}. Use different colors and set the alpha value for your colors to say 0.5 to see both sets of points on the plot. You will see that the M-H generated values do not match the target? Explain why this is the case. [3 points] Choose appropriate 6, and 63 so that the M-H algotlthm would generate values that meet the target requirement. Draw similar plots as in part [d] for this case. [2 points] How do you expect the acceptance rate would change if you choose 61 and 63 to be very large? Briey explain why

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Algebra And Trigonometry (Subscription)

Authors: Michael Sullivan

9th Edition

0321830741, 9780321830746

More Books

Students also viewed these Mathematics questions