STAT 456/856 Assignment 4

Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due

STAT 456/856 Assignment 4

Due Sunday,April 13, 2025

●For each question, your solution should start on a fresh page. You can write your solution using one or a combination of the following three formats:
(1) Use your own paper.
(2) Use a tablet such as an ipad.
(3) Use document creation software such as Word or LaTeX.
●Write your name and student number on the first page of each solution, as well as the solution number.
●For each question, photograph or scan each page of your solution (unless your solution has been typed up and is already in electronic format),and combine the separate pages into a single file. Then upload each file (one for each question), into the appropriate box in Crowdmark.

Instructions for submitting your solutions to Crowdmark are also here.

Total Marks: 35

1.(15 marks) The following observations were obtained of the lifetimes of a certain component, in years:
1.37 0.52 1.52 1.80 1.70 1.31 1.65 0.78 4.07 1.69
2.15 0.95 1.11 1.45 1.69 0.56 1.53 0.84 1.28 2.90
It is assumed that, given 0, the observations are a random sample from a Gamma(0,2) distribution, i.e., the pdf of the lifetime is given by

Suppose that we put a Gamma(2,.1) prior on 0.
(a) (4 marks) Find the MLE of 0. You will need to do this numerically in R.You may wish to use the digamma() function in R.
(b) (6 marks) Write a random walk Metropolis-HastingsMarkovChain Monte Carlo sampler in R which uses a N(0,2) jump distribution to sample from the posterior distribution of 0. Start your chain at the MLE from part(a), use the first 1000 samples as a burn-in period, and take the second 1000 samples as your MCMC sample. Be sure to hand in your code. Plot a histogram of your sample.

(c) (5 marks) Based on the MCMC sample from part(b), compute the posterior mean, an equal-tailed 95% credible interval for 0, and the posterior probability that 0 is less than 1.

2.(8 marks) Return to Problem 5 of Assignment 1.Suppose y =45 is observed.Write a Gibbs Sampler in R to sample from the posterior distribution of (N, 0).Hand in your code. Run your sampler and get a sample of size 1000 using a burn-in period of 1000.Using your posterior sample, plot a histogram estimate of the posterior density of 0, and estimate the posterior mean and variance of 0. Suppose it is known that n = 200 people were sampled.With Jefferys prior on 0, what is the posterior mean and variance of 0 now?

3.(12 marks) The following data
1.85 4.38 5.65 0.23 4.72 3.42 3.60 0.50 2.14 3.77
6.38 4.39 5.82 4.02 0.67 0.54 4.84 2.50 4.72 5.74
is assumed to be a random sample from a N(μ,σ²) distribution, given 0 =(μ,σ²).

Suppose the prior distribution on θ is the product of a N(0,10) prior on p and an Inverse Gamma(3,5) prior on σ².
(a) (7 marks) Write a .stan program and run it in R to obtain samples from the posterior distribution of (μ,σ²). Run 4 chains each of length 4000 with a burn-in period of 2000 for each chain, for a total of 8000 samples. Plot histograms of the posterior distributions of μ and σ2. Find the posterior mean and variance of μ and of σ².
(b) (5 marks) Compute the exact posterior mean and variance of μ and of σ² and compare to the estimates from the simulations from part(a).

发表评论

电子邮件地址不会被公开。 必填项已用*标注