3
$\begingroup$

I am working with the package mgcv fitting some GAMs with several covariates, and the same models with GAMMs including annual correlation.

Applying the summary function to our GAMs and GAMMs we got the R squared that inform about the quality of our model and how well the data fit it. However, the Deviance explained is only showed for GAMs and not for GAMMs.

If I understand well, a given model could fit well some data but another model with different predictor variables can fit slightly worse but explain model variability and therefore, could be better.

Since we are going to present results of GAMs and GAMMs in our work, I would like to calculate the Deviance explained of both models.

Some time ago I found a way to calculate the Deviance explained in GAMM by calculating the sum of squared residuals of the null GAMM (gamm0) assuming that it should be the same thing as the null deviance. Then, we can do the same with the GAMM for which we would like to calculate the Deviance explained (gamm1) and calculate the proportion that it has been reduced relative to the gamm0. Something like that:

data$rand <- 1
gamm0 <- gamm(response ~ 1, random = list(rand = ~ 1), data=data, family=nb) # NULL GAMM
DN <- sum(residuals(gamm0$gam, type = "pearson")^2) # Deviance from NULL GAMM
DR <- sum(residuals(gamm1$gam, type = "pearson")^2) # Deviance from our GAMM
DE <- (DN-DR)*100/DN; DE # Deviance Explained from our GAMM model

I some place I had notted a comment telling that it should be done with the "deviance" residuals and not with the "pearson" residuals, and indeed the results are different.

Therefore, I don't know it this way to calculate the Deviance explained for a GAMM is correct, and if it is correct which residuals I should calculate ("deviance" or "pearson").

Moreover, I'm wondering why the Deviance explained is not showed in the summary function and it it shouldn't be calculated for GAMMs for any reason.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.