[R] GLM model vs. GAM model

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Oct 26 16:55:47 CEST 2004


R does not contain a gam() function.

*Two* contributed packages, gam and mgcv, do.

Please do as the posting guide asks and clarify what you are talking 
about here.

Your penultimate para is not logical: the tests are _not_ based on maximum
likelihood if ML fitting is not used.  However, there are other model
comparison tests that apply to non-ML fitting.  If you mean anova.gam() in
?mgcv, do read the help page which says

WARNING:

     Unless the models have no penalized terms then these methods are
     only approximate.

but there is also such a function in package gam.


On Tue, 26 Oct 2004, SUBIRANA CACHINERO, ISAAC wrote:

> I have a question about how to compare a GLM with a GAM model using anova
> function.
> 
> A GLM is performed for example: 
> 
> model1 <-glm(formula = exitus ~ age+gender+diabetes, family = "binomial",
> na.action = na.exclude)
> 
> A second nested model could be:
> 
> model2 <-glm(formula = exitus ~ age+gender, family = "binomial", na.action =
> na.exclude)
> 
> To compare these two GLM models the instruction is: 
> 
> anova(model1,model2, test="F")
> 
> Similarly for GAM models
> 
> model3 <-gam(formula = exitus ~ s(age)+gender, family = "binomial",
> na.action = na.exclude)
> 
> "R" allows to compare these two models (GLM vs. GAM)
> 
> anova(model2,model3, test="F") 
> 
> This instruction returns a p-value with no error or warning, but this test
> is based on maximum likelihood, and GAM models are not fitted with maximum
> likelihood criteria, thus I think this p-value is not correct.
> 
> Please, I really appreciate any information about how to compare a GLM with
> a GAM model. 

PLEASE do read the posting guide before posting.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list