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

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to