[R] Type III SS and collinearity in R
Fox, John
jfox at mcmaster.ca
Mon Jul 18 00:55:04 CEST 2016
Dear Pamela,
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Pamela
> Wong
> Sent: Sunday, July 17, 2016 1:58 AM
> To: r-help at r-project.org
> Subject: [R] Type III SS and collinearity in R
>
> Hi there
> It appears the Anova() function in the car package cannot compute type
> III SS when there is collinearity in the model. Has anyone else run into
> this problem?
That's right, by default anyway -- when there's *perfect* collinearity -- but in that circumstance what would be the point? That is, the SSs for the collinear terms are 0. You can force Anova() to (arbitrarily) deal with the collinearities
> library(car)
> mod <- lm(prestige ~ income + education + I(income + education), data=Duncan)
> Anova(mod, type="III", singular.ok=TRUE)
Anova Table (Type III tests)
Response: prestige
Sum Sq Df F value Pr(>F)
(Intercept) 360.2 1 2.0154 0.1631
income 4474.2 1 25.0331 1.053e-05 ***
education 5516.1 1 30.8626 1.727e-06 ***
I(income + education) 0
Residuals 7506.7 42
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' '
But, again, what's the point?
>
> I would use drop1() to obtain the SS but it does not provide the
> intercept...
Yes, drop1() reports the 0 SSs for all the collinear terms (on 0 df), which is better in a sense -- e.g.,
> drop1(mod)
Single term deletions
Model:
prestige ~ income + education + I(income + education)
Df Sum of Sq RSS AIC
<none> 7506.7 236.26
income 0 0 7506.7 236.26
education 0 0 7506.7 236.26
I(income + education) 0 0 7506.7 236.26
Why would it be interesting in this circumstance to know whether the intercept is 0? As you can see, Anova() reports the test; you can also get it from linearHypothesis():
> linearHypothesis(mod, "(Intercept)", singular.ok=TRUE)
Linear hypothesis test
Hypothesis:
(Intercept) = 0
Model 1: restricted model
Model 2: prestige ~ income + education + I(income + education)
Res.Df RSS Df Sum of Sq F Pr(>F)
1 43 7866.9
2 42 7506.7 1 360.22 2.0154 0.1631
I suspect that there's a statistical issue lurking here that's not addressed by showing you how to get the tests you're asking for.
Best,
John
--------------------------------------
John Fox, Professor
McMaster University
Hamilton, Ontario, Canada
Web: socserv.mcmaster.ca/jfox
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list