2024-02-05
Assume you are interested in sex differences in bodyfat in some hypothetical rodent.
A t-test on the sex difference gives \(P=0.2812\).
Or, simple ANOVA
m <- lm(bodyfat ~ sex, data = Sim.A) anova(m)
## Analysis of Variance Table ## ## Response: bodyfat ## Df Sum Sq Mean Sq F value Pr(>F) ## sex 1 0.05696 0.056960 1.183 0.2812 ## Residuals 58 2.79261 0.048148
Oh dear!
Clearly, there is a sex difference in bodyfat once you account for bodyweight:
m <- lm(bodyfat ~ bodyweight+sex, Sim.A,
contrasts = list(sex=contr.sum))
Anova(m)
## Anova Table (Type II tests) ## ## Response: bodyfat ## Sum Sq Df F value Pr(>F) ## bodyweight 2.25485 1 239.004 < 2.2e-16 ## sex 0.63519 1 67.328 3.137e-11 ## Residuals 0.53776 57
Assume you are interested in sex differences in bodyfat in some hypothetical rodent.
A t-test on the sex difference gives \(P=1.38\times 10^{-6}\).
How exciting!
Clearly, there is nothing interesting going on terms of sex differences in bodyfat.
The (very real) sex difference in bodyfat is entirely explained by the fact that males are bigger (higher bodyweight) and consequently they have more fat.
m <- lm(bodyfat ~ bodyweight+sex, Sim.B,
contrasts = list(sex=contr.sum))
Anova(m)
## Anova Table (Type II tests) ## ## Response: bodyfat ## Sum Sq Df F value Pr(>F) ## bodyweight 2.39405 1 264.5034 <2e-16 ## sex 0.00700 1 0.7735 0.3828 ## Residuals 0.51591 57
Assume you are interested in the relationship between bodyfat and bodyweight.
Univariate regression suggests there is no relationship whatsoever:
m <- lm(bodyfat ~ bodyweight, Sim.C) Anova(m)
## Anova Table (Type II tests) ## ## Response: bodyfat ## Sum Sq Df F value Pr(>F) ## bodyweight 0.0838 1 0.2559 0.6149 ## Residuals 18.9904 58
Assume you are interested in the relationship between bodyfat and bodyweight.
Once you factor in sex, it turns out that there is a clear positive relationship between bodyfat and bodyweight. It is just that males are bigger too.
m <- lm(bodyfat ~ sex+bodyweight, Sim.C,
contrasts = list(sex=contr.sum))
Anova(m)
## Anova Table (Type II tests) ## ## Response: bodyfat ## Sum Sq Df F value Pr(>F) ## sex 13.4637 1 138.860 < 2.2e-16 ## bodyweight 1.7379 1 17.924 8.462e-05 ## Residuals 5.5267 57