1. Learn
  2. /
  3. Courses
  4. /
  5. Bayesian Modeling with RJAGS

Exercise

Naive standard errors

The mean of the \(m\) Markov chain provides an estimate of the posterior mean of \(m\). The naive standard error provides a measure of the potential error in this estimate. In turn, we can use this measure to determine an appropriate chain length. For example, suppose your goal is to estimate the posterior mean of \(m\) within a standard error of 0.1 ms. If your observed naive standard error exceeds this target, no problem! Simply run a longer chain - the error in using a Markov chain to approximate a posterior tends to decrease as chain length increases.

The defined sleep_model and compiled sleep_jags object are your workspace.

Instructions

100 XP
  • SIMULATE 1,000 draws from the posterior model of \(m\) and \(s\). Store these in sleep_sim_1.

  • Obtain a summary() of the sleep_sim_1 chains.

  • If the naive standard error of the \(m\) chain exceeds the 0.1 target, adjust your simulation: try using either 500 draws or 10,000 draws (instead of 1,000). Store the results in sleep_sim_2.

  • Obtain a summary() of the sleep_sim_2 chains. Confirm that your new simulation meets the criterion. If not, return to the previous step & repeat!