开始使用免费开始使用

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.

本练习是课程的一部分

Bayesian Modeling with RJAGS

查看课程

练习说明

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

交互式实操练习

通过完成这段示例代码来试试这个练习。

# 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
编辑并运行代码