smooth.influence: Nonparametric Regression Diagnostics

View source: R/smooth.influence.R

smooth.influenceR Documentation

Nonparametric Regression Diagnostics


These functions provide the basic quantities that are used to form a variety of diagnostics for checking the quality of a fit smoothing spline (fit by ss), smooth model (fit by sm), or generalized smooth model (fit by gsm).


## S3 method for class 'ss'
influence(model, do.coef = TRUE, ...)
## S3 method for class 'sm'
influence(model, do.coef = TRUE, ...)
## S3 method for class 'gsm'
influence(model, do.coef = TRUE, ...)

smooth.influence(model, do.coef = TRUE)



an object of class "gsm" output by the gsm function, "sm" output by the sm function, or "ss" output by the ss function


logical indicating if the changed coefficients are desired (see Details).


additional arguments (currently ignored)


Inspired by influence and lm.influence functions in R's stats package.

The functions documented in smooth.influence.measures provide a more user-friendly way of computing a variety of regression diagnostics.

For non-Gaussian gsm objects, these regression diagnostics are based on one-step approximations, which may be inadequate if a case has high influence.

For all models, the diagostics are computed assuming that the smoothing parameters are fixed at the given values.


A list with the components


a vector containing the leverages, i.e., the diagonals of the smoothing matrix


if do.coef is true, a matrix whose i-th row contains the change in the estimated coefficients which results when the i-th case is excluded from the fitting.


a vector whose i-th entry contains the deviance which results when the i-th case is excluded from the fitting.


a vector whose i-th entry contains the effective degrees-of-freedom which results when the i-th case is excluded from the fitting.


a vector whose i-th element contains the estimate of the residual standard deviation obtained when the i-th case is excluded from the fitting.


a vector of weighted (or for class gsm rather deviance) residuals.


The approximations used for gsm objects can result in sigma estimates being NaN.


The coefficients returned by smooth.influence (and the corresponding functions S3 influence methods) are the change in the coefficients which result from dropping each case, i.e., θ - θ_i, where θ are the original coefficients obtained from the full sample of n observations and θ_i are the coefficients that result from dropping the i-th case.


Nathaniel E. Helwig <>


See the list in the documentation for influence.measures

Chambers, J. M. (1992) Linear models. Chapter 4 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.

See Also

ss, sm, gsm for modeling functions

smooth.influence.measures for convenient summary

diagnostic.plots for regression diagnostic plots


# generate data
n <- 100
x <- seq(0, 1, length.out = n)
fx <- 2 + 3 * x + sin(2 * pi * x)
y <- fx + rnorm(n, sd = 0.5)

# fit models <- ss(x, y, nknots = 10) <- sm(y ~ x, knots = 10)
mod.gsm <- gsm(y ~ x, knots = 10)

# calculate influence <- influence( <- influence(
infl.gsm <- influence(mod.gsm)

# compare hat
mean(($hat -$hat)^2)
mean(($hat - infl.gsm$hat)^2)
mean(($hat - infl.gsm$hat)^2)

# compare deviance
mean(($deviance -$deviance)^2)
mean(($deviance - infl.gsm$deviance)^2)
mean(($deviance - infl.gsm$deviance)^2)

# compare df
mean(($df -$df)^2)
mean(($df - infl.gsm$df)^2)
mean(($df - infl.gsm$df)^2)

# compare sigma
mean(($sigma -$sigma)^2)
mean(($sigma - infl.gsm$sigma)^2)
mean(($sigma - infl.gsm$sigma)^2)

# compare residuals
mean(($wt.res -$wt.res)^2)
mean(($wt.res - infl.gsm$dev.res)^2)
mean(($wt.res - infl.gsm$dev.res)^2)

# NOTE: ss() coef only comparable to sm() and gsm() after rescaling <- rep(c(1,$specs$thetas), times = c(2, 10))
scale.gsm <- rep(c(1, mod.gsm$specs$thetas), times = c(2, 10))
mean((coef( / - coef(^2)
mean((coef( / scale.gsm - coef(mod.gsm))^2)
mean((coef( - coef(mod.gsm))^2)

#$coefficients are *not* comparable to others
mean(($coefficients -$coefficients)^2)
mean(($coefficients - infl.gsm$coefficients)^2)
mean(($coefficients - infl.gsm$coefficients)^2)

npreg documentation built on July 21, 2022, 1:06 a.m.