1. Learn
  2. /
  3. Courses
  4. /
  5. Bayesian Modeling with RJAGS

Exercise

RJAGS simulation for multivariate regression

Consider the following Bayesian model of volume \(Y\)i by weekday status \(X\)i and temperature \(Z\)i:

  • likelihood: \(Y\)i \(\sim N(m\)i, \(s^2)\) where \(m\)i \(= a + b X\)i \(+ c Z\)i .
  • priors: \(a \sim N(0, 200^2)\), \(b \sim N(0, 200^2)\), \(c \sim N(0, 20^2)\), \(s \sim Unif(0, 200)\)

Your previous exploration of the relationship between volume, weekday, and hightemp in the RailTrail data provided some insight into this relationship. You will combine this with insight from the priors to develop a posterior model of this relationship using RJAGS. The RailTrail data are in your work space.

Instructions 1/3

undefined XP
    1
    2
    3

DEFINE your Bayesian model and store it as rail_model_2. Specifically, utilizing the dnorm() and dunif() rjags functions:

  • For each of the 90 subjects \(i\), define \(m\)i and the model of \(Y\)i given \(m\)i and \(s\) using RJAGS notation. To this end, remember that b[X[i]] is the rjags equivalent of \(bX\)i.

  • Specify the priors for \(a\), \(b\), \(c\), and \(s\).