[R-sig-ME] lmer function in R for linear mixed models : syntax - check

Kim Pearce k|m@pe@rce @end|ng |rom newc@@t|e@@c@uk
Mon Jul 1 16:59:02 CEST 2024


Dear Dr Bolker,

Many thanks for verifying last week that my syntax below was appropriate when we are considering a hypothetical situation where time (level 1) is nested within patient (level 2) and our hypothetical linear mixed model included random intercepts, fixed and random slopes for one continuous predictor (time), fixed and random slopes for another continuous predictor (dose) and  q-1 fixed slopes for the q category baseline severity group:

Modely <- lmer(Y ~ time + meddose + basesevgroupf + (time + meddose | subject), data=datafile)

Or equivalently:

Modely <- lmer(Y ~ time + meddose + basesevgroupf + (1+ time + meddose | subject), data=datafile)

You mentioned, "You would end up with a 3x3 covariance matrix (variation in intercept, slope with respect to time, and effect of dose across subjects, and 3 covariances)".

Am I correct in thinking that you mean that the syntax would allow us to look at : 

1. the estimate of the variance of the random intercepts (at position 1,1 in the covariance matrix),

2. the estimate of the variance of the random slopes for time (at position 2,2 in the covariance matrix),

3. the estimate of the variance of the random slopes for dose (at position 3,3 in the covariance matrix),

4. the estimate of the covariance (correlation) between the random intercepts and random slopes for time (at position 2,1 [and 1,2 due to symmetry] in the covariance matrix),

5. the estimate of the covariance (correlation) between the random intercepts and random slopes for dose (at position 3,1 [and 1,3 due to symmetry] in the covariance matrix), and

6. the estimate of the covariance (correlation) between the random slopes for time and random slopes for dose (at position 3,2 [and 2,3 due to symmetry] in the covariance matrix).

Many thanks again, in advance, for verifying that my thoughts are correct.
Best wishes,
Kim

Dr Kim Pearce PhD, CStat, Fellow HEA
Newcastle University



More information about the R-sig-mixed-models mailing list