Skip to main content
added 11 characters in body; edited title
Source Link

Can repeated measures variable with only 2 levels be nested within participants in lmer function?

Here are the libraries

library(tidyverse)
library(lmer4)

I'm using the data that comes with it: sleepstudy.

The example in the vignette is...

fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)

This works fine! Hooray! I'm excited because my data has the same form. Essentially, I have within-subjects design where participants see two versions of something. Participants rate each one. This leaves me with two ratings for each participant, one for each version. Hence, I apply this model to my work:

mymodel <- lmer(Rating ~ Version + (Version | Subject), mydata)

This results in an error:

Error: number of observations (=2600) <= number of random effects (=2600) for term (Accuracy | id); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable

I think that it must be my data, but decide to try to my the sleepsubject data similar to mine by reducing the number of days from 8 levels to 2, like mine:

sleepstudy2 <- sleepstudy %>% filter(Days < 2)

I then rerun the analysis:

fm2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy2)

Same error:

Error: number of observations (=36) <= number of random effects (=36) for term (Days | Subject); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable

Someone referencing a different problem here said,

15 unique IDs times (intercept + slope) gives 30 random effects. You don't have sufficient observations to support the model.

This would seem to be the logic behind my issue, but I'm confused why this problem doesn't become worse with the more levels in the nested variable (e.g., day).

So, back to the original question: Can a repeated measures variable with only 2 levels be nested within participants in lmer function?

Can repeated measures with only 2 levels be nested within participants in lmer function?

Here are the libraries

library(tidyverse)
library(lmer4)

I'm using the data that comes with it: sleepstudy.

The example in the vignette is...

fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)

This works fine! Hooray! I'm excited because my data has the same form. Essentially, I have within-subjects design where participants see two versions of something. Participants rate each one. This leaves me with two ratings for each participant, one for each version. Hence, I apply this model to my work:

mymodel <- lmer(Rating ~ Version + (Version | Subject), mydata)

This results in an error:

Error: number of observations (=2600) <= number of random effects (=2600) for term (Accuracy | id); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable

I think that it must be my data, but decide to try to my the sleepsubject data similar to mine by reducing the number of days from 8 levels to 2, like mine:

sleepstudy2 <- sleepstudy %>% filter(Days < 2)

I then rerun the analysis:

fm2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy2)

Same error:

Error: number of observations (=36) <= number of random effects (=36) for term (Days | Subject); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable

Someone referencing a different problem here said,

15 unique IDs times (intercept + slope) gives 30 random effects. You don't have sufficient observations to support the model.

This would seem to be the logic behind my issue, but I'm confused why this problem doesn't become worse with the more levels in the nested variable (e.g., day).

So, back to the original question: Can repeated measures with only 2 levels be nested within participants in lmer function?

Can repeated measures variable with only 2 levels be nested within participants in lmer function?

Here are the libraries

library(tidyverse)
library(lmer4)

I'm using the data that comes with it: sleepstudy.

The example in the vignette is...

fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)

This works fine! Hooray! I'm excited because my data has the same form. Essentially, I have within-subjects design where participants see two versions of something. Participants rate each one. This leaves me with two ratings for each participant, one for each version. Hence, I apply this model to my work:

mymodel <- lmer(Rating ~ Version + (Version | Subject), mydata)

This results in an error:

Error: number of observations (=2600) <= number of random effects (=2600) for term (Accuracy | id); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable

I think that it must be my data, but decide to try to my the sleepsubject data similar to mine by reducing the number of days from 8 levels to 2, like mine:

sleepstudy2 <- sleepstudy %>% filter(Days < 2)

I then rerun the analysis:

fm2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy2)

Same error:

Error: number of observations (=36) <= number of random effects (=36) for term (Days | Subject); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable

Someone referencing a different problem here said,

15 unique IDs times (intercept + slope) gives 30 random effects. You don't have sufficient observations to support the model.

This would seem to be the logic behind my issue, but I'm confused why this problem doesn't become worse with the more levels in the nested variable (e.g., day).

So, back to the original question: Can a repeated measures variable with only 2 levels be nested within participants in lmer function?

Source Link

Can repeated measures with only 2 levels be nested within participants in lmer function?

Here are the libraries

library(tidyverse)
library(lmer4)

I'm using the data that comes with it: sleepstudy.

The example in the vignette is...

fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)

This works fine! Hooray! I'm excited because my data has the same form. Essentially, I have within-subjects design where participants see two versions of something. Participants rate each one. This leaves me with two ratings for each participant, one for each version. Hence, I apply this model to my work:

mymodel <- lmer(Rating ~ Version + (Version | Subject), mydata)

This results in an error:

Error: number of observations (=2600) <= number of random effects (=2600) for term (Accuracy | id); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable

I think that it must be my data, but decide to try to my the sleepsubject data similar to mine by reducing the number of days from 8 levels to 2, like mine:

sleepstudy2 <- sleepstudy %>% filter(Days < 2)

I then rerun the analysis:

fm2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy2)

Same error:

Error: number of observations (=36) <= number of random effects (=36) for term (Days | Subject); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable

Someone referencing a different problem here said,

15 unique IDs times (intercept + slope) gives 30 random effects. You don't have sufficient observations to support the model.

This would seem to be the logic behind my issue, but I'm confused why this problem doesn't become worse with the more levels in the nested variable (e.g., day).

So, back to the original question: Can repeated measures with only 2 levels be nested within participants in lmer function?