1

I have a regression model with a polynomial term and I am using ANOVA to test for the significance of the terms. I have been asked to report the linear and quadratic terms separately for the polynomial term, but can't seem to do this in R using either stats::anova() or car::Anova().

The model summary function reports test statistics for each term separately, is there a way to do this using with an ANOVA? Or is there maybe a good reason why the ANOVA functions don't do this?

Reproducible example:

data(iris)
mod<-lm(Petal.Length ~ Species + poly(Petal.Width,2),data=iris)

Anova(mod) #gives output for "poly(Petal.Width, 2)"
summary(mod) #gives output for "poly(Petal.Width, 2)1" and "poly(Petal.Width, 2)2"

It does work if I specify the model as mod<-lm(Petal.Length ~ Species + Petal.Width + I(Petal.Width^2),data=iris) but after reading around it seems that poly() is more appropriate in most cases so I would prefer to use that if possible.

corn_bunting
  • 349
  • 1
  • 11

1 Answers1

1

anova() and car::Anova() treat those polynomial terms as same term (same as Species) and therefore the results are combined.

The easiest workaround is to create and compare nested models. This would matches with the I(.) syntax.

# you may also add the intercept-only model to completely match with I(.)
mod0<-lm(Petal.Length ~ Species,data=iris)
mod1<-lm(Petal.Length ~ Species + poly(Petal.Width,1,raw=T),data=iris)
mod2<-lm(Petal.Length ~ Species + poly(Petal.Width,2,raw=T),data=iris)
anova(mod0,mod1,mod2) 

Analysis of Variance Table

Model 1: Petal.Length ~ Species
Model 2: Petal.Length ~ Species + poly(Petal.Width, 1, raw = T)
Model 3: Petal.Length ~ Species + poly(Petal.Width, 2, raw = T)
  Res.Df    RSS Df Sum of Sq       F    Pr(>F)    
1    147 27.223                                   
2    146 20.833  1    6.3892 45.1372 3.896e-10 ***
3    145 20.525  1    0.3087  2.1811    0.1419    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
one
  • 3,121
  • 1
  • 4
  • 24