Learn R Programming

india (version 0.1)

cooks.distance: Cook's distances

Description

Cook's distance is a measure to assess the influence of the ith observation on the model parameter estimates. This function computes the Cook's distance based on leave-one-out cases deletion for ordinary least squares, lad and ridge regression.

Usage

# S3 method for lad
cooks.distance(model, ...)
  # S3 method for ols
cooks.distance(model, ...)
  # S3 method for ridge
cooks.distance(model, type = "cov", ...)

Value

A vector whose ith element contains the Cook's distance,

$$D_i(\bold{M},c) = \frac{(\hat{\bold{\beta}}_{(i)} - \hat{\bold{\beta}})^T\bold{M} (\hat{\bold{\beta}}_{(i)} - \hat{\bold{\beta}})}{c},$$

for \(i = 1,\dots,n\), with \(\bold{M}\) a positive definite matrix and \(c > 0\). Specific choices of \(\bold{M}\) and \(c\) are done for objects of class ols, lad and

ridge.

Arguments

model

an R object, returned by ols, lad or ridge.

type

only required for 'ridge' objects, options available are "1st", "cov" and "both" to obtain the Cook's distance based on Equation (2.5), (2.6) or both by Walker and Birch (1988), respectively.

...

further arguments passed to or from other methods.

References

Cook, R.D., Weisberg, S. (1980). Characterizations of an empirical influence function for detecting influential cases in regression. Technometrics 22, 495-508. tools:::Rd_expr_doi("10.1080/00401706.1980.10486199")

Cook, R.D., Weisberg, S. (1982). Residuals and Influence in Regression. Chapman and Hall, London.

Sun, R.B., Wei, B.C. (2004). On influence assessment for LAD regression. Statistics & Probability Letters 67, 97-110. tools:::Rd_expr_doi("10.1016/j.spl.2003.08.018").

Walker, E., Birch, J.B. (1988). Influence measures in ridge regression. Technometrics 30, 221-227. tools:::Rd_expr_doi("10.1080/00401706.1988.10488370")

Examples

Run this code
# Cook's distances for linear regression
fm <- ols(stack.loss ~ ., data = stackloss)
CD <- cooks.distance(fm)
plot(CD, ylab = "Cook's distances", ylim = c(0,0.8))
text(21, CD[21], label = as.character(21), pos = 3)

# Cook's distances for LAD regression
fm <- lad(stack.loss ~ ., data = stackloss)
CD <- cooks.distance(fm)
plot(CD, ylab = "Cook's distances", ylim = c(0,0.4))
text(17, CD[17], label = as.character(17), pos = 3)

# Cook's distances for ridge regression
data(portland)
fm <- ridge(y ~ ., data = portland)
CD <- cooks.distance(fm)
plot(CD, ylab = "Cook's distances", ylim = c(0,0.5))
text(8, CD[8], label = as.character(8), pos = 3)

Run the code above in your browser using DataLab