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?

• Why are you removing data? Instead of removing the data, it might be better to account for its particularities in your model. Also, I'd expect response times to violate ANOVA assumptions. Commented Jun 16, 2020 at 12:37
• @Roland I did ensure that ANOVA assumptions were not violated when I was running rm ANOVA on the original data. Also, I am not aware of ways to account for the removed trials in the model. Can you please suggest some methods. Commented Jun 16, 2020 at 13:36

One approach to this problem is with a linear mixed effects model. Mixed effects models can handle unbalanced designs. There are repeated measures within subjects, so we can fit random intercepts for subject

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

RT ~ Trial + (1|subject)


If trial is a factor variable then this will produce 39 estimates (1 will be included in the intercept). If there is a meaningful temporal structure to the trials, then you might want to code it as numeric, in which case you will obtain an estimate for the linear association of the response times with trials over time. You could explore nonlinear associations by including higher order terms (eg quadratic and cubic) or with splines.

• Does this answer your question ? If so please consider marking it as the accepted answer. If not please let us know why so that it can be improved Commented Aug 7, 2020 at 5:26