leverages {india}R Documentation

Leverages

Description

Computes leverage measures from a fitted model object.

Usage

leverages(model, ...)
## S3 method for class 'lm'
leverages(model, infl = lm.influence(model, do.coef = FALSE), ...)
## S3 method for class 'nls'
leverages(model, ...)
## S3 method for class 'ols'
leverages(model, ...)
## S3 method for class 'ridge'
leverages(model, ...)

## S3 method for class 'nls'
hatvalues(model, ...)
## S3 method for class 'ols'
hatvalues(model, ...)
## S3 method for class 'ridge'
hatvalues(model, ...)

Arguments

model

an R object, returned by lm, nls, ols or ridge.

infl

influence structure as returned by lm.influence.

...

further arguments passed to or from other methods.

Value

A vector containing the diagonal of the prediction (or ‘hat’) matrix.

For linear regression (i.e., for "lm" or "ols" objects) the prediction matrix assumes the form

\bold{H} = \bold{X}(\bold{X}^T\bold{X})^{-1}\bold{X}^T,

in which case, h_{ii} = \bold{x}_i^T(\bold{X}^T\bold{X})^{-1}\bold{x}_i for i=1,\dots,n. Whereas for ridge regression, the prediction matrix is given by

\bold{H}(\lambda) = \bold{X}(\bold{X}^T\bold{X} + \lambda\bold{I})^{-1}\bold{X}^T,

where \lambda represents the ridge parameter. Thus, the diagonal elements of \bold{H}(\lambda), are h_{ii}(\lambda) = \bold{x}_i^T(\bold{X}^T\bold{X} + \lambda\bm{I})^{-1}\bold{x}_i, i=1,\dots,n.

In nonlinear regression, the tangent plane leverage matrix is given by

\hat{\bold{H}} = \hat{\bold{F}}(\hat{\bold{F}}^T\hat{\bold{F}})^{-1}\hat{\bold{F}}^T,

where \bold{F} = \bold{F}(\bold{\beta}) is the n\times p local model matrix with ith row \partial f_i(\bold{\beta})/\partial\bold{\beta} and \hat{\bold{F}} = \bold{F}(\hat{\bold{\beta}}).

Note

This function never creates the prediction matrix and only obtains its diagonal elements from the singular value decomposition of \bold{X} or \hat{\bold{F}}.

Function hatvalues only is a wrapper for function leverages.

References

Chatterjee, S., Hadi, A.S. (1988). Sensivity Analysis in Linear Regression. Wiley, New York.

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

Ross, W.H. (1987). The geometry of case deletion and the assessment of influence in nonlinear regression. The Canadian Journal of Statistics 15, 91-103. doi:10.2307/3315198

St. Laurent, R.T., Cook, R.D. (1992). Leverage and superleverage in nonlinear regression. Journal of the Amercian Statistical Association 87, 985-990. doi:10.1080/01621459.1992.10476253

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

Examples

# Leverages for linear regression
fm <- ols(stack.loss ~ ., data = stackloss)
lev <- leverages(fm)
cutoff <- 2 * mean(lev)
plot(lev, ylab = "Leverages", ylim = c(0,0.45))
abline(h = cutoff, lty = 2, lwd = 2, col = "red")
text(17, lev[17], label = as.character(17), pos = 3)

# Leverages for ridge regression
data(portland)
fm <- ridge(y ~ ., data = portland)
lev <- leverages(fm)
cutoff <- 2 * mean(lev)
plot(lev, ylab = "Leverages", ylim = c(0,0.7))
abline(h = cutoff, lty = 2, lwd = 2, col = "red")
text(10, lev[10], label = as.character(10), pos = 3)

# Leverages for nonlinear regression
data(skeena)
model <- recruits ~ b1 * spawners * exp(-b2 * spawners)
fm <- nls(model, data = skeena, start = list(b1 = 3, b2 = 0))
lev <- leverages(fm)
plot(lev, ylab = "Leverages", ylim = c(0,0.25))
obs <- c(1,9)
text(obs, lev[obs], label = as.character(obs), pos = 3)

[Package india version 0.1-1 Index]