Reputation: 11
What is the point of the "1 +" in (1 + X1|X2) structure of the random effect of an lmer function in lme4 package of R, and how does this differ from (1|X1) + (1|X2)?
Upvotes: 1
Views: 852
Reputation: 226077
As the comment suggests, looking at the GLMM FAQ might be useful.
(1+X1|X2)
is identical to (X1|X2)
(due to R's default of adding an intercept). This fits a model where all of the effects of X1
(i.e. all of the predictors that we would get from a linear model using y ~ X1
) vary across the groups/levels defined by X2
, and all of the correlations among these varying effects are estimated.
X1
is numeric, this fits a random-slopes model that estimates the variation in the intercept across groups, the variation in the slope across groups, and their covariance (correlation).X1
is categorical (a factor), this estimates variation based on the contrasts used for X1
. Suppose X1
has three levels {A, B, C} and the default treatment contrasts are being used. Then a 3x3 covariance matrix is estimated which includes
The formula (1|X1) + (1|X2)
only makes sense if X1
is categorical (only categorical variables, or variables that can be treated as categorical, make sense as grouping variables). This estimates the variation in the intercept (baseline response) among levels of X2
and the variation in the intercept (baseline response) among levels of X1
.
As a final note, it's hard for me to think of a case where the latter formula ((1|X1) + (1|X2)
) would make sense as an alternative to (X1|X2)
...
Upvotes: 3