I am confused by lmer's formula syntax for mixed models.
I found a very useful "cheat sheet" in an answer to a related question.
Unfortunately, there is no example of a fairly common class of model, the intercept/slope as outcomes model, and I do not understand how it might be formulated.
Specifically, I do not know how to formulate a model such as this one:
Level 1
$Y_{ij} = β_{0j} + β_{1j}(X_{ij}) + r_{ij}$
Level 2
$β_{0j} = γ_{00} + γ_{01}W_j + u_{0j}$
$β_{1j} = γ_{10} + γ_{11}W_j + u_{1j}$
where i ranges over individuals, j over groups, and $W_j$ is a group-level predictor of the level 1 slope and intercept. Combined this creates a cross-level interaction:
$Y_{ij} = (γ_{00} + γ_{01}W_j + u_{0j}) + (γ_{10}+γ_{11}W_j + u_{1j})X_{ij} + r_{ij}$
By pattern matching on the answer to this question the correct formulation might be something like:
Y ~ 1 + X + W:X + (1 + X | Group)
but I really don't understand why. Would someone please explain the correct way to model this, and in particular how it might inform me about the semantics of lme4's formula?