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.

You don't say what gam() function you are using. There are at least two out there and they work in quite different ways.


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)
<snip>

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.

Probably not. If the number of degrees of freedom for age is small it may be quite a good approximation. If you are using mgcv::gam you will have seen a warning to this effect on the help page for anova.gam.


If you need a more accurate test you could simulate from model2 and compare the simulated distribution of the p-value to the value in the observed data.

        -thomas

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to