Home > Mobile >  mixed model specification
mixed model specification

Time:04-29

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.

CodePudding user response:

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)
  • Related