4
$\begingroup$

I have seen this and similar questions all over the place, but no really satisfying answers: How can we quantify the contribution that each term in a GAM (using mgcv package) adds to the total Deviance explained or to adj. R²?

This post looks like someone found a nice way of deriving the deviance for each term and plotted it: GAM (mgcv): AIC vs Deviance Explained but doesn't demonstrate how they did it and hasn't been around this site for years.

Versions of the same question were asked here: How to get the variance explained by each term in a GAM and here: How to calculate percent partial deviance explained by each predictor variable in a GAM model? and here: Assessing variable importance in generalized additive models (GAM) and here: https://stackoverflow.com/questions/65137719/can-gam-vcomp-be-used-to-estimate-partial-deviance-explained-in-a-gam-with-gauls Here is a version of this question for mixed GAMs: https://stat.ethz.ch/pipermail/r-sig-mixed-models/2014q3/022703.html

I stumbled upon this package: https://cran.r-project.org/web//packages//gam.hp/gam.hp.pdf which appears to have been written for this specific purpose, but it ain't running for me. There also seems to be this function: https://search.r-project.org/CRAN/refmans/collinear/html/f_gam_deviance.html, but I am neither sure what it does nor what the "resulting preference order" in the description text is.

There were hinds to answers given here: https://stat.ethz.ch/pipermail/r-help/2009-July/397343.html, here: https://stat.ethz.ch/pipermail/r-help/2011-November/295324.html, and here: https://stackoverflow.com/questions/38516139/gam-r-variance-explained-by-variable, although these also do not seem to have been satisfactory, are tidysome with larger models, and are probably not the way the plots in the first post above were created.

Are there any new solutions to this question? Does any of you know, how to easily reproduce the DEVIANCE plots given here: GAM (mgcv): AIC vs Deviance Explained ?

Curious to see what you bring up, Thanks for reading

$\endgroup$

1 Answer 1

3
$\begingroup$

Update: This new R package gam.hp seems to be the solution I have been looking for: It contains basically one function (gam.hp()) that takes GAMs and GAMMs constructed with the mgcv package and decomposes either Adjusted R² or explained Deviance from the model into relative contributions per each predictor of the model formula. It also calculates which fraction of the explained deviance or R² is uniquely attributable to a certain predictor and the publication reference below discusses in how far that it useful to consider. Computation can take a while for complexer models. Further details see here:

Reference:

Lai J, Tang J, Li T, Zhang A, Mao L (2024) Evaluating the relative importance of predictors in Generalized Additive Models using the gam.hp R package. Plant Diversity, 46, 542-546. [Link]

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.