3

I am getting this error.

Error: number of observations (=30) <= number of random effects (=30) for term (1 + year | ID0); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable

I can't see anything wrong. The number of random effects should be 15, not 30. My grouping parameter is ID0, which is nominal, and there are twice as many observations as there are unique ID0's.

Here is some data that I'm using. I've subsetted just 30 rows of it for an example, but the original data has 1,088 obs. I'm trying to estimate random slopes and intercepts.

w1 <- structure(list(ID0 = c("007a275b3b24f4866a0d026503af0f3470f57bfc", 
"007a275b3b24f4866a0d026503af0f3470f57bfc", "0225c47f9da2575d71468f753699a02b972de8ba", 
"0225c47f9da2575d71468f753699a02b972de8ba", "02dc8096dff62e94c39ec3b0df26cd7dd2ed07aa", 
"02dc8096dff62e94c39ec3b0df26cd7dd2ed07aa", "03099c4feb5d232d9c60e2bdd04434cde1741073", 
"03099c4feb5d232d9c60e2bdd04434cde1741073", "03d255805fe183e1c3b1218fe08d7bba8ffc4d87", 
"03d255805fe183e1c3b1218fe08d7bba8ffc4d87", "042746d2cd8a74b6e2bfa6a5645ae90c920cf3e1", 
"042746d2cd8a74b6e2bfa6a5645ae90c920cf3e1", "046538c636e5ed4097ede61b9f6693b376c61119", 
"046538c636e5ed4097ede61b9f6693b376c61119", "0489a242d084104452045fece4038cd45fba6d7a", 
"0489a242d084104452045fece4038cd45fba6d7a", "06500c806172e86f835e5c21a052269dd222e30c", 
"06500c806172e86f835e5c21a052269dd222e30c", "06917c5835230a589bbd5cbb40909cc45afd5c40", 
"06917c5835230a589bbd5cbb40909cc45afd5c40", "06a9c55568e3f2d2d4bcef4534e5672ccc1323db", 
"06a9c55568e3f2d2d4bcef4534e5672ccc1323db", "06ccbadee52b11e853eaab602f71c073a950cc85", 
"06ccbadee52b11e853eaab602f71c073a950cc85", "06faa13b62f5f68089d595548638ca1b81d21b49", 
"06faa13b62f5f68089d595548638ca1b81d21b49", "081d7c912e71b04e894dc21761db9ed531a99d11", 
"081d7c912e71b04e894dc21761db9ed531a99d11", "08f23961db566bb51f8fa0ae37159a8d97320157", 
"08f23961db566bb51f8fa0ae37159a8d97320157"), year = c(0, 1, 0, 
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
0, 1, 0, 1, 0, 1), SatisAvg = c(6, 5, 4, 4, 6.3333333333, 6, 
5.3333333333, 5.6666666667, 6.3333333333, 6.3333333333, 6.3333333333, 
7, 6, 6.3333333333, 6.6666666667, 3.6666666667, 6, 6, 6, 6, 6, 
4.3333333333, 5.6666666667, 2.6666666667, 5.3333333333, 5, 6, 
4.3333333333, 6.6666666667, 7)), .Names = c("ID0", "year", "SatisAvg"
), row.names = c(NA, -30L), class = "data.frame")
Jesse
  • 95

1 Answers1

16

(1 + year | ID0) specify a random intercept and a random slope, both grouped by ID0, and additionally their correlation. See the cheat sheet for an explanation of the syntax.

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

Roland
  • 6,611
  • how many observations would you need to support this model? Trying to wrap my head around the data needed to estimate X number of random effects. – Brigadeiro May 23 '23 at 03:43
  • @Brigadeiro I suspect your question reflects a lack of understanding of mixed-effects models. In your experimental design you need to decide two numbers: the number of subjects and the number of measurements per subject. 15 subjects is sufficient in many cases. For OPs model you'd want at least 3 to 5 observations of each subject. Ultimately, a power analysis is necessary. – Roland May 23 '23 at 05:21
  • I am always looking to improve on what I know. I understand power, but this seems like it is less of a power issue and more of a model identification problem to me. My question is essentially how to determine how many random effects is too many? What goes into this? Thanks. – Brigadeiro May 24 '23 at 15:59
  • @Brigadeiro You are expressing this in a wrong way. You have never too many random effects. The random effects result from the experimental design. You can only have data that is insufficient to estimate the model and sometimes random effects can be negligible. And even if you have insufficient data to estimate the model, you can sometimes fix that by switching to a Bayesian model with informative priors. If data is sufficient to support a mixed-effects model does not only depend on the number of fixed and random effects but also on effect sizes (including correlations between effects). – Roland May 25 '23 at 04:35