Storing Markov chains
Let \(m\) be the average change in reaction time after 3 days of sleep deprivation. In a previous exercise, you obtained an approximate sample of 10,000 draws from the posterior model of \(m\). You stored the resulting mcmc.list object as sleep_sim which is loaded in your workspace:
sleep_sim <- coda.samples(model = sleep_jags, variable.names = c("m", "s"), n.iter = 10000)
In fact, the sample of \(m\) values in sleep_sim is a dependent Markov chain, the distribution of which converges to the posterior. You will examine the contents of sleep_sim and, to have finer control over your analysis, store the contents in a data frame.
Cet exercice fait partie du cours
Bayesian Modeling with RJAGS
Instructions
Check out the
head()of thesleep_simlist object.The first
sleep_simlist item contains the \(m\) and \(s\) chains. Store these in a data frame namedsleep_chains. Include a variableiterthat records the corresponding iteration number,1:10000, for each chain element.Check out the first 6 rows of
sleep_chains.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Check out the head of sleep_sim
# Store the chains in a data frame
sleep_chains <- data.frame(___, iter = ___)
# Check out the head of sleep_chains