\HeaderA{weighted.residuals}{Compute Weighted Residuals}{weighted.residuals}
\keyword{regression}{weighted.residuals}
\begin{Description}\relax
Computed weighted residuals from a linear model fit.
\end{Description}
\begin{Usage}
\begin{verbatim}
weighted.residuals(obj, drop0 = TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{obj}] \R{} object, typically of class \code{\LinkA{lm}{lm}} or
\code{\LinkA{glm}{glm}}.
\item[\code{drop0}] logical.  If \code{TRUE}, drop all cases with
\code{\LinkA{weights}{weights} == 0}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Weighted residuals are based on the deviance residuals, which for
a \code{\LinkA{lm}{lm}} fit are the raw residuals \eqn{R_i}{Ri}
multiplied by \eqn{\sqrt{w_i}}{wi^0.5}, where \eqn{w_i}{wi} are the
\code{weights} as specified in \code{\LinkA{lm}{lm}}'s call.

Dropping cases with weights zero is compatible with
\code{\LinkA{influence}{influence}} and related functions.
\end{Details}
\begin{Value}
Numeric vector of length \eqn{n'}{}, where \eqn{n'}{} is the number of
of non-0 weights (\code{drop0 = TRUE}) or the number of
observations, otherwise.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{residuals}{residuals}}, \code{\LinkA{lm.influence}{lm.influence}}, etc.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
utils::example("lm")
all.equal(weighted.residuals(lm.D9),
          residuals(lm.D9))
x <- 1:10
w <- 0:9
y <- rnorm(x)
weighted.residuals(lmxy <- lm(y ~ x, weights = w))
weighted.residuals(lmxy, drop0 = FALSE)
\end{ExampleCode}
\end{Examples}

