[R-sig-ME] Help with nested and crossed effects in models with 2- and 3-way interactions

Thierry Onkelinx th|erry@onke||nx @end|ng |rom |nbo@be
Wed Aug 26 16:57:36 CEST 2020


Dear Mollie,

I agree that (1| DayOfWeek:date) doesn't make sense and it is better to use
(1|Date). IMHO it might be sensible to include DayOfWeek in the model.
(1|DayOfWeek) + (1|Date) or DayOfWeek + (1|Date). So either as random
effect or as fixed effect. Having a factor both as fixed and random
intercept is nonsense. Given there are only 7 days in week, I'd use
DayOfWeek rather as a fixed effect.

Best regards,

ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkelinx using inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

///////////////////////////////////////////////////////////////////////////////////////////
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
///////////////////////////////////////////////////////////////////////////////////////////

<https://www.inbo.be>


Op wo 26 aug. 2020 om 16:16 schreef Mollie Brooks <mollieebrooks using gmail.com>:

> I’m guessing that the problem with mod3 could be another instance of
> confusion with nested effects.
>
> As originally written, the random effects in mod3 are
> (1|DayOfWeek/date) = (1|DayOfWeek) + (1| DayOfWeek:date)
> The second term doesn’t make sense to me when each date can only be
> accompanied by either 0 or 1 for DayOfWeek.
>
> Maybe you want (1|Subject) + (1|Date) in mod3. That model could address
> both hypotheses.
>
> cheers,
> Mollie
>
> > On 23Aug 2020, at 12:50, Michal Kahn <michalkahn10 using gmail.com> wrote:
> >
> > Hello there! 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:
> >
> > [image: enter image description here] <
> https://i.stack.imgur.com/Ouuhw.png>
> >
> > 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!
> > Mika
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-mixed-models using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list