\Header{weighted.residuals}{Compute 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{\Link{lm}} or \code{\Link{glm}}.
\item[\code{drop0}] logical.  If \code{TRUE}, drop all cases with
\code{\Link{weights} == 0}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Weighted residuals are the usual 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{\Link{lm}}'s call.

Dropping cases with weights zero is compatible with
\code{\Link{lm.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{\Link{residuals}},\code{\Link{lm.influence}}, etc.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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}

