Normal-Normal priors
Researchers developed a test to evaluate the impact of sleep deprivation on reaction time. For subject \(i\), let \(Y\)i be the change in reaction time (in ms) after 3 sleep deprived nights. Of course, people react differently to sleep deprivation. It's reasonable to assume that \(Y\)i are Normally distributed around some average \(m\) with standard deviation \(s\): \(Y\)i \(\sim N(m, s^2)\).
In the first step of your Bayesian analysis, you'll simulate the following prior models for parameters \(m\) and \(s\): \(m \sim N(50, 25^2)\) and \(s \sim Unif(0, 200)\). This requires the rnorm(n, mean, sd) and runif(n, min, max) functions.
Cet exercice fait partie du cours
Bayesian Modeling with RJAGS
Instructions
- Use
rnorm(n, mean, sd)to sample 10,000 draws from the \(m\) prior. Assign the output toprior_m. - Use
runif(n, min, max)to sample 10,000 draws from the \(s\) prior. Assign the output toprior_s. - After storing these results in the
samplesdata frame, construct a density plot of theprior_msamples and a density plot of theprior_ssamples.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Take 10000 samples from the m prior
# Take 10000 samples from the s prior
# Store samples in a data frame
samples <- data.frame(prior_m, prior_s)
# Density plots of the prior_m & prior_s samples
ggplot(___, aes(x = ___)) +
___()
ggplot(___, aes(x = ___)) +
___()