5
$\begingroup$

In this post @Ben Bolker wrote in his answer that for the interaction between station and day we could write station+(1|day/station), but I don't understand how this is possible. In the OP, day is a random effect and station is fixed, but writing (1|day/station) means you are nesting station within day, in which case you are treating both station and day as random effects. My understanding is that nesting can only apply to random effects, according to @Tim's comment here.

Also in @John's answer he mentions in the end that we could create a model like

lmer(y ~ station + (tow*day|station), data = dat) 

but isn't this specifying station as a random effect (ie right side of | and within parentheses)? Shouldn't it rather be lmer(y ~ station + (station|tow*day), data = dat)? Am I missing something?

$\endgroup$
8
  • 2
    $\begingroup$ (1|day/station) means (1|day) + (1|day:station), so it's a random effect of day and a random effect of day:station interaction. An interaction between random factor and a fixed factor is random. There is no random effect of station alone here (because station is random). So Ben's answer is correct. $\endgroup$ Commented Jul 4, 2018 at 8:33
  • 1
    $\begingroup$ Regarding (day|station), I don't see how it makes sense if station is fixed. $\endgroup$ Commented Jul 4, 2018 at 8:34
  • $\begingroup$ Thanks @amoeba. In the first comment you wrote "(because station is random)", but I think you meant "fixed", or am I wrong? $\endgroup$ Commented Jul 12, 2018 at 23:52
  • $\begingroup$ Regarding the (1|day/station), I was confused because I thought the / symbol always meant nested random effects like in the (1|school/class) situation in which school and class are both random effects. But if I understand it correctly, the (1|A/B) syntax could also mean random effect of A plus random effect of A-B interaction. This is somewhat confusing, how does lmer distinguish between nested random effects and random-fixed interaction effect? $\endgroup$ Commented Jul 12, 2018 at 23:54
  • 1
    $\begingroup$ @RobertLong I honestly don't remember these discussions anymore :-) It's a been a while since I last thought about mixed models and repeated measures. But if you feel like updating/amending your answer in the linked thread, I'd be happy to re-read the whole discussion and will be happy to accept the answer if we think the question is resolved. $\endgroup$ Commented Jan 6, 2024 at 13:38

1 Answer 1

8
$\begingroup$

is it correct to nest fixed effects within random factors?

No, it is not correct. However that is not what is happening in the first example:

... + station + (1|day/station) + ... 

Here station is a fixed effect. As for the random effects structure, station is nested within day, but it is crucial to understand what this means:

(1|day/station) 

is simply shorthand for

(1|day) + (1|day:station) 

That is, we have random intercepts for the main effect of day and also random intercepts for the day:station interaction which means that station is free to vary randomly within the levels of day, which is what if means for a nested structure. station is not free to vary across all levels of day. Thus it is perfectly reasonable to have + station + (1|day/station) +.

In the second example:

...+ station + (tow*day|station) + ... 

this does not make sense because here, the main effect of station is specified as both random and fixed.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.