Last chance! 50% off unlimited learning
Sale ends in
Computes various residuals and measures of influence for a
fit from ols
.
# S3 method for ols
residuals(object,
type=c("ordinary", "score", "dfbeta", "dfbetas",
"dffit", "dffits", "hat", "hscore", "influence.measures",
"studentized"), ...)
a matrix or vector, with places for observations that were originally
deleted by ols
held by NA
s
object created by ols
. Depending on type
, you may have had to
specify x=TRUE
to ols
.
type of residual desired. "ordinary"
refers to the usual residual.
"score"
is the matrix of score residuals (contributions to first
derivative of log likelihood).
dfbeta
and dfbetas
mean respectively the raw and normalized matrix of changes in regression coefficients after
deleting in turn each observation. The coefficients are normalized by their
standard errors. hat
contains the leverages --- diagonals of the ``hat'' matrix.
dffit
and dffits
contain respectively the difference and normalized
difference in predicted values when each observation is omitted.
The S lm.influence
function is used. When type="hscore"
, the
ordinary residuals are divided by one minus the corresponding hat
matrix diagonal element to make residuals have equal variance. When
type="influence.measures"
the model is converted to an
lm
model and influence.measures(object)$infmat
is
returned. This is a matrix with dfbetas for all predictors, dffit,
cov.r, Cook's d, and hat. For type="studentized"
studentized leave-out-one residuals are computed.
See the help file for influence.measures
for more details.
ignored
Frank Harrell
Department of Biostatistics
Vanderbilt University
fh@fharrell.com
lm.influence
, ols
,
which.influence
set.seed(1)
x1 <- rnorm(100)
x2 <- rnorm(100)
x1[1] <- 100
y <- x1 + x2 + rnorm(100)
f <- ols(y ~ x1 + x2, x=TRUE, y=TRUE)
resid(f, "dfbetas")
which.influence(f)
i <- resid(f, 'influence.measures') # dfbeta, dffit, etc.
Run the code above in your browser using DataLab