Multi-Dependent Variable Hierarchical Bayesian Model - Estimation

I want to estimate a hierarchical Bayesian model that has more than one dependent variable, i.e., a hierarchical model for >1 equations, where the equations are tied together via correlation between the error terms. The question is how to program this in Stan.

A two-dependent variable model would be:

Sales_Online(it) = Online sales in time t for retailer i.
Sales_Offline(it) = Offline sales in time t for retailer i.

  1. Sales_Online(it) = a0(i) + a1(i)*X(it) + e1(it)

  2. Sales_Offline(it) = b0(i) + b1(i)*X(it) + e2(it)

  3. a0(i) = c01 + c02*W(i) + e3(i)

  4. a1(i) = d01 + d02*W(i) + e4(i)

  5. b0(i) = g01 + g02*W(i) + e5(i)

  6. b1(i) = h01 + h02*W(i) + e6(i)

Equations 1 and 2 are the equations for my 2 dependent variables. They are functions of X(it). X(it) might be price for retailer i in time t.

The function parameters a and b are in turn functions of retailer characteristics W(i) (the hierarchical structure)

A single-equation hierarchical model would just have equations 1, 3, and 4. I have above two equations (1 and 2). Note their errors e1 and e2 might be correlated for a given retailer i. Similarly e3 and e4, and e5 and e6, might be correlated among retailers. That makes the estimation non-trivial.

Question is whether Stan can handle this and how.

Yup, Stan can definitely do multivariate outcomes like this. Here’s a lecture demonstrating how to go about it.

1 Like


Thanks VERY much! I’ll watch that lecture.

As I’m sure you’d surmise, I’m new to Stan so need the help. This is a great forum and I truly appreciate your assistance.