12.4 Exercises

Exercise 12.1 Using the dataset wilson as in this section, do 10 additional iterations of the Metropolis-Hastings Algorithm by continuing the table. See if you can get the value of \(p_{1}\) to 2 decimal places of accuracy.

 

Exercise 12.2 An alternative model for the dog’s mass is the following differential equation:

\[\begin{equation} \frac{dW}{dt} = -k (W-p_{1}) \end{equation}\]

  1. Apply separation of variables and \(W(0)=5\) and the value of \(p_{1}\) from the previous problem to write down the solution to this equation. Your final answer will depend on \(k\).
  2. With the function compute_likelihood and the Metropolis-Hastings algorithm to estimate the value of \(k\) to three decimal places accuracy. The true value of \(k\) is between 0 and 1.

 

Exercise 12.3 Consider the linear model \(y=6.94+bx\) for the following dataset:

x y
-0.365 6.57
-0.14 6.78
-0.53 6.39
-0.035 6.96
0.272 7.20
With the function compute_likelihood apply 10 steps the Metropolis-Hastings algorithm to determine \(b\).

 

Exercise 12.4 For the wilson dataset, repeat three steps of the parameter estimation to determine \(p_{1}\) as in this section, but this time use the log-likelihood (so you will compare the difference of log likelihoods). Which method do you think is easier?