I have fitted a series of GAMs of increasing complexity, and compared with anova.gam. I get a significant p value (based on Chisq test) for a pair of models, even though the difference in deviance between the two models is 0.
The models are specified using default settings for gam, in mgcv (i.e. select = FALSE).
The smooth term in model 2 is non-significant and has edf = approx. 0, p = 1. Therefore I am not surprised the deviance does not change with its inclusion. However, I would expect the p value for the Chisq test to be ~1.
Am I misinterpreting this test?
Output below. Note the p-value for contrast between models 1 and 2 is very small even though deviance is 0.
anova.gam(model1, model2, models3, test="Chisq")
Analysis of Deviance Table
Model 1: outcome ~ s(sujetno, bs = "re")
Model 2: outcome ~ s(z.Cluster_1_PC1) + s(sujetno, bs = "re")
Model 3: outcome ~ s(z.Cluster_1_PC1) + s(sujetno, bs = "re") + z.age
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 1890 1889.0
2 1890 1889.0 -4.8263e-08 0.000 4.707e-07 ***
3 1886 1878.2 4.0115e+00 10.765 0.02899 *