I am playing with a toy data where the Simpson's paradox exists for two variables NO2 and temperature:

enter image description here

A scatter plot clearly shows that the correlation between NO2 and temperature was reversed when going from population level to subject level: enter image description here

I am thinking of using lme to detect this, by specifying temperature as a fixed effect and for each subject a random intercept:

summary(lme(NO2~temperature, data=data.frame(data2), random = ~1| subject))

My expectation was that despite the negative correlation at the individual level, the fixed effect of temperature should reflect what is at the population level, i.e. a positive coefficient. However, the results showed the opposite as a negative coefficient for temperature: enter image description here

My puzzle is:

  1. It seems that the fixed effect estimation result captures the negative correlation between NO2 and temperature within each individual but why?

  2. Is there a method to return both the correlations at the population level as well as the individual level? I tried to add a random slope for each subject like this:

    summary(lme(NO2~temperature, data=data.frame(data2), random = ~0+temperature| subject)) And then it returned a positive coefficient. Why is that? enter image description here


1 Answer 1


In any linear model, the coefficient for one predictor tells us how the response changes when that predictor changes while all other predictors don't change.

There are two predictors in your model: temperature and individual. Coefficient for temperature shows change in NO2 when temperature changes but the other predictor doesn't. Therefore, coefficient for temperature is negative.

However, you can compare that model with another model without the individual factor, that is, NO2 ~ temperature, where coefficient for temperature will be positive. In fact, that is Simson's reversal: the sign of the coefficient of one predictor gets reversed when we take in account another (usually categorical) predictor.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.