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.
This exercise is part of the course
Bayesian Modeling with RJAGS
Exercise 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
samples
data frame, construct a density plot of theprior_m
samples and a density plot of theprior_s
samples.
Hands-on interactive exercise
Have a go at this exercise by completing this sample 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 = ___)) +
___()