4
$\begingroup$

I am running a mixed model in lmer, testing the effects of Covid restrictions on sleep, comparing 2 cohorts of individuals- one from 2019 and one from 2020, coded 0/1 (between subjects). Each individual was measured repeatedly for ~130 consecutive nights, and each row in the dataset represents a single night. I also have a binary Lockdown IV, where each night is coded 0/1 to indicate if it was before/after restrictions were imposed in 2020 (and the equivalent dates for 2019). Finally, I have a DayOfWeek IV, where each night is coded 0/1 to indicate if it represents a weekday/weekend night. The simplified dataset looks something like:

enter image description here

My hypotheses are: (1) there will be a Cohort by Lockdown interaction effect on sleep; and (2) there will be a Cohort by Lockdown by DayOfWeek interaction effect on sleep.

For hypothesis 1, I ran:

mod1 <- lmer(sleep ~ Cohort*Lockdown + (1|Subject) + (1|Date), data = COVID, REML=FALSE)

Results seem reasonable, but I think I am not accounting for random slopes. I have tried to model the slopes as follows, but the model failed to converge.

mod2 <- lmer(sleep ~ Cohort*Lockdown + (Lockdown|Subject), data = COVID, REML=FALSE)

As for the 2nd hypothesis, if I understand correctly, nights are nested within DayOfWeek, which are crossed with Lockdown (since each level of Lockdown includes both weekdays and weekends). I tried the following code, but am getting a singular fit warning (boundary (singular) fit: see ?isSingular)

mod3 <- lmer(sleep ~ Cohort * Lockdown * DayOfWeek + (1|DayOfWeek/date), data = COVID, REML=FALSE)

Could anyone direct me as to what should be changed in these models? Many thanks in advance for your help!

$\endgroup$
4
$\begingroup$

In your second model :

mod2 <- lmer(sleep ~ Cohort*Lockdown + (Lockdown|Subject), data = COVID, REML=FALSE)

you are not accounting for repeated measures within Date. Perhaps you found from the first model that this was not needed, which seems reasonable if that is the case. You would need to include it sleep is more similar to sleep on the same date than different dates. This could be plausible, perhaps due to weather or other factors which might cause different subjects to have more or less sleep on the same nights.

nights are nested within DayOfWeek

I don't see why nights are nested within DayOfWeek. This would mean that each DayOfWeek had it's own night.

It very rarely, if ever, makes sense to fit fixed effects for a factor, so DayOfWeek should not be in the grouping part of the random effects. So the model:

mod3 <- lmer(sleep ~ Cohort * Lockdown * DayOfWeek + (1|DayOfWeek/date), data = COVID, REML=FALSE)

does not make sense. Moreove it does not account for repeated measures within subjects. It is also not clear that you need date as a grouping variable (see above)

From your description, the 2nd question could be answered with:

lmer(sleep ~ Cohort * Lockdown * DayOfWeek + (1|Subject)
$\endgroup$
  • $\begingroup$ Thank you very much for your help! $\endgroup$ – Mika Aug 25 '20 at 6:56
  • $\begingroup$ In my second model, if I want to account for repeated measures within date, so that different subjects can have different slopes (across dates), should I define (Date|Subject) + (Lockdown|Subject)? Also, model 1 runs fine, but when I run emmeans(mod1) to see pairwise comparisons, I get the following error: "Error in asMethod(object) : Cholmod error 'problem too large' at file ../Core/cholmod_dense.c, line 105". I have ~75,000 rows of data. Is there any other way to obtain Cohort*Lockdown pairwise comparisons? Many thanks again! Mika $\endgroup$ – Mika Aug 25 '20 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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