Exercise

# RJAGS simulation with categorical variables

Consider the Normal regression model of volume \(Y\)_{i} by weekday status \(X\)_{i}:

**likelihood:**\(Y\)_{i}\(\sim N(m\)_{i}, \(s^2)\) where \(m\)_{i}\(= a + b X\)_{i}**priors:**\(a \sim N(400, 100^2)\), \(b \sim N(0, 200^2)\), \(s \sim Unif(0, 200)\)

You explored the relationship between \(Y\)_{i} and \(X\)_{i} for the 90 days recorded in `RailTrail`

(in your workspace). In light of these data and the priors above, you will update your *posterior* model of this relationship. This differs from previous analyses in that \(X\)_{i} is *categorical*. In `rjags`

syntax, its coefficient \(b\) is defined by two elements, `b[1]`

and `b[2]`

, which correspond to the weekend and weekday levels, respectively. For reference, `b[1]`

is set to 0. In contrast, `b[2]`

is modeled by the prior for \(b\).

Instructions 1/3

**undefined XP**

**DEFINE** your Bayesian model.

- Define the likelihood model of
`Y[i]`

given`m[i]`

and`s`

where`m[i] <- a + b[X[i]]`

. Note the new notation`b[X[i]]`

here! - Specify the priors for
`a`

,`b`

(via`b[1]`

and`b[2]`

), and`s`

. - Store the
*model string*as`rail_model_1`

.