\Header{lm.influence}{Regression Diagnostics}
\alias{influence}{lm.influence}
\methalias{influence.glm}{lm.influence}
\methalias{influence.lm}{lm.influence}
\keyword{regression}{lm.influence}
\begin{Description}\relax
This function provides the basic quantities which are
used in forming a wide variety of diagnostics for
checking the quality of regression fits.\end{Description}
\begin{Usage}
\begin{verbatim}
influence(model, ...)
## S3 method for class 'lm':
influence(model, do.coef = TRUE, ...)
## S3 method for class 'glm':
influence(model, do.coef = TRUE, ...)

lm.influence(model, do.coef = TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{model}] an object as returned by \code{\Link{lm}}.
\item[\code{do.coef}] logical indicating if the changed \code{coefficients}
(see below) are desired.  These need \eqn{O(n^2 p)}{} computing time.
\item[\code{...}] further arguments passed to or from other methods.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The \code{\Link{influence.measures}()} and other functions listed in
\bold{See Also} provide a more user oriented way of computing a
variety of regression diagnostics.  These all build on
\code{lm.influence}.

An attempt is made to ensure that computed hat values that are
probably one are treated as one, and the corresponding rows in
\code{sigma} and \code{coefficients} are \code{NaN}.  (Dropping such a
case would normally result in a variable being dropped, so it is not
possible to give simple drop-one diagnostics.)\end{Details}
\begin{Value}
A list containing the following components of the same length or
number of rows \eqn{n}{}, which is the number of non-zero weights.
Cases omitted in the fit are omitted unless a \code{\Link{na.action}}
method was used (such as \code{\Link{na.exclude}}) which restores them.

\begin{ldescription}
\item[\code{hat}] a vector containing the diagonal of the \dQuote{hat} matrix.
\item[\code{coefficients}] (unless \code{do.coef} is false) a matrix whose
i-th row contains the change in the estimated coefficients which
results when the i-th case is dropped from the regression.  Note
that aliased coefficients are not included in the matrix.
\item[\code{sigma}] a vector whose i-th element contains the estimate
of the residual standard deviation obtained when the i-th
case is dropped from the regression.
\item[\code{wt.res}] a vector of \emph{weighted} (or for class \code{glm}
rather \emph{deviance}) residuals.
\end{ldescription}
\end{Value}
\begin{Note}\relax
The \code{coefficients} returned by the \R{} version
of \code{lm.influence} differ from those computed by S.
Rather than returning the coefficients which result
from dropping each case, we return the changes in the coefficients.
This is more directly useful in many diagnostic measures.\\
Since these need \eqn{O(n^2 p)}{} computing time, they can be omitted by
\code{do.coef = FALSE}.

Note that cases with \code{weights == 0} are \emph{dropped} (contrary
to the situation in S).

If a model has been fitted with \code{na.action=na.exclude} (see
\code{\Link{na.exclude}}), cases excluded in the fit \emph{are}
considered here.\end{Note}
\begin{References}\relax
See the list in the documentation for \code{\Link{influence.measures}}.

Chambers, J. M. (1992)
\emph{Linear models.}
Chapter 4 of \emph{Statistical Models in S}
eds J. M. Chambers and T. J. Hastie, Wadsworth \& Brooks/Cole.\end{References}
\begin{SeeAlso}\relax
\code{\Link{summary.lm}} for \code{\Link{summary}} and related methods;\\
\code{\Link{influence.measures}},\\
\code{\Link{hat}} for the hat matrix diagonals,\\
\code{\Link{dfbetas}},
\code{\Link{dffits}},
\code{\Link{covratio}},
\code{\Link{cooks.distance}},
\code{\Link{lm}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## Analysis of the life-cycle savings data
## given in Belsley, Kuh and Welsch.
data(LifeCycleSavings)
summary(lm.SR <- lm(sr ~ pop15 + pop75 + dpi + ddpi,
                    data = LifeCycleSavings),
        corr = TRUE)
str(lmI <- lm.influence(lm.SR))

## For more "user level" examples, use example(influence.measures)
\end{ExampleCode}
\end{Examples}

