I would like to model a treatment effect in two different groups, controlled for some co-variates (like age and education), and I assume that a two-way repeated-measure Anova would be the right approach - if yes, I have some questions on how to model this design.
I'm a bit confused on how to do this with R (and the
lme4 package), because I found different approaches for the same design. Let's say, I have following variables:
- group (control vs treatment group)
- time (t0 vs t1, i.e. two measures for each subject)
- age (co-variate)
- education (co-variate)
Am I right, that, according to this posting on Cross Validated, my model would look like this?
lmer(DV ~ group * time + age + education + (1+time|subject), mydata)
Then I found this tutorial. Following these instructions, my model would look like this?
lmer(DV ~ group * time + age + education + (1|subject) + (1|group:subject) + (1|time:subject), data=mydata)
Now I have two questions:
a) which of the two above models is correct? or do both work?
b) my data is in long format, how should my variable
subject look like? the same value for each measured person, i.e. a value appears twice in this variable (for person A in group X at t0 and person A in group X at t1 the same value), or should each row/observation be indicated by a new, unique ID?