Random effects in repeated-measures design using lme

by n_ro   Last Updated June 12, 2019 08:19 AM

I have a repeated-measures design where participants were measured 4 times each on 2 consecutive days. There were 2 conditions, randomly attributed to day 1 and day 2 for each participant.

So, this is how the head of my data 'dat' look:

So, this is how the head of my data 'dat' look:

'subject' is just the IDs, 'DV' is my outcome/dependent variable.

I want to know how 'day', condition ('cond'), and 'measurement' influence 'DV' using R's lme package. Even after a rather excessive search, I'm still not sure how to set the random effects...

So far, I've done something like:

m_base <- lme(DV ~ 1, random = ~1|subject/cond/measurement, data = dat, method = "ML")

or

m_base <- lme(DV ~ 1, random = ~1|subject/day/measurement, data = dat, method = "ML")

and then stepwise added my variables as fixed effects using update() and compared the models using anova().

Still, I'm not sure about how to set the random effects, since 'measurement' is somehow nested within both 'day' and 'cond'. Does anyone know a correct way of implementing my question?



Related Questions




MMRM model from SAS to R

Updated May 15, 2017 14:19 PM