--- title: "HW 5" author: "Name here" date: "Due Friday October 5, 2018" output: html_document --- Please use D2L to turn in both the PDF output and your R Markdown file. ### Q1. (5 pts) Sketch out the steps for a Gibbs sampler algorithm. ### Q2. (45 pts) Simulating data is a key step in verifying your algorithms are working correctly. This will be more apparent as we start studying sophisticated hierarchical models. #### a. (5 pts) Simulate 100 observations from a standard normal distribution and plot a histogram of your data. #### b. (5 pts) Select and state prior distributions for $\theta$ the mean of the normal distribution and $\sigma^2$ the variance (or alternatively you may parameterize your model using the precision term). #### c. (10 pts) Implement a Gibbs sampler to simulate from the joint posterior distribution $p(\theta,\sigma^2|y_1, \dots, y_{100})$. Create a plot of the joint posterior distribution. #### d. (10 pts) Plot trace plots and histograms of the marginal posterior distributions for $\theta$ and $\sigma^2$. Include the true values on these figures. Comment on the figures. #### e. (10 pts) Use your MCMC samples to create a posterior predictive distribution. Compare the data and your posterior predictive distribution using a QQ plot `qqnorm()`. Comment on the figure.