Regression priors
Let \(Y\)i be the weight (in kg) of subject \(i\). Past studies have shown that weight is linearly related to height \(X\)i (in cm). The average weight \(m\)i among adults of any shared height \(X\)i can be written as \(m\)i \(= a + b X\)i. But height isn't a perfect predictor of weight - individuals vary from the trend. To this end, it's reasonable to assume that \(Y\)i are Normally distributed around \(m\)i with residual standard deviation \(s\): \(Y\)i \(\sim N(m\)i, \(s^2)\).
Note the 3 parameters in the model of weight by height: intercept \(a\), slope \(b\), & standard deviation \(s\). In the first step of your Bayesian analysis, you will simulate the following prior models for these parameters: \(a \sim N(0, 200^2)\), \(b \sim N(1, 0.5^2)\), and \(s \sim Unif(0, 20)\).
Este exercício faz parte do curso
Bayesian Modeling with RJAGS
Instruções do exercício
- Sample 10,000 draws from each of the \(a\), \(b\), and \(s\) priors. Assign the output to
a
,b
, ands
. These are subsequently combined in thesamples
data frame along withset = 1:10000
, an indicator of the draw numbers. - Construct separate density plots of each of the
a
,b
, ands
samples.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Take 10000 samples from the a, b, & s priors
a <- ___
b <- ___
s <- ___
# Store samples in a data frame
samples <- data.frame(set = 1:10000, a, b, s)
# Construct density plots of the prior samples
ggplot(___, aes(x = ___)) +
___()
ggplot(___, aes(x = ___)) +
___()
ggplot(___, aes(x = ___)) +
___()