How to extract/compute leverage and Cook's distances for Generalised Additive models

Similar to the following question,

How to extract/compute leverage and Cook's distances for linear mixed effects models

Is there any method in R to determine influential points in a GAM?

If your model is quick to fit, you can calculate a leave-one-out measure of sample influence manually like this:

mref <- gam(y ~ s(x), data = DAT)
fref <- fitted(mref)

f <- function(index) {
dat <- DAT[-index, ]
m <- gam(y ~ s(x), data = dat)

# sum of squared differences between this fit and reference model
# based on full dataset
sum( (fref[-index] - fitted(m))^2 )
}

influence <- sapply(1:nrow(DAT), f)

• Thanks but how do you determine how big the sum of squared differences has to be to for a point to be influential?. – user53020 Jan 23 '17 at 16:06
• @user53020 Rather than taking any particular threshold, I would take the values as a relative measure of influence and look for any that stand out from the rest, as per this answer – michael Jan 24 '17 at 6:41