ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Bayesian Modeling with RJAGS

Ver curso

Instrucciones del ejercicio

  • Use rnorm(n, mean, sd) to sample 10,000 draws from the \(m\) prior. Assign the output to prior_m.
  • Use runif(n, min, max) to sample 10,000 draws from the \(s\) prior. Assign the output to prior_s.
  • After storing these results in the samples data frame, construct a density plot of the prior_m samples and a density plot of the prior_s samples.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# 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 = ___)) + 
    ___()
Editar y ejecutar código