Let's say each participant does multiple trials in a study, where x
represents trial difficulty and y
represents the score on that trial. Since the participant is represented by data points spread across the x
and y
scales, I can see the sense in using a linear mixed-effects regression, modelling random slopes and intercepts for participant.
But what if each participant is represented by just one x
value, and several y
values? Let's say the x
is participant age and y
is participant score on a series of trials. It seems nonsensical now to model participant as a random effect - if their data points are just represented by one x
value I don't see how they could be modelled as a random slope or intercept.
Am I right in thinking an LMER with
participant
as random effect is not appropriate in such a case? (putting aside the question of whether to modeltrial
as a random effect)Is the 0 variance for participant in the random effects matrix below diagnostic of this specific problem when modelling a random intercept?
In the random-intercept example below, a regular
lm()
has the same output as thelmer()
. Will that always be the case in such a situation?Is the correlation of -1 in the random effects structure below diagnostic of this problem with modelling a random slope?
# Generate random data df = data.frame(participant = rep(letters[seq( from = 1, to = 8)], each=3), x = rep(c(1,2,3,4), each=6), offset = runif(24, -0.5, 0.5)) %>% mutate(y=x+offset) # Model random intercept Linear mixed model fit by REML ['lmerMod'] Formula: y ~ x + (1 | participant) Data: df REML criterion at convergence: 17.1 Scaled residuals: Min 1Q Median 3Q Max -1.45511 -0.85896 -0.03722 0.72266 1.63586 Random effects: Groups Name Variance Std.Dev. participant (Intercept) 0.00000 0.0000 Residual 0.09449 0.3074 Number of obs: 24, groups: participant, 8 Fixed effects: Estimate Std. Error t value (Intercept) -0.11465 0.15370 -0.746 x 1.02373 0.05612 18.241 Correlation of Fixed Effects: (Intr) x -0.913 # Model random slope Linear mixed model fit by REML ['lmerMod'] Formula: y ~ x + (1 + x | participant) Data: df REML criterion at convergence: 17.1 Scaled residuals: Min 1Q Median 3Q Max -1.45511 -0.85896 -0.03722 0.72266 1.63586 Random effects: Groups Name Variance Std.Dev. Corr participant (Intercept) 6.469e-16 2.543e-08 x 4.309e-17 6.564e-09 -1.00 Residual 9.449e-02 3.074e-01 Number of obs: 24, groups: participant, 8 Fixed effects: Estimate Std. Error t value (Intercept) -0.11465 0.15370 -0.746 x 1.02373 0.05612 18.241 Correlation of Fixed Effects: (Intr) x -0.913