# Interpreting Reaction Time data with mixed-effects model

I have a problem with interpreting Reaction Time results with mixed-effect models.

In the experiment, participants were split into 2 conditions. They looked at the same set of pictures and then took part in a Reaction Time task. The data is unbalanced, because I removed outliers according to a pre-specified procedure (I'm aware of the issues with outlier removal). So x participants in Condition 1 and y participants in Condition 2 provided Reaction Times to the same pictures; each person only once, but for some participants not all responses are available.

If to follow the simplest standard procedure, I could aggregate the results by participants (i.e. get participant means) and compare the groups with a t-test. This gives a significant difference.

But there are additional factors I want to consider (for example ProceedingRT and Trial Sequence, which were shown to correlate with Reaction Times in the task: Baayen & Milin 2010). Plus, there is the independence assumption that would be violated (since the same participant is more likely to provide similar answers due to his/her reaction skills etc.). So linear mixed-effects model seems much more adequate.

I will also add gender to the mix, for theoretically-justified reasons. The most obvious model in this case would be:

RT(inverted) ~ cond + gender + RTtrial + proceedingRT + (1|ids) + (1|pic)


('ids' stands for participant id; 'pic' stands for 'picture'). I also inverted RT (1/RT) and standardised it for easier interpretation. This results in:

Random effects:
Groups   Name        Variance Std.Dev.
ids      (Intercept) 0.25276  0.5028
pic      (Intercept) 0.05411  0.2326
Residual             0.54659  0.7393
Number of obs: 309, groups:  ids, 31; pic, 14

Fixed effects:
Estimate Std. Error        df t value   Pr(>|t|)
(Intercept)   -0.17437    0.22172  28.64000  -0.786    0.43805
cond2         -0.27471    0.20965  24.92000  -1.310    0.20204
genderm        0.40161    0.21222  25.20000   1.892    0.06998 .
RTtrial       -0.21375    0.04472 276.97000  -4.780 0.00000285 ***
proceedingRT  -0.15225    0.05542 292.20000  -2.747    0.00638 **

Marginal R^2 was 0.15 and Conditional R^2 was 0.45.


P-values are just a visual helper from lmerTest (I'm aware of the issues with them, too:). Anyway, t-value for cond is pretty low and not well-justified if I compare it against a model with no cond as a predictor. However, when I run the same model without the random by-participant effect:

RT(inverted) ~ cond + gender + RTtrial + proceedingRT + (1|pic)


the effect of cond rises.

Random effects:
Groups   Name        Variance Std.Dev.
pic      (Intercept) 0.0466   0.2159
Residual             0.7628   0.8734
Number of obs: 309, groups:  pic, 14

Fixed effects:
Estimate Std. Error        df t value   Pr(>|t|)
(Intercept)   -0.16677    0.12121  77.93000  -1.376   0.172805
cond2         -0.24750    0.10322 293.55000  -2.398   0.017116 *
genderm        0.39617    0.10646 295.78000   3.721   0.000237 ***
RTtrial       -0.24894    0.05141 301.91000  -4.842 0.00000205 ***
proceedingRT  -0.27026    0.06032 299.17000  -4.480 0.00001063 ***

Marginal R^2 was 0.2 and Conditional R^2 was 0.25.


AIC value of the first model (with (1|ids)) is lower. However, the second model, despite performing worse overall, has a higher Marginal R-squared, meaning it explains bigger proportion of variance by fixed effects than the first model.

I generally understand that the first model can account for the random by-person variance, therefore accounts for more theoretically-justified variance, and therefore performs better overall. What I don't understand is why the random effect 'steals' the explained variance from the fixed effect. My understanding so far was that it should be the opposite: that random effects are only used to show how much 'leftover' variance there is in the data after accounting for all significant fixed effects. After all, I want to maximise Marginal R^2 - I want to know how well I can predict a given phenomenon with my known, well-defined, quantified, fixed factors.

I am not sure how to interpret this result: the impact of condition is significant when the by-participant variance is ignored, but it is not, when we account for its random effect... Does this mean that participants got split into conditions in some funny, regular way that elevated the cond effect?

Or perhaps I'm doing something wrong by including both cond and (1|ids) in the model, even though each participant could only be in one condition? If so, how could I account for by-participant variance within each condition separately?

And just to make it clear: I'm absolutely fine with either effect of condition, I just want to understand where this behaviour comes from. And why the result is contrary to the simplest t-test?

RTtrial is a number at which the picture was seen in the sequence. There were 14 pictures, the order was random, and there were 14 additional 'distractors' which are completely removed from analysis. In total there were 28 trials but I'm looking at only half of them. So RTtrial is a random set of 14 numbers from the range 1-28, and the numbers are unique within participant. Everyone saw the same pictures, that's why I want a random by-picture effect (some pictures might be easier to react to than others).

---OUTPUT from optinfo requested in comments (I'm not sure how to interpret it)

mem2@optinfo
$optimizer  "bobyqa"$control
$control$iprint
 0

$derivs$derivs$gradient  -0.000002817160 0.000003574314$derivs$Hessian [,1] [,2] [1,] 128.05035 -10.96187 [2,] -10.96187 244.71216$conv
$conv$opt
 0

$conv$lme4
list()

$feval  50$warnings
list()

\$val
 0.6800193 0.3146293

• Have you checked the optimization results? They are part of the lmer object, named optinfo. There you can check that a minimum was found and other diagnostics to ensure that your deal is actually converging properly. Jan 4, 2015 at 21:55
• Also: I don't under the pictures and RTrial. Is RTrial just the numbered trial? Does everyone see the same pictures? So is the number of pictures the same as the number of trials each person does? And were the pictures assigned in random order? Jan 4, 2015 at 21:56
• I have added additional info about the variables and output from optinfo. Jan 5, 2015 at 9:31

As a general rule, including a random subject effect in a repeated measures/mixed model pulls up the within subject effects and dampens between subject effects. In other words, if you fail to include a person effect that should exist, you are likely to get spurious significance of between subject effects and spurious non-significance of within subject effects.

Let's look at what happens with Person and Condition.

The mixed model assumes that each person has a "person effect" which we don't see. It comes from a normal distribution with mean 0. Ignoring pictures, trials and everything else, the total for condition 1 is the total of the person effects for persons receiving that condition + the estimated effect of condition 1 + the estimated intercept term (or something close to that. Your design isn't balanced, so the totals may not be exact. But that's the gist of what's happening). In a mixed model, the random effects (which get estimated during execution of the EM algorithm) are not constrained to sum to 0 over each condition, even though their theoretical mean is 0. Suppose the sum of the random effects of condition 1 just happened to be larger than the sum of the random effects of condition 2 -- and suppose also that the total over condition 1 is greater than the total over condition 2 ..... then in that case, the random effect is stealing from the fixed effect. In other words, if you remove the random effect, the full difference between condition 1 and condition 2 is explained by the condition effect. When you include random effects, some of the observed difference would be explained by the persons, at the expense of the condition. This is because Condition is a between subjects effect.

Now in the case of a large sample (large number of persons), and where the condition effect was meaningfully larger than the person effect, you wouldn't get this paradox. The person effects will likely cancel out over the condition, and the large condition effect will come shining through. However, your condition effect is smaller than the standard deviation of the person effect.

Furthermore, you don't say how many subjects you have, but I'm guessing it's not large. That means that the cumulative random person effects don't have the numbers they need to average out close to 0 within each condition, which means they will get in the way of estimating the condition effect.

You can ask R to produce the estimated random person effects and do a boxplot of these against Condition. If the mean (or median) person effects are pulling in the same direction as the condition difference, you are open to the paradox you mention.

I'm not sure what you should do here. To me, the concern is that all your effects are small. The variance of the person effect is around the same size as the condition effect. The variance of the picture effect is very small, and that variable should probably be dropped. Your optinfo looks good, so at least the model converged. But the biggest effects you have are gender and residual variance. In other words, people differ from each other; men differ from women.

You can test for random effects using package RLRsim. You can't do a Wald t-test on them because if indeed the variance of a random effect is 0, then your parameter is on the boundary of the parameter space and maximum likelihood asymptotics break down. RLRsim brute forces the issue through simulation. This will indicate whether you should drop the picture effect. I don't like dropping the person effect, since I think you only want to infer the relevance of experimental effects that are stronger than random person to person variation. You have a repeated measures design and you should honour that in the analysis.

I also have doubts about using the reciprocal of reaction time, unless you have strong theoretical grounds for holding that the 1/RT is linear in all that stuff. All of your parameters seem to be fairly close to 0 compared to the residual variance - your estimated (non-significant) intercept is even negative - which doesn't help interpretability. At least not for me.

As to your question about estimation, the random effects are not "conditional on having estimated the fixed effects". The likelihood is maximized over all parameters -- the so-called unseen random effects and the fixed effects. Each parameter estimate is made in the presence of the others.

• Thank you. Sample sizes indeed are small (~15 per condition). 1/RT is justified in theory and is linear. Typically, Reaction Time distributions are heavy-tailed. When I run the same model on RT (not 1/RT) as output, I get lower overall performance of the model with violated normality of residuals (even though, surprisingly, intercept gets significant). I haven't accepted the answer because--despite being extremely helpful on theoretical level--I could use a bit of clarification on two things regarding the interpretation: Jan 5, 2015 at 18:43
• a) is the use of t-test on aggregated data (aggregated to participant means) acceptable, as this is the technique typically used in this kind of research? Perhaps, linear mixed-effects shouldn't be used on so small sample sizes for the reasons mentioned by you? I don't know how to ask R to produce the estimated random person effects, so couldn't check the boxplot in the way you mentioned yet. b) does the fact that intercept is non-significant (and all effects quite small) justifies saying that the entire model is "no better than a random prediction"? Jan 5, 2015 at 18:44
• Yes. You can do a t-test on the aggregated data. As you point out in your question, you lose the ability to check out the effect of the pictures and trial sequence. Jan 6, 2015 at 12:59
• To check out the random effects (person effects) use the ranef method. If your fit is stored in object fit1, do ranef(fit1). You will get a list of random effects for the person and the picture. Jan 6, 2015 at 13:00
• I think your mixed model is worth doing. RTtrial is certainly a big effect. The coefficient represents change between sequence numbers. Over 24 sequence numbers, that's a large change, and the significance level is strong. You could quote both approaches. Either way, it is important to quote an effect size for Condition, with a confidence interval. Jan 6, 2015 at 13:04