I am trying to include a random slope of time for two random factors in my lmer model. My research design has four experimental groups who attended five tests at five time points. I would like to compare the effects of the different treatment types assigned to the four groups (between-subject independent variable) on subjects' test scores (dependent variable) along the five testing points (within-subject independent variable). Two fixed factors (group and time) which are the independent variables are included in the model. In order to control the random influence of subject and class, I also include these two factors in the random effect structure with random intercepts. Because "time" is a within-subject variable, I tried to include it as a random slope for the two random factors.
However, I got this error message:Error: number of observations (=631) <= number of random effects (=675) for term (0 + Time | subject); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable
My R syntax is
Group, time, subject and class are all defined as factors in the model.Time is not coded as a continuous variable because I would like to know the group differences at each time point and "time" is not expected to have linear positive influence on the dependent variable which is the test score.
My questions are:
(1) Is it reasonable to include time as a random slope in the model as long as it is coded as a categorical variable?
(2) Does the error mean I do not have enough observations to run this model?
I searched this question online and found contradictory comments regarding similar issues. While someone said categorical variable cannot be included as a random slope, someone said dummy coding would help. Can someone here give me some suggestions? Your input will be highly appreciated.