0
$\begingroup$

I have data like This (repeated measures), Testscore is the dependent variable, Time is the measurement time.

| ID | TIME | TESTSCORE | VAR1 | VAR2 |
|:-- |:----:|:---------:|:----:|:----:|
|20  |1     | 100       | 50   | 0    |
|20  |2     |200        | 60   | 1    |
|30  |3     | 400       | 70   | 0    |
|30  |2     | -100      | 200  | 1    |
|30  |1     | 500       | 100  | 1    |

This is my Code so far:

library(lme4)
library(lmerTest)
library(jtools)
mmodel <- lmer (Testscore ~ var1 + var2 + (1|ID), data = DB)
summ(mmodel)

Two questions:

  1. Is This a correct mixed model code? I don't know if the code takes into account the Time variable which represent the repeated measures for each participant
  2. Is ID a correct Random effect? or should I replace it with Time. Thanks.
$\endgroup$
0

1 Answer 1

0
$\begingroup$

Your code is not wrong per se, depending on what you want. It will account for each individual to have a different intercept, but not account for individual differences in changes over time. To account for this both a random intercept and slope:

lmer(Testscore ~ var1 + var2 + (1 + Time|ID), data = DB)

Which allows individuals to vary in terms of their intercept and the effect of time (slope).

Another option is that you can run a one way repeated measures ANOVA model, assuming that time is the only within-subject factor, to examine whether var1 and var2 have an effect on the Testscore outcome across multiple time points:

aov(Testscore ~ var1 + var2 + Error(id/time), data = DB)
$\endgroup$
2
  • $\begingroup$ Probably worth adding Time as a fixed effects as well (as otherwise there is an assumption that the mean of the slopes is zero) $\endgroup$
    – user20650
    Apr 28, 2022 at 11:50
  • $\begingroup$ Thanks, amazing answer. Do I need to change the class of Time to a factor? Or is to ok to be as an Intenger $\endgroup$
    – Sari Katish
    Apr 28, 2022 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.