# linear mixed effects models: should I aggregate repeated trials?

A colleague of mine asked me to analyse some data from a movement experiment.

Participants were asked to turn their head three times to the left (toL), three times to the right (toR), with both the eyes open (EO) and the eyes closed (EC). Thus, each participant completed 12 movements. Their movement was recorded with optoelectronics and different movement's measures have been obtained (e.g. amplitude, maximum speed...).

Things are actually more complex, given that the same experiment has been run on healthy controls and neurological patients and, in the latter, in multiple sessions several days apart. Moreover, patients received different treatments in between some sessions.

For the moment, just consider a single session with patients only.

I have a dataset like this:

patient     trial   side    eyes    measure
1           1       toR     EO      45
1           2       toR     EO      38
1           3       toR     EO      20
1           4       toR     EC      16
1           5       toR     EC      30
1           6       toR     EC      40
1           7       toL     EO      26
1           8       toL     EO      30
1           9       toL     EO      16
1           10      toL     EC      10
1           11      toL     EC      29
1           12      toL     EC      9
2           1       toR     EO      41
2           2       toR     EO      26
2           3       toR     EO      42
2           4       toR     EC      27
2           5       toR     EC      39
2           6       toR     EC      28
2           7       toL     EO      3
...
n           12      toL     EC      5


Due to the overall complexity of the experimental design, I'd like to use linear mixed effects (LME) models to analyse these data.

However, I have a major perplexity due to repeated trials.

As often happens when human movement is studied, participants are asked to repeat the very same movement several times (three times in the current work). This is done to let participants to get used to the experimental setting, to reduce the measurement error and to take into consideration some learning effect which is (more or less) always present in movement.

If ANOVA were used to analyse these data, the three "identical" movements would be averaged (i.e. aggregated) and the effects of "eyes" and "side" on measures would be studied.

It seems to me that one of the strength of the LME models is that they are able to deal with full data (i.e. not aggregated).

Therefore, I would try in R (lme4 library, lmer function) the following maximal model on the full dataset reported above:

full_model <- measure ~ eyes * side + (1 + eyes * side|patient)


With "full dataset" I mean the dataset with 12n rows. Note that "trial" does not appear on the right side of the formula.

I know that full_model could be too complex for the current dataset. Therefore, I would use the buildmer() function to find the most complex model that is supported by data.

I know that the repeated measure's problem has been already discussed in Cross Validated single trial vs aggregation. However, I think that our data are peculiar.

We introduce a source of repetition (i.e. trial), which is not taken into account in the model. Is this approach correct?

Note that, if this is ok in LME models, it should be acceptable to drop another source of repetition (e.g. eyes or side) and still analyse the full dataset (i.e. with 12n rows).

In other words, I should be able to use the full database (i.e. with 12n rows) to analyse the following model: full_model <- measure ~ eyes + (1 + eyes|patient)

I'm asking you for your help because it seems to me that not taking into account "trial" in the formula of the LME model could lead to increase the type I error probability.

Could you please give me an advice? References with analyses similar to the present one would be highly appreciated.

ADDENDUM (16 03 2021) I explain better the model selection, prompted by Robert's comment.

I had a lot of thinking about the best model for these data. I agree that the choice of the model should be on some theoretical ground. And I see as well that an automated choice could lead to a model poorly generalisable. The best model, but for the current dataset only. However, I really think that the right model should have random intercepts and slopes for any predictor and interaction.

Consider patient 1 and 2 moving to the left with the eyes open.

I cannot find a theoretical reason to assume that, for example, movement speed (i.e. the "measure" in the toy dataset) is the same in the two patients. For this reason, random intercepts are used in the model.

Now consider these two patients moving to the left with the eyes open and then with the eyes closed.

Again, I cannot assume that movement speed decreases the same in the two patients when moving with the eyes closed. Thus, random slopes should be included in the model.

Note that an interaction term is needed to describe this condition (movement to the left, eyes open, eyes closed).

The right model seems to be the most complex one. I simple ask to buildermer to check if data support this model. If not, buildmer finds for me the closest model to the most complex one.

From the description it appears that trial is simply a factor that denotes the measurement occasion As such there is no need to handle the trial variable seperately. Specifying patient as a grouping variable random intercepts, should take care of the repeated measures.
full_model <- measure ~ eyes + (1 + eyes * side|patient)

If you have good reason to think that the the effect of eyes, side AND their interaction should all vary by patient, then it may be worth specifying such a model. However with this sample size it may well converge to a singular fit. Also, please don't use automated functions such as buildmer - this may easily result in a model which converges on this dataset but generalises very poorly outside your particuar study. A far better approach is to be guided by the theory to specify what should be allowed to vary by patient. In your particular case - does