I would like to extract the slopes for each individual in a mixed effect model, as outlined in the following paragraph
Mixed effects models were used to characterize individual paths of change in the cognitive summary measures, including terms for age, sex, and years of education as fixed effects (Laird and Ware, 1982; Wilson et al., 2000, 2002c)…. Residual, individual cognitive decline slope terms were extracted from the mixed models, after adjustment for the effects of age, sex, and education. Person-specific, adjusted residual slopes were then used as a quantitative outcome phenotype for the genetic association analyses. These estimates equate to the difference between an individual’s slope and the predicted slope of an individual of the same age, sex, and education level.
De Jager, P. L., Shulman, J. M., Chibnik, L. B., Keenan, B. T., Raj, T., Wilson, R. S., et al. (2012). A genome-wide scan for common variants affecting the rate of age-related cognitive decline. Neurobiology of Aging, 33(5), 1017.e1–1017.e15.
I have looked at using the coef
function to extract the coefficients for each individual, but I am unsure if this is the correct approach to be using.
Can anyone provide some advice on how to do this?
#example R code
library(lme4)
attach(sleepstudy)
fml <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
beta <- coef(fml)$Subject
colnames(beta) <- c("Intercept", "Slope")
beta
summary(beta)
summary(fm1)
Best Answer
The model:
The function
coef
is the right approach for extracting individual differences.These values are a combination of the fixed effects and the variance components (random effects). You can use
summary
andcoef
to obtain the coefficients of the fixed effects.The intercept is 251.4 and the slope (associated with
Days
) is 10.4. These coeffcients are the mean of all subjects. To obtain the random effects, you can useranef
.These values are the variance components of the subjects. Every row corresponds to one subject. Inherently the mean of each column is zero since the values correspond to the differences in relation to the fixed effects.
Note that these values are equal to zero, deviations are due to imprecision of floating point number representation.
The result of
coef(fm1)$Subject
incoporates the fixed effects into the random effects, i.e., the fixed effect coefficients are added to the random effects. The results are individual intercepts and slopes.