0
$\begingroup$

I estimated a three-level multilevel model in stan but I have some trouble writing it correctly in terms of vectors and matrices. Now, I have the following:

$\begin{equation} \begin{gathered} y_{ijt} = \boldsymbol{z}_{ijt}'\boldsymbol{\pi}_{ij} + \boldsymbol{a}'\boldsymbol{\theta} + \varepsilon_{ijt} , \\ \boldsymbol{\pi}_{ij} = \boldsymbol{\beta}_{j}'\boldsymbol{x}_{ij} + \boldsymbol{\eta}_{ij}, \\ \boldsymbol{\beta}_{j} = \boldsymbol{\Gamma}'\boldsymbol{w}_j + \boldsymbol{u}_{j}. \end{gathered} \end{equation}$

With dimensions:

$\boldsymbol{z}_{ijt}$: $p \times 1$

$\boldsymbol{\pi}_{ij}$: $p \times 1$

$\boldsymbol{a}$: $g \times 1$

$\boldsymbol{\theta}$: $g \times 1$

$\boldsymbol{\beta}_{j}$: $q \times p$

$\boldsymbol{x}_{ij}$: $q \times 1$

$\boldsymbol{\Gamma}$: $s\times q$

$\boldsymbol{w}_j$: $s \times p$

So, there are $p$ variables in the first level, $q$ in the second and $s$ in the third. However, to get the dimensions right my $\boldsymbol{w}_j$ has to have $p$ columns, but I do not know how to incorporate this in stan, since I would think that I only have a $\boldsymbol{w}_j$ with size $s \times 1$ in the third level (so $s$ variables with only one value each). Now, I could use $p$ equal columns for $\boldsymbol{w}_j$, but I do not know whether this is right. Can someone explain this to me?

Next to that, I can define the joint posterior to be:
$ p(\boldsymbol{\pi}_{ij}, \boldsymbol{\beta}_{j}, \boldsymbol{\Gamma}| \boldsymbol{y}) \propto p(\boldsymbol{y}| \boldsymbol{\pi_{ij}})p(\boldsymbol{\pi_{ij}}|\boldsymbol{\beta}_j)p(\boldsymbol{\beta_{j}}|\boldsymbol{\Gamma})p(\boldsymbol{\Gamma})$. But can someone explain how to incorporate the fixed effect part $ \boldsymbol{a}'\boldsymbol{\theta}$ in this equation?

Thanks in advance for the help!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.