I have the following code:
model <- lmer(Scores ~ Group*Time + (Time | ID), positiveaffect)
I am trying to run a linear mixed effects model with Group as a between-subjects variable and Time as a within-subjects variable , taking into account the interaction between Group and Time.
Each participant has two measurements (one from each time point: time point 1 and 2).
However, I get this error when I run the code:
Error: number of observations (=89) <= number of random effects (=90) for term (Time | ID); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable
I am not sure what I need to do to overcome this?
I would be so grateful for your help!
Minimal reproducible example:
structure(list(Group = c("SH", "SH", "SH", "SH", "SH", "SH",
"SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH",
"SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH",
"SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH",
"SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH",
"SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "SH", "HC",
"HC", "HC", "HC", "HC", "HC", "HC", "HC", "HC", "HC", "HC", "HC",
"HC", "HC", "HC", "HC", "HC", "HC", "HC", "HC", "HC", "HC", "HC",
"HC", "HC", "HC", "HC", "HC", "HC", "HC"), Time = c(1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2), Scores = c(16, 18, 24, 31, 11, 14, 23, 17, 19, 10,
16, 22, 19, 19, 23, 20, 14, 17, 29, 20, 16, 30, 26, 18, 21, 20,
19, 15, 39, 11, 15, 28, 35, 16, 10, 15, 17, 21, 23, 12, 17, 22,
13, 17, 13, 17, 18, 19, 17, 16, 24, 20, 22, 19, 18, 24, 13, 24,
28, 24, 26, 13, 28, 10, 24, 32, 34, 36, 16, 25, 28, 30, 27, 24,
19, 19, 20, 20, 10, 22, 15, 12, 20, 26, 17, 21, 24, 27, 31, 16
), ID = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L,
26L, 27L, 28L, 29L, 30L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,
36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 31L, 32L, 33L,
34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L)), row.names = c(NA,
-90L), class = c("tbl_df", "tbl", "data.frame"))