cooks.distance.zlm | R Documentation |
Calculates the Cook's distances (technically a divergence, i.e. distance squared) of a complex linear model. These serve as a measurement of how much each input data point had on the model.\loadmathjax
## S3 method for class 'zlm'
cooks.distance(model, lever = zhatvalues(model), ...)
model |
An object of class "lm" or "rlm". Can be complex or numeric. |
lever |
A list of leverage scores with the same length as |
... |
Other parameters. Only used if |
Consider a linear model relating a response vector y
to a predictor vector x
, both of length n
. Using the model and predictor vector we can
calculate a vector of predicted values yh
. y
and yh
are points in a n
dimensional output space. If we drop the i
-th element of x
and y
, then fit another
model using the "dropped i
" vectors, we can get another point in output space, yhi
. The squared Euclidean distance between yh
and yhi
, divided by the
rank of the model (p
) times its mean squared error s^2
, is the i
-th Cook's distance.
\mjdeqnD_i = (yh - yhi)^t (yh - yhi) / p s^2D_i = (yh - yhi)^t (yh - yhi) / p s^2
A more elegant way to calculate it, which this function uses, is with the influence scores, hii
.
\mjdeqnD_i = |r_i|^2 / p s^2 hii / (1 - hii)D_i = |r_i|^2 / p s^2 hii / (1 - hii)
Where r_i
is the i
-th residual, and ^t
is the conjugate transpose.
A numeric vector. The elements are the Cook's distances of each data point in model
.
This is a simpler function than stats::cooks.distance, and does not understand any additional parameters not listed in this entry.
R. D. Cook, Influential Observations in Linear Regression, Journal of the American Statistical Association 74, 169 (1979).
stats::cooks.distance, zhatvalues
set.seed(4242)
n <- 8
slop <- complex(real = 4.23, imaginary = 2.323)
interc <- complex(real = 1.4, imaginary = 1.804)
e <- complex(real=rnorm(n)/6, imaginary=rnorm(n)/6)
xx <- complex(real= rnorm(n), imaginary= rnorm(n))
tframe <- data.frame(x = xx, y= slop*xx + interc + e)
fit <- lm(y ~ x, data = tframe, weights = rep(1,n))
cooks.distance(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.