[R] A hiccup when using anova on gam() fits.

Rolf Turner r.turner at auckland.ac.nz
Wed Jul 29 01:57:20 CEST 2009


I stumbled across a mild glitch when trying to compare the
result of gam() fitting with the result of lm() fitting.

The following code demonstrates the problem:

library(gam)
x <- rep(1:10,10)
set.seed(42)
y <- rnorm(100)
fit1 <- lm(y~x)
fit2 <- gam(y~lo(x))
fit3 <- lm(y~factor(x))
print(anova(fit1,fit2)) # No worries.
print(anova(fit1,fit3)) # Likewise.
print(anova(fit2,fit3)) # Throws an error.
print(anova(fit3,fit2)) # ``Works'' but gives negative degrees of  
freedom and sum of squares.

Is this evidence of a ``bug''?  Or am I being terribly young and  
naive to
expect anova() to work at all in such circumstances?

The error thrown is:

Error in anova.glmlist(list(object, ...), test = test) :
   (list) object cannot be coerced to type 'double'

	cheers,

		Rolf Turner


######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}




More information about the R-help mailing list