# Follow-up: Random & Crossed Random-Effects in Model Syntax in R (lme4)

I'm following up on this question and this answer. The answer mentions that without having a clear study design, understanding whether the random-effects specified in an lmer() model syntax are CROSSED or NESTED is not possible.

Therefore, in this thread, I want to visually provide a couple of study designs as well as their suggested model syntax (from this blogpost) and learn how the model syntax may match up with the study design in terms of CROSSED or NESTED random-effects defined in them. In the following syntax, tx is a binary treatment indicator (0=control, 1=treatment).

DESIGN 1:

Imagine in a 3-wave, longitudinal study, two therapists both get to deliver the treatment and the control arms of the study to a different set of subjects.

The suggested lmer() model syntax is (Q: How does this model syntax match up with DESIGN 1?):

    lmer(y ~ time * tx +                      ## DON'T RUN
(time | therapist:subjects) +
(time * tx || therapist),
data = data)


DESIGN 2:

Imagine in a 3-wave, longitudinal study, two therapists both get to deliver ONLY the treatment arm of the study to different subjects. The control arm subjects will NOT meet any therapist at all.

The suggested lmer() model syntax is (Q: How does this model syntax match up with DESIGN 2?):

        lmer(y ~ time * tx +                         ## DON'T RUN
(1 | therapist:subjects) +
(0 + time | therapist:subjects) +
(0 + time:tx | therapist) +
(0 + tx | therapist),
data = data)


lmer(y ~ time * tx +                      ## DON'T RUN
(time | therapist:subjects) +
(time * tx || therapist),
data = data)


Q: does this model syntax match up with DESIGN 1 ?

Yes.

In this design, subjects are nested within therapists, so ( ... | therapist:subjects) + ( ... | therapist) matches with the design.

It is worth noting that since subjects are coded uniquely, therapist:subjects is the same as subjects

lmer(y ~ time * tx +                         ## DON'T RUN
(1 | therapist:subjects) +
(0 + time | therapist:subjects) +
(0 + time:tx | therapist) +
(0 + tx | therapist),
data = data)


Q: does this model syntax match up with DESIGN 2 ?

No.

In this design, subjects are partially nested in therapists, however since therapist is missing from the control group, inclusion of therapist or therapist:subjects will result in the whole control group being dropped from the model, therefore unlike design 1, therapist:subjects is not same as subjects. An appropriate model would be:

lmer(y ~ time * tx + (time * tx | subjects), data = data)


Alternatively, if a dummy therapist was added to the data, for the control group, then a model with the same random intercepts as that for design 1 would be appropriate. The proposed model for design 2 would not make sense in this case because it does not allow for variation attributable to therapist.

• Dear Rob, thank you very much for your response. Some clarification questions. First, HERE for DESIGN 1 (please scroll down a little), the linked blogpost uses the term therapist crossed effect, is this use of crossed effect different in nature from what you considered? In fact, what is the role of dropping the correlation (time * tx || therapist) in DESIGN 1? . . . Dec 5, 2020 at 4:50
• . . ., HERE for DESIGN 2 (please scroll down a little), do you see any role for the combination of terms to the left of | such that they would justify partial nesting or the totality of DESIGN 2 in any way? Dec 5, 2020 at 4:56
• They seems to be talking about therapist being crossed with treatment. Dropping the correlation might be due to convergence issues or if there is no theoretical justification for the correlation. Dec 5, 2020 at 10:56
• As for design 2, random slopes might be justified on theoretical a priori grounds. That's a matter for domain knowledge. Dec 5, 2020 at 10:59
• Rob, thank you so much. Just wanted to mention that the author of the linked blogpost seems to specialize in this area of designs. Maybe it is worth taking a look at his dissertation HERE to better understand why he has proposed the model syntax for these designs the way he discusses in his blog. --Once again, many thanks (both upvoted & accepted). Dec 5, 2020 at 17:19