mercredi 17 avril 2019

Error: number of levels of each grouping factor must be < number of observations: when nesting random effects

I am conducting the following LMEM with a brain volume (continuous numerical) as my DV, Group (categorical Control versus Autistic), Hemisphere (categorical Left versus Right), SEX (categorical Male versus Female) and Age (continuous numerical) as my IVs. I want to include MRI scanner site (categorical, 15 different sites) as my random effect. The following model works well:

Putamen_model <- lmer(Putamen ~ DX_GROUP * Hemisphere * AGE_AT_SCAN * SEX 
+ (1|SITE_ID),
data = L_Putamen_Outlier_DF)

However, i want to take into account the fact that each participant has two putamen values, one for the right hemisphere and one for the left hemisphere in my model. I am not sure if this is the right thing to do, but I believe I need to indicate that hemisphere is nested in my model with the following model:

Putamen_model_Age <- lmer(Putamen ~ DX_GROUP * Hemisphere * AGE_AT_SCAN * SEX + (1|Hemisphere/SUB_ID)
+ (1 |SITE_ID2),
data = L_Putamen_Outlier_DF)

Yet I get the following error because I have as many hemisphere values as participants:

Error: number of levels of each grouping factor must be < number of observations

> table(L_Putamen_Outlier_DF$Hemisphere)

 Left Right 
  644   644 

> summary(table(L_Putamen_Outlier_DF$SUB_ID))
Number of cases in table: 1288 
Number of factors: 1 

> summary(L_Putamen_Outlier_DF$SUB_ID)
  50002   50004   50005   50006   50012   50022   50023   50024   50030   50031   50032   50045   50046   50047   50048   50049   50051   50053   50054 
      2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2 
  50056   50059   50102   50103   50104   50105   50106   50109   50110   50111   50112   50113   50114   50116   50120   50121   50122   50124   50127 
      2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2 
  50128   50129   50130   50131   50134   50137   50142   50144   50145   50147   50149   50150   50152   50153   50157   50158   50160   50161   50162 
      2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2 
  50163   50164   50165   50166   50167   50168   50170   50171   50186   50187   50188   50189   50190   50193   50194   50195   50196   50198   50199 
      2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2 
  50200   50201   50202   50203   50204   50205   50206   50208   50209   50210   50211   50212   50213   50214   50215   50216   50232   50241   50245 
      2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2       2 
  50250   50251   50254   50255 (Other) 
      2       2       2       2    1090 

I clearly see that there seems to be as many subjects as observations in my case and that Linear mixed effect model supposes that there is less subjects than observations so it throws an error if it is not the case. However I want to indicate that for one participant I have 2 volume values, one for each hemisphere.

How can I tell the model that I have 2 values for each participant, one for each hemisphere? Can you suggest any models? Any help is welcome.

I also tried including (1 | SUB_ID) + (1 | SITE_ID2) but my model fails to converge.

Thank you, Camille




Aucun commentaire:

Enregistrer un commentaire