11 Markov Chain Monte Carlo Methods
Q11.1
Repeat Example 11.1 for the target distribution Rayleigh(\(\sigma = 2\)). Compare the performance of the Metropolis-Hastings sampler for Example 1.1 and this problem. In particular, what differences are obvious from the plot corresponding to Figure 11.1?
Q11.2
Repeat Example 11.1 using the proposal distribution \(Y \sim \textrm{Gamma}(X_t, 1)\) (shape parameter \(X_t\) and rate parameter 1).
Q11.3
Use the Metropolis-Hastings sampler to generate random variables from a standard Cauchy distribution. Discard the first 1000 of the chain, and compare the deciles of the generated observations with the deciles of the standard Cauchy distribution (see qcauchy
or qt
with df=1). Recall that a Cauchy(\(\theta\),\(\eta\)) distribution has density function \[
f(x) = \frac{1}{\theta\pi(1 + [(x-\eta)/\theta]^2}, \hspace{2em} -\infty < x < \infty, \hspace{1em} \theta > 0
\]
The standard Cauchy has the Cauchy(\(\theta=1\), \(\eta=0\)) density. (Note that the standard Cauchy density is equal to the Student t density with one degree of freedom.)
Q11.4
Refer to the Bayesian prediction application in Example 11.3, with the Geometric(\(p\)) survival model. Prove that the derived parameter \(\psi(p) = p/(1-p)\) does not depend on attained age of the individual in this model. (This is not true in general for other models.)
Q11.5
Refer to the Metropolis-Hastings sampler implemented in Examples 11.3 - 11.5. Data from a test on a second batch of parts is obtained. Again, \(N=20\) parts were tested for 24 hours. Five failures were observed at times 7.0, 7.3, 7.4, 16.8, 21.8, and the other 15 parts were not observed to fail during the test. Derive the posterior distribution given the new data, and repeat the entire analysis (using only the gamma proposal distribution). Find a god value of the shape parameter \(\alpha\) and check for convergence. Compute the posterior mode and intervals.
Q11.6
Implement a random walk Metropolis-Hastings sampler for generating the standard Laplace distribution (see Exercise 3.3.2). For the increment, simulate from a normal distribution. Compare the chains generated when different variances are used for the proposal distribution. Also, compute the acceptance rates of each chain.
Q11.7
What effect, if any, does the width \(w\) have on the mixing of the chains in Example 11.8? Repeat the simulation keeping the random number seed fixed, trying different proposal distributions based on the random increments from Uniform(\(-w\),\(w\)), varying \(w\).
Q11.8
Rao presented an example on genetic linkage of 197 animals in four categories. The group sizes are (125, 18, 20, 34). Assume that the probabilities of the corresponding multinomial distribution are \[ \left( \frac{1}{2} + \frac{\theta}{4}, \frac{1-\theta}{4}, \frac{1-\theta}{4}, \frac{\theta}{4} \right) \]
Estimate the posterior distribution of \(\theta\) given the observed sample, using one of the methods in this chapter.
Q11.9
Implement a Gibbs sampler to generate a bivariate normal chain (\(X_t\), \(Y_t\)) with zero means, unit standard deviations, and correlation 0.9. Plot the generated sample after discarding a suitable burn-in sample. Fit a simple linear regression model \(Y = \beta_0 + \beta_1X\) to the sample and check the residuals of the model for normality and constant variance.
Q11.10
This example appears in [41]. Consider the bivariate density \[ f(x,y) \propto {n \choose x} y^{x+a-1} (1-y)^{n-x+b-1}, \hspace{2em} x=0,1,\ldots,n, \hspace{1em} 0 \le y \le 1 \]
It can be shown that for fixed \(a\), \(b\), \(n\), the conditional distributions are Binomial(\(n\), \(y\)) and Beta(\(x+a\), \(n-x+b\)). Use the Gibbs sampler to generate a chain with target joint density \(f(x,y)\).
Q11.11
Modify the Gelman-Rubin convergence monitoring given in Example 11.11 so that only the final value of \(\hat{R}\) is computed, and repeat the example, omitting the graphs.
Q11.12
Refer to Example 11.1. Use the Gelman-Rubin method to monitor convergence of the chain, and run the chain until the chain has converged approxiamtely to the target distribution according to \(\hat{R} < 1.2\). (See Exercise 11.11.) Also use the coda
package to check for convergence of the chain ty the Gelman-Rubin method. Hints: See the help topics for the coda
functions gelman.diag
, gelman.plot
, as.mcmc
, and mcmc.list
.
Q11.13
Refer to Example 11.8. Use the Gelman-Rubin method to monitor convergence of the chain, and run the chain until the chain has converged approxiamtely to the target distribution according to \(\hat{R} < 1.2\). Also use the coda
package to check for convergence of the chain ty the Gelman-Rubin method. (See Exercises 11.11 and 11.12.)
Q11.14
Refer to Example 11.9. Use the Gelman-Rubin method to monitor convergence of the chain, and run the chain until the chain has converged approxiamtely to the target distribution according to \(\hat{R} < 1.2\). Also use the coda
package to check for convergence of the chain ty the Gelman-Rubin method. (See Exercises 11.11 and 11.12.)
Q11.15
Refer to the change point application in Section 11.5. Compute a 95% highest posterior density interval (HPDI) for each of the parameters \(\mu\), \(\lambda\), and the change point \(k\). Do this using the HPDi
function in this chapter. Compare the results obtained by converting the chains into an mcmc
object, and use the coda::HPDinterval
method on that object.