Practice the following exercises to reinforce the concepts learned in this chapter:
- Write a function that will take a vector holding MCMC samples for a parameter and plot a density curve depicting the posterior distribution and the 95% credible interval. Be careful of different scales on the y-axis.
- Fitting a normal curve to an empirical distribution is conceptually easy, but not very robust. For distribution fitting that is more robust to outliers, it's common to use a t-distribution instead of the normal distribution, since the t has heavier tails. View the distribution of the
shape
attribute of the built-inrock
dataset. Does this look normally distributed? Find the parameters of a normal curve that is a fit to the data. In JAGS,dt
, the t-distribution density function, takes three parameters: the mean, the precision, and the degrees of freedom that controls the heaviness of the tails. Find the parameters after fitting a t-distribution to the data. Are the means similar? Which...