# Formula for cross-classified (a.k.a., crossed random factors) mixed effects model with interaction between two "second level" variables

I have a crossed-classified (Hox, 2010) mixed effects model—also known as crossed random factors (West, Welch, & Galecki, 2015), but I am struggling with how to write the formula for an interaction.

I have observations ($$i$$) nested within items ($$j$$) and respondents ($$k$$). items and respondents are not nested; they are both the units of analysis at "level two." I measured a characteristic of the item, called $$Z_j$$, and a characteristic of the person, called $$X_k$$. Thus, both of these are "level two" predictors, but are crossed—not measured at the same unit of analysis.

The primary hypothesis is: Does the relationship between $$X_k$$ and the outcome, $$y_{i(jk)}$$, depend on $$Z_j$$?

The R code seems harmless:

y ~ x * z + (1 + x | j) + (1 + z | k)


But I hit a snag when writing down the formula.

The "level one" equation is simple enough, where we let the intercept vary by items $$j$$ and respondents $$k$$, which are crossed (hence in parentheses together, showing they are both at the same "level"):

$$y_{i(jk)} = \beta_{0(jk)} + \epsilon_{i(jk)}$$

And now the main effects come in when they predict the intercept:

$$\beta_{0(jk)} = \gamma_{00} + \gamma_{01j}X_k + \gamma_{02k}Z_j + u_{0j} + v_{0k}$$

This shows that the relationship between $$X$$ and $$y$$ varies by $$j$$; and it shows that the relationship between $$Z$$ and $$y$$ varies by $$k$$.

Now, my hypothesis is specified as the $$y \sim X$$ relationship depending on $$Z$$. I could write this as:

$$\gamma_{01j} = \gamma_{010} + \gamma_{011}Z_j + u_{01j}$$

When we substitute everything in, we get two main effects, an interaction, and random effects around intercepts at both $$j$$ and $$k$$ as well as random slopes for the main effects.

However, if I add this equation:

$$\gamma_{02k} = \gamma_{020} + \gamma_{021}X_k + v_{01k}$$

Then we get two identical interaction effects, both $$\gamma_{011}$$ and $$\gamma_{021}$$. But since interactions are multiplicative terms, then the way that I formulate my hypothesis shouldn't matter. This is where my confusion arises. Can I include both? It appears not, since they model the same thing. If not, are the two equivalent? Thus, my questions are:

• Am I specifying this model correctly? (That is, before adding $$\gamma_{02k}$$)

• If so, then does that mean: $$\gamma_{01j} = \gamma_{010} + \gamma_{011}Z_j + u_{01j}$$ and $$\gamma_{02k} = \gamma_{020} + \gamma_{021}X_k + v_{01k}$$ are equivalent?

References:

Hox, J. (2010). Multilevel Analysis, 2nd Edition.

West, B., Welch, K., & Galecki, A. (2015). Linear Mixed Models, 2nd Edition.

• Your claim is: $$(Y\mid \mathcal B =\mathbf b, \mathcal G = \mathbf g) \sim \mathcal{N}(\mathbf{C\beta} + \mathbf{Vb} + \mathbf{Tg}, \sigma) \\ \text{where } \mathbf C = [1, X, Z, X\times Z],\ \mathbf V = [1, X], \\ \quad\mathbf T = [1, Z],\ \mathcal B \sim \mathcal N_2(\mathbf{0, \Sigma_0}),\ \mathcal G \sim \mathcal N_2(\mathbf{0, \Sigma_1})$$ Jan 29, 2019 at 15:19
• @HeteroskedasticJim could you relate this to the vector notation I use above? Jan 29, 2019 at 16:32
• I don't think it'd be any different from the answer you already have below. That's why I left it as a comment. Jan 30, 2019 at 0:15

$$\left \{ \begin{array}{l} y_{ijk} = \beta_0 + \beta_1 X_{ijk} + \beta_2 Z_{ijk} + \beta_3 \{X_{ijk} \times Z_{ijk} \}+ \\ \quad\quad\quad\quad b_{0k} + b_{1k} X_{ijk} + u_{0j} + u_{1j} Z_{ijk} + \varepsilon_{ijk},\\\\ b_k = (b_{0k}, b_{1k}) \sim \mathcal N(0, D), \\ u_j = (u_{0j}, u_{1j}) \sim \mathcal N(0, V), \\ \varepsilon_{ijk} \sim \mathcal N(0, \sigma^2), \end{array} \right.$$
where $$D$$ and $$V$$ denote the variance-covariance matrices for the two sets of random effects, $$b_k$$ and $$u_j$$, respectively.
• Shouldn't the lowercase $b_1$ and $u_1$ terms swap subscripts? How can the relationship between $X_k$ and $y$ vary by $k$? it seems like the relationship would vary by $j$. Jan 29, 2019 at 14:41