From what I understand GLM with a gaussian family should give the same results as LM in R, because they're essentially the same thing (from reading other posts).
When I run both on my data I get differences in significance levels; could someone explain why? The regression output appears the same, but when I do pairwise comparisons the results are different.
I am using the multcomp
package for significance levels (I know there is a strong argument that p-values should not be used for regression outputs.) Is this discrepancy to do with multcomp
or am I missing something?
lm <- lm(gene ~ condition, data = data)
summary(lm)
Call:
lm(formula = gene ~ condition, data = data)
Residuals:
Min 1Q Median 3Q Max
-1.49604 -0.54119 0.02927 0.61199 1.26961
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -5.0178 0.3395 -14.781 1.84e-14 ***
groupCS 0.4658 0.4383 1.063 0.2973
groupSC -0.1508 0.4383 -0.344 0.7335
groupSS 1.2337 0.4626 2.667 0.0128 *
---
Residual standard error: 0.8316 on 27 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.3145, Adjusted R-squared: 0.2384
F-statistic: 4.13 on 3 and 27 DF, p-value: 0.01562
> ph <- glht(lm, mcp(group="Tukey"))
> summary(ph)
Simultaneous Tests for General Linear Hypotheses
Multiple Comparisons of Means: Tukey Contrasts
Fit: lm(formula = gene ~ condition, data = data)
Linear Hypotheses:
Estimate Std. Error t value Pr(>|t|)
CS - CC == 0 0.4658 0.4383 1.063 0.7139
SC - CC == 0 -0.1508 0.4383 -0.344 0.9856
SS - CC == 0 1.2337 0.4626 2.667 0.0578 .
SC - CS == 0 -0.6165 0.3920 -1.573 0.4096
SS - CS == 0 0.7680 0.4191 1.833 0.2798
SS - SC == 0 1.3845 0.4191 3.304 0.0137 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Adjusted p values reported -- single-step method)
and running the automatic glm (with Gaussian distribution);
Call:
glm(formula = gene ~ condition, data = data)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.49604 -0.54119 0.02927 0.61199 1.26961
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -5.0178 0.3395 -14.781 1.84e-14 ***
groupCS 0.4658 0.4383 1.063 0.2973
groupSC -0.1508 0.4383 -0.344 0.7335
groupSS 1.2337 0.4626 2.667 0.0128 *
---
(Dispersion parameter for gaussian family taken to be 0.6914902)
Null deviance: 27.237 on 30 degrees of freedom
Residual deviance: 18.670 on 27 degrees of freedom
(1 observation deleted due to missingness)
AIC: 82.255
Number of Fisher Scoring iterations: 2
> ph <- glht(lm, mcp(group="Tukey"))
> summary(ph)
Simultaneous Tests for General Linear Hypotheses
Multiple Comparisons of Means: Tukey Contrasts
Fit: glm(formula = gene ~ condition, data = data)
Linear Hypotheses:
Estimate Std. Error z value Pr(>|z|)
CS - CC == 0 0.4658 0.4383 1.063 0.71155
SC - CC == 0 -0.1508 0.4383 -0.344 0.98596
SS - CC == 0 1.2337 0.4626 2.667 0.03803 *
SC - CS == 0 -0.6165 0.3920 -1.573 0.39337
SS - CS == 0 0.7680 0.4191 1.833 0.25721
SS - SC == 0 1.3845 0.4191 3.304 0.00517 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Adjusted p values reported -- single-step method)
> str(data)
'data.frame': 127 obs. of 23 variables:
$ sample.id : chr "1" "3" "4" "5" ...
$ group : Factor w/ 4 levels "CC","CS","SC",..: 1 1 1 1 1 1 2 2 2 3 ...
$ gene : num -4.57 -4.91 -4.48 -5.32 -5.24 ...
lm
, it uses a t statistic whereas withglm
, it uses a z statistic. I suspect the slight differences are due to that. $\endgroup$emmeans()
. I assume this difference will remain for some time when usingglht()
. $\endgroup$