I am novice to R (from MATLAB) and have some questions about how to translate my data structure and research Qs to syntax for the lmer function.
I am looking to predict teenagers scores on a mental health questionnaire (0-10) from 3 variables: age (continuous), sex (M/F) and my variable of interest, let's call it X for simplicity (continuous). I demeaned both my continuous predicted variables. Both the teenager and their parent filled out the questionnaire about the teenager, adding a third (within-subject) variable rater. I restructured the dataset into long format such that each subject has 2 rows for each outcome value: parent-report & self-report.
Number of subjects ~85
Number of outcome observations ~170
I am interested in the following effects:
- The fixed effect of X on outcome score (main interest)
- The interaction between X and sex on the outcome ("does X affect the outcome in one sex but not the other?")
- The fixed effect of sex on scores - The fixed effect of age on scores
But I would also like to know whether the effects above are dependant on who is the rater? In this sense, rater is not a nuisance grouping variable whose effect on the outcome I want to account for. I would like to perform a test similar to a MANOVA but given that some subjects are missing some observations, I would prefer to use mixed models. As I understand it, linear mixed models can be used for multiple outcome data but I do not know how to phrase the syntax such that:
- I declare non-independant observations within subjects (rater falls within subject)
- I do not have a random slope for every subject (I have a relatively small sample size)
Using some specific examples, I'd like to know which (if any!) of the following capture my needs...
m1 <- lmer(score ~ X*sex+ age + (1+rater), data = mydata ) m2 <- lmer(score ~ X*sex + age + (1|rater), data = mydata ) # same as m1? m3 <- lmer(score ~ X*sex + age + (1|ID/rater), data = mydata ) # Error: number of levels of each grouping factor must be < number of observations # An issue related to missing data??
Any help (for any part of the above) is appreciated!