Two-Level Model in Matrix Notation

#1
A two-level model, with one explanatory variable at the individual level (X) and one explanatory variable at the group level (Z):

\(Y_{ij}=\gamma_{00}+\gamma_{10}X_{ij}+\gamma_{01}Z_{j}+\gamma_{11}X_{ij}Z_{j}+u_{0j}+u_{1j}X_{ij}+e_{ij}\ldots (1)\)

correlation between \(u_{0j}\) and \(u_{1j}\) is 0 .

The matrix form of a mixed model collects the fixed effects in a vector \(\beta\), and the random effects in a vector \(u\), and finally the random error term, which is also a random effect factor in the vector \(e\). A formal definition is
\(Y=X\beta+Zu+e\ldots (2)\)

with \(X\) the known design matrix for fixed effects and \(Z\) the known design matrix for random effects .

Now I want to write down equation (1) in matrix form. But I can't visualize what will be the dimension and elements in each vector/matrix in it.

Say, in equation (1), I have 3 groups (J=3) and 2 individuals (i=2) in each group so that the total sample size, N=6 .

Then equation (2) will be,

\(\boldsymbol Y=
\begin{bmatrix}
y_{11}\\
y_{21}\\
y_{12}\\
y_{22}\\
y_{13}\\
y_{23}\\
\end{bmatrix},\quad\quad \boldsymbol e=
\begin{bmatrix}
e_{11}\\
e_{21}\\
e_{12}\\
e_{22}\\
e_{13}\\
e_{23}\\
\end{bmatrix}
\)
and is \(\beta=
\begin{bmatrix}
\gamma_{00} \\
\gamma_{10} \\
\gamma_{01}\\
\gamma_{11}\\
\end{bmatrix} ?
\)

How will be \(X\) , \(Z\) and \(u\) in equation (2) look like ?

Any help is appreciated. Many thanks.
 
Last edited: