# Repeated measures / linear mixed model: Aggregating vs. modelling every data point

Assume that you repeatedly collected measures from multiple subjects under different conditions, e.g. reaction times in response to differently colored stimuli:

| Subject | Condition | RT    |
|---------|-----------|-------|
|    1    | Red       | 323   |
|    1    | Red       | 243   |
|    1    | Blue      | 665   |
|    1    | Blue      | 242   |
|    2    | Red       | 163   |
|    2    | Red       | 344   |
|    2    | Blue      | 233   |
|    2    | Blue      | 119   |
|   ....  | ....      | ...   |


Now, to compare reaction times between conditions, you could easily calculate a paired t-test (i.e. a one-sample t-test over the differences). You could also apply a random-intercept linear mixed model over the aggregated (averaged per condition and subject) data and receive the same - mathematically equivalent - result:

lmer(RT ~ Condition + (1|Subject))


Question: However, you could also run the above model without aggregating fist. This obviously yields a different result. Would this model still be interpretable? How would it be different from the aggregated data?

m1 <- lmer(RT ~ 1 + condition + (1|Subject), data=df)

This model appropriately accounts for the correlation of reaction times within individuals (random intercept) and provides a test of the mean difference between the referent condition and each of the other conditions. You can use emmeans or effects to get the pairwise comparisons:
emmeans(m1, list(pairwise ~ condition), adjust = "holm") #can use different adjustment