[R] anova() interpretation and error message

Jinsong Zhao jszhao at yeah.net
Sun Feb 6 12:17:30 CET 2011


Hi there,

I have a data frame as listed below:

 > Ca.P.Biomass.A
          P   Biomass
1 334.5567 0.2870000
2 737.5400 0.5713333
3 894.5300 0.6393333
4 782.3800 0.5836667
5 857.5900 0.6003333
6 829.2700 0.5883333

I have fit the data using logistic, Michaelis–Menten, and linear model, 
they all give significance.

 > fm1 <- nls(Biomass~SSlogis(P, phi1, phi2, phi3), data=Ca.P.Biomass.A)
 > fm2 <- nls(Biomass~SSmicmen(P, phi1, phi2), data=Ca.P.Biomass.A)
 > fm3 <- lm(Biomass~P, data = Ca.P.Biomass.A)

I hope to compare the difference among the three models, and I using 
anova(). As for the example here, the three models seem not have 
significant difference. However, I am confused by the negative df in the 
following ANOVA table. And my question is how to interpret the results, 
if the Pr < 0.05.

 > anova(fm1,fm2,fm3)
Analysis of Variance Table

Model 1: Biomass ~ SSlogis(P, phi1, phi2, phi3)
Model 2: Biomass ~ SSmicmen(P, phi1, phi2)
Model 3: Biomass ~ P
   Res.Df Res.Sum Sq Df      Sum Sq F value Pr(>F)
1      3 0.00063741
2      4 0.00087249 -1 -0.00023508  1.1064 0.3701
3      4 0.00142751  0  0.00000000

And when the argument position changed, the anova() give different 
results. It seems the anova() compare the first model with all other models.

 > anova(fm2,fm1,fm3)
Analysis of Variance Table

Model 1: Biomass ~ SSmicmen(P, phi1, phi2)
Model 2: Biomass ~ SSlogis(P, phi1, phi2, phi3)
Model 3: Biomass ~ P
   Res.Df Res.Sum Sq Df      Sum Sq F value Pr(>F)
1      4 0.00087249
2      3 0.00063741  1  0.00023508  1.1064 0.3701
3      4 0.00142751 -1 -0.00079010  3.7187 0.1494

When I put the fm3, a linear model, in the first position, and two nls 
model following it, anova() give the following error message. It seems 
abnormal.

 > anova(fm3,fm1,fm2)
Analysis of Variance Table

Response: Biomass
           Df   Sum Sq  Mean Sq F value    Pr(>F)
P          1 0.081163 0.081163  227.43 0.0001127 ***
Residuals  4 0.001428 0.000357
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Warning message:
In anova.lmlist(object, ...) :
   models with response c("NULL", "NULL") removed because response 
differs from model 1

Any suggestions and comments will be really appreciated. Thanks in advance.

Regards,
Jinsong



More information about the R-help mailing list