[R] anova.lm and F-test
Suresh Krishna
madzientist at gmail.com
Mon Jul 9 15:40:26 CEST 2012
Hello,
Why does anova.lm sometimes return a p-value and at other times not ? Is
it because it recognizes nested models from non-nested ones ?
> x<-seq(1,100,1)
> y<-3*x+rnorm(100)
> anova(lm(y~x),lm(y~x+I(x^2)),test="F")
Analysis of Variance Table
Model 1: y ~ x
Model 2: y ~ x + I(x^2)
Res.Df RSS Df Sum of Sq F Pr(>F)
1 98 90.449
2 97 90.288 1 0.16117 0.1732 0.6782
> anova(lm(y~x),lm(y~I(x^2)+I(x^3)),test="F")
Analysis of Variance Table
Model 1: y ~ x
Model 2: y ~ I(x^2) + I(x^3)
Res.Df RSS Df Sum of Sq F Pr(>F)
1 98 90.4
2 97 7345.7 1 -7255.3
Thanks, Suresh
More information about the R-help
mailing list