I tried to find out similar previous questions but, got no good result. I see some discrepancy between the lm() summary output; and anova(lm()) output. In the below R output, summary(lm()) tells that disp
variable is not significant statistically, while anova(lm()) tells that both variables are significant. Could anyone shed me a light on this?
The below is summary of lm() in R.
> summary(lm(mpg~disp+wt,mtcars))
Call:
lm(formula = mpg ~ disp + wt, data = mtcars)
Residuals:
Min 1Q Median 3Q Max
-3.4087 -2.3243 -0.7683 1.7721 6.3484
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 34.96055 2.16454 16.151 4.91e-16 ***
disp -0.01773 0.00919 -1.929 0.06362 .
wt -3.35082 1.16413 -2.878 0.00743 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.917 on 29 degrees of freedom
Multiple R-squared: 0.7809, Adjusted R-squared: 0.7658
F-statistic: 51.69 on 2 and 29 DF, p-value: 2.744e-10
>
and the below is the output of anova(lm()).
> anova(lm(mpg~disp+wt,mtcars))
Analysis of Variance Table
Response: mpg
Df Sum Sq Mean Sq F value Pr(>F)
disp 1 808.89 808.89 95.0929 1.164e-10 ***
wt 1 70.48 70.48 8.2852 0.007431 **
Residuals 29 246.68 8.51
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
---- added part begins
@Noah helped me a lot. Since I am a newbie here, I made some stupid things such as I making an answer thread to ask an additional question. While doing that I noticed low quality answer mark (or something like that). So, I am adding this part to clarify Noah's explanation and why it completes my question.
The initial Noah's answer was like this:
For t-test for an individual IV in multiple regression (lm()), R compares the whole model to the the model without the individual model. That is, for t-testing disp
IV, R compares the whole model lm(mpg ~ disp + wt)
to lm(mpg ~ wt)
(less disp) and see how much additional part is explained by the disp. This is another way of saying t-test in lm function is to see the 'pure regression' part (with the other IVs' parts out).
So, I did spcor.test
to see if Noah's answer is working; and, found out that it's not. But, Noah explained that R uses pcor.test instead of spcor.test. And I confirmed that. both pcor and spcor test are ways of seeing the unique contribution of IVs in a regression test. By unique contribution, I am talking about Some of Square part (SS) of IVs, which is usually referred as $SS_{regression}$. The difference is the denominator part. In the picture, red circle is mpg
; blue circle is disp
; and black is wt
. (2) is semipartial correlation squared value; and the denominator part is a+b+c+d (the while SS of y, that is, SS total). 3) is partial correlation squared value; the the denominator is a+b (less the shared part). In the below picture, d/a+d is significant, which is unique explanation of wt
without the whole influence of disp
part. And for the disp
part, b/a+b is not significant, since b is not big enough compared to a+b part. When Noah answered my question, I initially thought he meant (2) instead of (3); and Noah corrected me R uses (3) method in t-testing for each IV.
---- added part ends
anova(lm(mpg~wt+disp,mtcars))
. $\endgroup$