Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

mixed model specification

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  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.

>Solution :

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading