View source: R/smooth.influence.measures.R
| smooth.influence.measures | R Documentation |
These functions compute several regression (leave-one-out deletion) diagnostics for a fit smoothing spline (fit by ss), smooth model (fit by sm), or generalized smooth model (fit by gsm).
smooth.influence.measures(model, infl = smooth.influence(model))
## S3 method for class 'ss'
rstandard(model, infl = NULL, sd = model$sigma,
type = c("sd.1", "predictive"), ...)
## S3 method for class 'sm'
rstandard(model, infl = NULL, sd = model$sigma,
type = c("sd.1", "predictive"), ...)
## S3 method for class 'gsm'
rstandard(model, infl = NULL,
type = c("deviance", "pearson"), ...)
## S3 method for class 'ss'
rstudent(model, infl = influence(model, do.coef = FALSE),
res = infl$wt.res, ...)
## S3 method for class 'sm'
rstudent(model, infl = influence(model, do.coef = FALSE),
res = infl$wt.res, ...)
## S3 method for class 'gsm'
rstudent(model, infl = influence(model, do.coef = FALSE), ...)
## S3 method for class 'ss'
dfbeta(model, infl = NULL, ...)
## S3 method for class 'sm'
dfbeta(model, infl = NULL, ...)
## S3 method for class 'gsm'
dfbeta(model, infl = NULL, ...)
## S3 method for class 'ss'
dfbetas(model, infl = smooth.influence(model, do.coef = TRUE), ...)
## S3 method for class 'sm'
dfbetas(model, infl = smooth.influence(model, do.coef = TRUE), ...)
## S3 method for class 'gsm'
dfbetas(model, infl = smooth.influence(model, do.coef = TRUE), ...)
cov.ratio(model, infl = smooth.influence(model, do.coef = FALSE),
res = weighted.residuals(model))
## S3 method for class 'ss'
cooks.distance(model, infl = NULL, res = weighted.residuals(model),
sd = model$sigma, hat = hatvalues(model), ...)
## S3 method for class 'sm'
cooks.distance(model, infl = NULL, res = weighted.residuals(model),
sd = model$sigma, hat = hatvalues(model), ...)
## S3 method for class 'gsm'
cooks.distance(model, infl = NULL, res = residuals(model, type = "pearson"),
dispersion = model$dispersion, hat = hatvalues(model), ...)
## S3 method for class 'ss'
hatvalues(model, ...)
## S3 method for class 'sm'
hatvalues(model, ...)
## S3 method for class 'gsm'
hatvalues(model, ...)
model |
an object of class "gsm" output by the |
infl |
influence structure as returned by |
res |
(possibly weighted) residuals with proper defaults |
sd |
standard deviation to use, see defaults |
dispersion |
dispersion (for |
hat |
hat values |
type |
type of residuals for |
... |
additional arguments (currently ignored) |
Inspired by influence.measures and related functions in R's stats package.
The function smooth.influence.measures produces a class "infl" object, which displays the DFBETAS for each coefficient, DFFITS, covariance ratios, Cook's distance, and the diagonals of the smoothing matrix. Cases which are influential with respect to any of these measures are marked with an asterisk.
The S3 methods dfbetas, dffits, covratio, and cooks.distance provide direct access to the corresponding diagnostic quantities. The S3 methods rstandard and rstudent give the standardized and Studentized residuals, respectively. (These re-normalize the residuals to have unit variance, using an overall and leave-one-out measure of the error variance, respectively.)
Values for generalized smoothing models are approximations, as described in Williams (1987) (except that Cook's distances are scaled as F rather than chi-square values). THe approximations can be poor when some cases have large influence.
The optional infl, res, and sd arguments are there to encourage the use of these direct access functions in situations where the underlying basic influence measures, e.g., from smooth.influence, are already available.
For ss and sm objects, the code rstandard(*, type = "predictive") returns the leave-one-out (ordinary) cross-validation residuals, and the PRESS (PREdictive Sum of Squares) statistic is defined as
PRESS <- sum(rstandard(model, type = "predictive")^2)
Note that OCV = PRESS / n, where OCV = ordinary cross-validation criterion
Note: the dffits function in R's stats package can be used with the following syntax
dffits(model, infl = smooth.influence(model, do.coef = FALSE),
res = weighted.residuals(model))
Nathaniel E. Helwig <helwig@umn.edu>
See references listed in influence.measures
Williams, D. A. (1987). Generalized linear model diagnostics using the deviance and single case deletions. Applied Statistics, 36, 181-191. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/2347550")}
ss, sm, gsm for modeling functions
smooth.influence for some basic influence information
diagnostic.plots for regression diagnostic plots
# generate data
set.seed(1)
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
mod.ss <- ss(x, y, nknots = 10)
mod.sm <- sm(y ~ x, knots = 10)
mod.gsm <- gsm(y ~ x, knots = 10)
# calculate influence
infl.ss <- smooth.influence.measures(mod.ss)
infl.sm <- smooth.influence.measures(mod.sm)
infl.gsm <- smooth.influence.measures(mod.gsm)
# standardized residuals
rstan.ss <- rstandard(mod.ss)
rstan.sm <- rstandard(mod.sm)
rstan.gsm <- rstandard(mod.gsm)
# studentized residuals
rstud.ss <- rstudent(mod.ss)
rstud.sm <- rstudent(mod.sm)
rstud.gsm <- rstudent(mod.gsm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.