# Mixed effects model for paired subjects in a complex design

I'm new to the mixed effects approach and I'm struggling to understand how to apply it to my relatively complicated experimental design given that all tutorials and articles I read are not directly comparable.

We are studying how perceptual accuracy differs depending on a number of factors. Specifically, people are asked to explore some objects with touch and estimate their sizes. One group of participants explores the objects actively (moving their hand) and we record their trajectories (doesn't matter how for this question). Then, we have another group of participants who explore the objects passively by having the active participant's trajectories applied to their hand. Each "passive" participants receives the trajectories of a specific matched "active" participant in exactly the same order.

Each person is asked to explore 6 different objects in 2 possible orientations and receives 2 possible questions before the exploration. Each combination of factors is repeated 3 times resulting in 72 trials per person. We don't have any theoretical predictions regarding the different objects and orientations but we want to know how perceptual accuracy differs depending on the group (active-passive) and question manipulation and whether there is a possible interaction effect.

So, the variables we have are as follows:

• continuous response variable: perceptual accuracy (accuracy)
• between-subject variable: active vs passive condition (condition)
• within-subject variable: 2 types of questions (question)
• within-subject variable: 2 object orientations (orientation)
• within-subject variable: 6 different objects (object)
• possible learning effect: trial number (trialNum)

I was trying to translate this into the LMM vocabulary and got as far as follows:

• fixed effects: 2 conditions and 2 question types
• random effects: subject, object orientation, object to account for random variability

Does that sound reasonable so far?

Typing this into R would be:

model1 <- lmer(accuracy ~ condition * question + (1+question|subjectID) +
(1|object) + (1|orientation), data = df)


What I struggle with specifically is

1. How do I enter the possible effect of trial number?
2. How can I take into account the fact that the subjects are paired through the trajectories that they perform to explore the object? That is, while the accuracy might differ depending on each person, it might also be affected by the specific ways of exploring the object introducing a possible source of variability between paired subjects. Is this some kind of nesting?
3. Am I missing something about possible crossed effects? That is, the fact that each trial involves a specific combination of within-subject variables (question, object and orientation)?

These are good questions you are asking before moving forward with this model, which, in my opinion, has some issues. I'll address each of your questions and that should also address the problems with the model.

How do I enter the possible effect of trial number?

For this, you can enter trial number as a fixed effects predictor in the model. You should explore the association graphically in order to understand whether there appears to be any association, and if so, if it appears linear or non-linear. If linear, you can simply add it to the model, if non-linear but systematic, you could consider adding a squared or cubed term of it to the model. You could also add it as a factor variable, which does not assume any linearity in the association and instead, treats each instantiation of a new trial number as having it's some average association with the outcome (relative to the holdout group).

How can I take into account the fact that the subjects are paired through the trajectories that they perform to explore the object?

It is not clear to me that this is something you need to account for in the model. You could create a pairing ID variable that has the same value for each individual in the pair and include it as a random intercept. I would look to see whether there is any appreciable variance in this intercept before deciding whether to include it in your final model.

Am I missing something about possible crossed effects?

By including object and orientation in the model, you take care of any cross-classification. However, I would advise you to include object and orientation as fixed effect factor predictors. The main reason is that they have very few values (<=6), which is too few for a random intercept. You'd want at least 10-15 values in a variable that you are treating as a random intercept. This is due to the idea that a random intercept is a population parameter with a normal distribution and estimated variance, and accordingly, is supposed to be representative of a larger population of groups, subjects, conditions, etc. This, plus the fact that these models do not behave well when random intercepts have so few groups. There is some great discussion in this earlier CV thread.