LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Bayesian Modeling with RJAGS

Kurs anzeigen

Anleitung zur Übung

  • 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!

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# SIMULATE the posterior    
sleep_sim_1 <- coda.samples(model = ___, variable.names = c("m", "s"), n.iter = ___)

# Summarize the m and s chains of sleep_sim_1


# RE-SIMULATE the posterior    
sleep_sim_2 <- coda.samples(model = ___, variable.names = c("m", "s"), n.iter = ___)

# Summarize the m and s chains of sleep_sim_2
Code bearbeiten und ausführen