Here is somewhat simplified structure of the data I have, since fixed effects are quite straight forward, however, random effects are giving me a headache (like I said something new :) ):
studentId | courseId | courseName | year | courseGroup | timespent | mark
stud1 | 19 | M101 | 2008 | F | 12.3 | 3.7
stud1 | 21 | E102 | 2008 | C | 2.3 | 4
stud1 | 109 | H300 | 2008 | E | 22.3 | 3
stud2 | 19 | M101 | 2008 | F | 3.3 | 3
stud2 | 21 | E102 | 2008 | C | 12.3 | 3.3
stud3 | 200 | M101 | 2009 | F | 12.3 | 3.7
There are 2000 observations for around 300 students within several courses (3-10 courses per student), over 4 years. Each course belongs to one of the groups (F, C, or E). idcourse is a specific offering of a course - for example, stud1 and 2 took the same course M101 during 2008, while stud3 took the same course in different offering (2009, id-200).
The idea is to predict the final grade (mark) based on the time spent reading course materials (for example). This means that timespent would be a fixed effect. But, I'd like to examine the effect of different courses within the various groups. That is, how the predictive power of time depends on the course group, and maybe course or even course offer.
I was trying to fit a null model with different settings, so far the best model I was able to fit is this
lmer(mark~(1|studentId)+(1|courseId)+(1|courseName:courseGroup), data=data_final)
but I think the model I wanted is this
lmer(mark~(1|studentId)+(courseId|courseName/courseGroup), data=data_final)
which gives the following error:
Error: number of observations (=2017) <= number of random effects (=6355) for term (courseId | courseGroup:courseName); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable
I understand the error, but I'm not sure I quite understand the difference between these two models. I mean, I do understand what those models mean, but which one would be correct in this case? (If we ignore the fact that I wasn't able to fit the second one...)
idcourse
tocourseId
between your data description and your model description? $\endgroup$