I know similar error messages were discussed before, but my question is different than those.
I have a model in the following form: $$Y_{ij} = \alpha_jX_i+ \beta_j + \epsilon_{ij} $$
Here $\beta_j$ is a categorical variable (Group), $\alpha_j$ is a random slope for each group, $X_i$ is a categorical variable to identify each subject, and $Y_{ij}$ is subject $i$'s contribution to group $j$.
When I write this model in lmer, I use the following model function:
contrib ~ Subj + Grp + (Subj+0|Grp)
I don't have observations for all Subj-Grp
combinations. Some subjects only participate in some groups. When running this model, if my Subj
is a continuous variable, then I don't get any error message.
But if my Subj
is a categorical variable to identify each subject, I get the following error message:
Error: number of observations <= number of random effects for term
(0 + Subj | Grp); the random-effects parameters and the residual
variance (or scale parameter) are probably unidentifiable
Is there a way to use a lmer
model for such cases with imbalanced data?
Any conceptual explanation about the differences of a model with a random slope for a categorical variable vs. continuous variable would be really helpful.
Edit: as requested, this is the scenario I am trying to model. Subjects in the study are members of multiple groups. But not every subject is part of every group. So I think this is not a fully nested design (?). I measure the quality of the contribution of each subject to each group they contribute to ($Y_{ij}$ is such a measure). This measurement could be due to the properties of the subject and the group. That is why I am including categorical variables for the subject and the group. However the subject could have different quality of contribution in different groups. Hence I include a random slope $\alpha_j$. When I got the error message for subject as a categorical variable, I tried to replace it with a continuous value for the subject (average quality measurement across all groups the subject participate in). What I am interested in finding from the model is $\alpha_j$ (i.e., how much a subject vary in different groups).