# specifying random effects in an intensive longitudinal design

I conducted a study where participants made 15 decisions (which could be correct or incorrect) per trial (or block). There were 10 identical trials (so the same 15 decisions were made 10 times). All participants made the same decisions across the same number of trials. Further, each decision contains a unique cue. The cues can be grouped into one of three categories. So, my data looks like this:

ID trial decision cue correct
1 1 1 A 1
1 1 2 B 0
1 1 3 C 1
1 1 4 B 1
1 2 1 A 0
1 2 2 B 0
1 2 3 C 1
1 2 4 B 1
1 3 1 A 1
1 3 2 B 0
1 3 3 C 1
1 3 4 B 0
1 4 1 A 0
1 4 2 B 0
1 4 3 C 1
1 4 4 B 1
2 1 1 A 0
2 1 2 B 0
2 1 3 C 1
2 1 4 B 0

... but with 40 participants (ID), 10 trials, and 15 decisions. I'm specifically interested in two things: (1) How do participants learn across the trials and (2) is there an interaction between cue and trial (in other words, do participants learn across trials differently based on the cue type).

Here's what I believe (though I would appreciate confirmation or corrections).

1. This is an example of an intensive longitudinal design (as described in this paper, which is essentially collecting repeated measures data at multiple time points.
2. In a hierarchical modeling framework, there are three nested levels. Specifically, decision is nested within trial which is nested within participant (ID).

I have three model specifications that I cannot choose from. I'd appreciate any help you can offer in deciphering how to best specify this model.

1)

lmer(correct ~ 1 + trial * cue + (1 | ID:trial) + (1 + trial | ID), data=df, family="binomial")

2)

lmer(correct ~ 1 + trial * cue + (1 | trial) + (1 | ID), data=df, family="binomial")

3)

lmer(correct ~ 1 + trial * cue + (1 + trial | ID), data=df, family="binomial")

My question is: What are the consequences or meaning of each specification. In other words, I believe that the first model best captures the study design, but I can't explain why. I think I understand the resulting formulas. Thus, this is not a coding question and I am not limited to using lmer or R.

In the first model:

correct ~ 1 + trial * cue + (1 | ID:trial) + (1 + trial | ID)


(1 | ID:trial) treats trial as a random factor that is nested within levels of ID. From the description in the question, this is not the case. Since all participants were in each trial, these would be crossed random effects, not nested. To understand the difference, see here:
Crossed vs nested random effects: how do they differ and how are they specified correctly in lme4?

However, since you are specifically interested in the fixed effect of trial (and it's interaction with cue) it does not make sense to also treat trial as a random factor.

The second model:

correct ~ 1 + trial * cue + (1 | trial) + (1 | ID), data=df


is the formulation you would use to treat ID and trial as crossed random effects, but as mentioned above, this does not make sense.

The third model:

correct ~ 1 + trial * cue + (1 + trial | ID)


does make sense, based on the description. Here we are fitting random intercepts for participants and allowing the fixed effect of trial to vary by participant. If this is what you want, then this would be a reasonable model, provided that it is supported by the data.