Skip to main content
Tweeted twitter.com/StackStats/status/1297685090168901632
Became Hot Network Question
formatting and tags
Source Link
Robert Long
  • 65.8k
  • 11
  • 133
  • 248

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)

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)

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)

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!

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!

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!

Source Link
Mika
  • 43
  • 2

Nested and crossed effects in 3-way interaction in lmer

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!