| weighted.residuals {stats} | R Documentation |
Compute Weighted Residuals
Description
Computed weighted residuals from a model fit.
Usage
weighted.residuals(obj, drop0 = TRUE)
Arguments
obj |
|
drop0 |
logical. If |
Details
Weighted residuals are based on the working residuals and working weights, which for
a lm fit are the raw residuals R_i
multiplied by \sqrt{w_i}, where w_i are the
weights as specified in lm's call.
For other models, including glm fits, weights and
residuals are taken from the last iteration of the approximating
weighted linear model fit. Notice that it is assumed that
residuals() and weights() methods for obj accept
type="working".
Dropping cases with weights zero is compatible with
influence and related functions.
Value
Numeric vector of length n', where n' is the number
of non-0 weights (drop0 = TRUE) or the number of
observations, otherwise.
Note
Until R version 4.5, this returned deviance residuals, which are
identical for lm fits, but differ for other models and are
not well suited for influence measures.
See Also
residuals, lm.influence, etc.
Examples
## following on from 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)