\HeaderA{influence.measures}{Regression Deletion Diagnostics}{influence.measures}
\aliasA{cooks.distance}{influence.measures}{cooks.distance}
\methaliasA{cooks.distance.glm}{influence.measures}{cooks.distance.glm}
\methaliasA{cooks.distance.lm}{influence.measures}{cooks.distance.lm}
\aliasA{covratio}{influence.measures}{covratio}
\aliasA{dfbeta}{influence.measures}{dfbeta}
\methaliasA{dfbeta.lm}{influence.measures}{dfbeta.lm}
\aliasA{dfbetas}{influence.measures}{dfbetas}
\methaliasA{dfbetas.lm}{influence.measures}{dfbetas.lm}
\aliasA{dffits}{influence.measures}{dffits}
\aliasA{hat}{influence.measures}{hat}
\aliasA{hatvalues}{influence.measures}{hatvalues}
\methaliasA{hatvalues.lm}{influence.measures}{hatvalues.lm}
\aliasA{print.infl}{influence.measures}{print.infl}
\aliasA{rstandard}{influence.measures}{rstandard}
\methaliasA{rstandard.glm}{influence.measures}{rstandard.glm}
\methaliasA{rstandard.lm}{influence.measures}{rstandard.lm}
\aliasA{rstudent}{influence.measures}{rstudent}
\methaliasA{rstudent.glm}{influence.measures}{rstudent.glm}
\methaliasA{rstudent.lm}{influence.measures}{rstudent.lm}
\aliasA{summary.infl}{influence.measures}{summary.infl}
\keyword{regression}{influence.measures}
\begin{Description}\relax
This suite of functions can be used to compute some of the regression
(leave-one-out deletion) diagnostics for linear and generalized linear
models discussed in Belsley, Kuh and Welsch (1980), Cook and Weisberg (1982),
etc.
\end{Description}
\begin{Usage}
\begin{verbatim}
influence.measures(model)

rstandard(model, ...)
## S3 method for class 'lm':
rstandard(model, infl = lm.influence(model, do.coef = FALSE),
          sd = sqrt(deviance(model)/df.residual(model)), ...)
## S3 method for class 'glm':
rstandard(model, infl = lm.influence(model, do.coef = FALSE),
          ...)

rstudent(model, ...)
## S3 method for class 'lm':
rstudent(model, infl = lm.influence(model, do.coef = FALSE),
         res = infl$wt.res, ...)
## S3 method for class 'glm':
rstudent(model, infl = influence(model, do.coef = FALSE), ...)

dffits(model, infl = , res = )

dfbeta(model, ...)
## S3 method for class 'lm':
dfbeta(model, infl = lm.influence(model, do.coef = TRUE), ...)

dfbetas(model, ...)
## S3 method for class 'lm':
dfbetas(model, infl = lm.influence(model, do.coef = TRUE), ...)

covratio(model, infl = lm.influence(model, do.coef = FALSE),
         res = weighted.residuals(model))

cooks.distance(model, ...)
## S3 method for class 'lm':
cooks.distance(model, infl = lm.influence(model, do.coef = FALSE),
               res = weighted.residuals(model),
               sd = sqrt(deviance(model)/df.residual(model)),
               hat = infl$hat, ...)
## S3 method for class 'glm':
cooks.distance(model, infl = influence(model, do.coef = FALSE),
               res = infl$pear.res,
               dispersion = summary(model)$dispersion,
               hat = infl$hat, ...)

hatvalues(model, ...)
## S3 method for class 'lm':
hatvalues(model, infl = lm.influence(model, do.coef = FALSE), ...)

hat(x, intercept = TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{model}] an \R{} object, typically returned by \code{\LinkA{lm}{lm}} or
\code{\LinkA{glm}{glm}}.
\item[\code{infl}] influence structure as returned by
\code{\LinkA{lm.influence}{lm.influence}} or \code{\LinkA{influence}{influence}} (the latter
only for the \code{glm} method of \code{rstudent} and
\code{cooks.distance}).
\item[\code{res}] (possibly weighted) residuals, with proper default.
\item[\code{sd}] standard deviation to use, see default.
\item[\code{dispersion}] dispersion (for \code{\LinkA{glm}{glm}} objects) to use,
see default.
\item[\code{hat}] hat values \eqn{H_{ii}}{H[i,i]}, see default.
\item[\code{x}] the \eqn{X}{} or design matrix.
\item[\code{intercept}] should an intercept column be pre-prended to \code{x}?
\item[\code{...}] further arguments passed to or from other methods.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The primary high-level function is \code{influence.measures} which produces a
class \code{"infl"} object tabular display showing the DFBETAS for
each model variable, DFFITS, covariance ratios, Cook's distances and
the diagonal elements of the hat matrix.  Cases which are influential
with respect to any of these measures are marked with an asterisk.

The functions \code{dfbetas}, \code{dffits},
\code{covratio} and \code{cooks.distance} provide direct access to the
corresponding diagnostic quantities.  Functions \code{rstandard} and
\code{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 linear models are approximations, as described
in Williams (1987) (except that Cook's distances are scaled as
\eqn{F}{} rather than as chi-square values).  The approximations can be
poor when some cases have large influence.

The optional \code{infl}, \code{res} and \code{sd} arguments are there
to encourage the use of these direct access functions, in situations
where, e.g., the underlying basic influence measures (from
\code{\LinkA{lm.influence}{lm.influence}} or the generic \code{\LinkA{influence}{influence}}) are
already available.

Note that cases with \code{weights == 0} are \emph{dropped} from all
these functions, but that if a linear model has been fitted with
\code{na.action = na.exclude}, suitable values are filled in for the
cases excluded during fitting.

The function \code{hat()} exists mainly for S (version 2)
compatibility; we recommend using \code{hatvalues()} instead.
\end{Details}
\begin{Note}\relax
For \code{hatvalues}, \code{dfbeta}, and \code{dfbetas}, the method
for linear models also works for generalized linear models.
\end{Note}
\begin{Author}\relax
Several R core team members and John Fox, originally in his \file{car}
package.
\end{Author}
\begin{References}\relax
Belsley, D. A., Kuh, E. and Welsch, R. E. (1980)
\emph{Regression Diagnostics}.
New York: Wiley.

Cook, R. D. and Weisberg, S. (1982)
\emph{Residuals and Influence in Regression}.
London: Chapman and Hall.

Williams, D. A. (1987)
Generalized linear model diagnostics using the deviance and single
case deletions. \emph{Applied Statistics} \bold{36}, 181--191.

Fox, J. (1997)
\emph{Applied Regression, Linear Models, and Related Methods}. Sage.

Fox, J. (2002)
\emph{An R and S-Plus Companion to Applied Regression}.
Sage Publ.; \url{http://www.socsci.mcmaster.ca/jfox/Books/Companion/}.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{influence}{influence}} (containing \code{\LinkA{lm.influence}{lm.influence}}).
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## Analysis of the life-cycle savings data
## given in Belsley, Kuh and Welsch.
lm.SR <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)

inflm.SR <- influence.measures(lm.SR)
which(apply(inflm.SR$is.inf, 1, any)) # which observations 'are' influential
summary(inflm.SR) # only these
inflm.SR          # all
plot(rstudent(lm.SR) ~ hatvalues(lm.SR)) # recommended by some

## The 'infl' argument is not needed, but avoids recomputation:
rs <- rstandard(lm.SR)
iflSR <- influence(lm.SR)
identical(rs, rstandard(lm.SR, infl = iflSR))
## to "see" the larger values:
1000 * round(dfbetas(lm.SR, infl = iflSR), 3)

## Huber's data [Atkinson 1985]
xh <- c(-4:0, 10)
yh <- c(2.48, .73, -.04, -1.44, -1.32, 0)
summary(lmH <- lm(yh ~ xh))
(im <- influence.measures(lmH))
plot(xh,yh, main = "Huber's data: L.S. line and influential obs.")
abline(lmH); points(xh[im$is.inf], yh[im$is.inf], pch=20, col=2)
\end{ExampleCode}
\end{Examples}

