2

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?

Jacob Lee
  • 133
  • 4

1 Answers1

3

It's just a little algebraic manipulation. Take the fixed effects as an example: These are two different ways of writing the same fixed effects model:

$$ Y \sim \mathcal{N}(\mathbf{X}\beta, \sigma^2)$$

and

$$ Y = \mathbf{X}\beta + \epsilon; \quad \epsilon \sim \mathcal{N}(0, \sigma^2).$$

They are equivalent parameterizations that lead to OLS as the MLE for $\beta$.

When random effects have a non-zero mean, it is the same thing to write them as a sum of fixed and random effects with a zero mean.

The formula object you write does not give rise to the random slopes/random intercepts growth model in your earlier expressions. X + X:W is a 2 degree of freedom expression which has no fixed effect for $W$, yet your 2 level model has a random intercept which varies in $W$. Rather use this formula:

~X*W + (1+X|Group)

If you go through the algebra you will find:

  • The coefficient (Intercept) is an estimate of $\gamma_{00}$
  • the coefficient to $X$ is an estimate of $\gamma_{10}$
  • the coefficient to $W$ is an estimate of $\gamma_{01}$
  • The coefficient to $X:W$ is an estimate of $\gamma_{11}$

for the fixed effects. The random effects are subtler. The variance in the group level controls for the between-group confounders $W$ and so is lower than the actual unconditional group level variance. That is the point of adjusting for these variables anyway.

  • The random effect for Intercept is an estimate of the variance of $u_{0j}$
  • The random effect for $X$ is an estimate of the variance of $u_{1j}$
  • The residual variance is an estimate of the variance of $r_{ij}$
AdamO
  • 52,330
  • 5
  • 104
  • 209