# What statistical tests should be performed to test effect of trials on response times where each subject has different number of data points?

I am running a behavioral experiment where a number of subjects (=20 in my case) perform a simple cognitive task. The experiment consists of a fixed number of trials (say, 40 in my case). During each trial, the participant executes a single key-press and the response time (RT) is recorded.

So my recorded data looks like this:

subject-1   -> [Trial-1 RT, Trial-2 RT ... Trial-40 RT]              # (40 trials)
subject-2   -> [Trial-1 RT, Trial-2 RT ... Trial-40 RT]              # (40 trials)
...        ...       ...
subject-20  -> [Trial-1 RT, Trial-2 RT ... Trial-40 RT]              # (40 trials)


Now based on some RT criterion, a few trials are removed for each subject. This resulting data looks like this:

subject-1   -> [Trial-1 RT, Trial-3 RT ... Trial-40 RT]              # (32 trials)
subject-2   -> [Trial-1 RT, Trial-2 RT ... Trial-38 RT]              # (36 trials)
...        ...       ...
subject-20  -> [Trial-3 RT, Trial-8 RT ... Trial-40 RT]              # (28 trials)


The removal of a few trials result in a non-uniform number of data-points for each subject. Eg. subject-1, subject-2 and subject-20 have 32, 36 and 28 trials respectively.

Now I want to test the effect of trials on response times, what statistical methods should I use?

I know that when I am not removing the data, I have a nice 20*40 (subjects * trials) data matrix on which I can perform repeated measures ANOVA (within-subject) to see the effect of trials on response times. But how should I go about it if I am removing a couple of trials?

This type of data (repeated measures on a group of subjects) lends itself perfectly for a linear mixed model (LMM) analysis. I'm into psychophysics myself and I have mostly abandoned simple ANOVAs and switched to LMMs almost completely, especially because it can handle missing data, and because LMMs allow for inclusion of trial and session number to correct for them in an elegant manner. In effect, you can potentially take learning effects and/or mental fatigue into account. Between-subject (baseline) differences and learning effects are two of the most pesky problems in psychophysics and repeated measure designs, respectively. This makes the use of LMMs so rewarding in this field.

An LMM has several huge advantages over standard ANOVA analysis and it is expected to replace standard ANOVA analysis in time.

• Subjects (and other variables) can be included as random effect, such that the model corrects for within-subject differences (akin to repeated measures);
• Missing data are allowed and corrected for;
• Fixed and covariate factors can be included and tested for significance. In your case trial # can be included as a covariate. The LMM will calculate the effect of trial # on your outcome measure and will calculate whether that effect is significant or not (check 'model estimates' under statistics when you use SPSS);
• LMMs can be statistically powerful, despite low subject numbers.

If you wish to stick to standard RM-ANOVA, you can also opt to impute your data to correct for missing values. Especially multiple imputation is a robust way of estimating missing data (Van Netten et al., 2016), also available in SPSS.

Reference
- Van Netten et al. Ear Hear (2017); 38: 1–6

• Thanks, @AliceD. While I was able to find another way around it, your suggestion seems like a potentially useful solution to similar problems. – zoozoo Jul 19 at 9:53
• @zoozoo - feel free to add an answer to your own question and enlighten us with your solution! – AliceD Jul 19 at 10:32

Mixed effects regression is somewhat related to repeated measures ANOVA and can handle missing data. However, they assume the missing data are missing at random.

Depending on what type of rejection criteria you are using, that assumption may be broken, in which case I think you're pretty much out of luck without a method to account for that. It may be that it is a sufficiently reasonable assumption, however, even if not strictly warranted.

LMM is a good suggestion, second that.

Consider also fitting a log-normal to the RT's as recommended by Haines & friends https://psyarxiv.com/xr7y3/download/?format=pdf

You will have more or less uncertainty depending on how many trials you got, but it won't matter that people did different numbers of trials. I find the arguments in this paper for 'one stage' inference (as opposed to two-stage summary) very compelling, see what you think, your mileage may vary. One reason to like it is that it goes very naturally with hierarchical approaches, so it's a natural ally of that LMM suggestion.

It seems likely that the dropped data points are super-fast or super-long RT's that are from some data generating process other than the one you're studying, right? The participant sneezed or snoozed briefly and then went back to doing the task? You can wrap that understanding into the model! If your actual understanding of the data generating process suggests that RT's are usually log normal with a mean that depends on condition, but there are some uniformly distributed contaminants, you can write down a model that says exactly that and do inference with it. There's a nice rundown of the theory/motivation here: https://www.sciencedirect.com/science/article/pii/S0022249610000593 but it's gotten much easier to do since this article was written. There's a blow-by-blow walkthrough with code in this incredibly awesome blog post https://www.martinmodrak.cz/2021/04/01/using-brms-to-model-reaction-times-contaminated-with-errors/