kind regards,
I have a response variable with the following dimensions:
data {
int N; // number of observations.
int K; // number of locations.
int R; // number of sensors at each location.
matrix[R, K] y[N];
}
I want to model y using a matrix normal distribution but don’t know how to specify it in Stan. The definition of the matrix normal distribution is the following:
p(\mathbf{X}\mid\mathbf{M}, \mathbf{U}, \mathbf{V}) = \frac{\exp\left( -\frac{1}{2} \, \mathrm{tr}\left[ \mathbf{V}^{-1} (\mathbf{X} - \mathbf{M})^{T} \mathbf{U}^{-1} (\mathbf{X} - \mathbf{M}) \right] \right)}{(2\pi)^{np/2} |\mathbf{V}|^{n/2} |\mathbf{U}|^{p/2}}
\mathbf{X} (p \times n)
\mathbf{M} (p \times n)
\mathbf{U} (p \times p)
\mathbf{V} (n \times n)