ridge: Ridge Regression Estimates

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/ridge.R

Description

The function ridge fits linear models by ridge regression, returning an object of class ridge designed to be used with the plotting methods in this package.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
ridge(y, ...)

## Default S3 method:
ridge(y, X, lambda = 0, df, svd = TRUE, ...)

## S3 method for class 'formula'
ridge(formula, data, lambda = 0, df, svd = TRUE, ...)

## S3 method for class 'ridge'
print(x, digits = max(5, getOption("digits") - 5), ...)

## S3 method for class 'ridge'
coef(object, ...)

## S3 method for class 'ridge'
vcov(object, ...)

Arguments

y

A numeric vector containing the response variable. NAs not allowed.

X

A matrix of predictor variables. NA's not allowed. Should not include a column of 1's for the intercept

formula

For the formula method, a two-sided formula

data

For the formula method, data frame within which to evaluate the formula

lambda

A scalar or vector of ridge constants. A value of 0 corresponds to ordinary least squares.

df

A scalar or vector of effective degrees of freedom corresponding to lambda

svd

If TRUE the SVD of the centered and scaled X matrix is returned in the ridge object.

x, object

An object of class ridge

...

Other arguments, passed down to methods

digits

For the print method, the number of digits to print.

Details

Ridge regression shrinkage can be parameterized in several ways. If a vector of lambda values is supplied, these are used directly in the ridge regression computations. Otherwise, if a vector df is supplied the equivalent values of lambda. In either case, both lambda and df are returned in the ridge object, but the rownames of the coefficients are given in terms of lambda.

Value

A list with the following components:

lambda

The vector of ridge constants

df

The vector of effective degrees of freedom corresponding to lambda

coef

The matrix of estimated ridge regression coefficients

scales

scalings used on the X matrix

kHKB

HKB estimate of the ridge constant

kLW

L-W estimate of the ridge constant

GCV

vector of GCV values

kGCV

value of lambda with the minimum GCV

If svd==TRUE, the following are also included:

svd.D

Singular values of the svd of the scaled X matrix

svd.U

Left singular vectors of the svd of the scaled X matrix. Rows correspond to observations and columns to dimensions.

svd.V

Right singular vectors of the svd of the scaled X matrix. Rows correspond to variables and columns to dimensions.

Author(s)

Michael Friendly

References

Hoerl, A. E., Kennard, R. W., and Baldwin, K. F. (1975), "Ridge Regression: Some Simulations," Communications in Statistics, 4, 105-123.

Lawless, J.F., and Wang, P. (1976), "A Simulation Study of Ridge and Other Regression Estimators," Communications in Statistics, 5, 307-323.

See Also

lm.ridge, simple.ridge for other implementations of ridge regression

traceplot, plot.ridge, pairs.ridge, plot3d.ridge, for 1D, 2D, 3D plotting methods

pca.ridge, biplot.ridge, biplot.pcaridge for views in PCA/SVD space

precision.ridge for measures of shrinkage and precision

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Longley data, using number Employed as response
longley.y <- longley[, "Employed"]
longley.X <- data.matrix(longley[, c(2:6,1)])

lambda <- c(0, 0.005, 0.01, 0.02, 0.04, 0.08)
lridge <- ridge(longley.y, longley.X, lambda=lambda)

# same, using formula interface
lridge <- ridge(Employed ~ GNP + Unemployed + Armed.Forces + Population + Year + GNP.deflator, 
		data=longley, lambda=lambda)


coef(lridge)
traceplot(lridge)
traceplot(lridge, X="df")
pairs(lridge, radius=0.5)


if (require("ElemStatLearn")) {
	py <- prostate[, "lpsa"]
	pX <- data.matrix(prostate[, 1:8])
	pridge <- ridge(py, pX, df=8:1)
	pridge
	
	plot(pridge)
	pairs(pridge)
	traceplot(pridge)
	traceplot(pridge, X="df")
}

# Hospital manpower data from Table 3.8 of Myers (1990) 
data(Manpower)
str(Manpower)

mmod <- lm(Hours ~ ., data=Manpower)
vif(mmod)
# ridge regression models, specified in terms of equivalent df
mridge <- ridge(Hours ~ ., data=Manpower, df=seq(5, 3.75, -.25))
vif(mridge)

# univariate ridge trace plots
traceplot(mridge)
traceplot(mridge, X="df")

# bivariate ridge trace plots
plot(mridge, radius=0.25, labels=mridge$df)
pairs(mridge, radius=0.25)

# 3D views
# ellipsoids for Load, Xray & BedDays are nearly 2D
plot3d(mridge, radius=0.2, labels=mridge$df)
# variables in model selected by AIC & BIC
plot3d(mridge, variables=c(2,3,5), radius=0.2, labels=mridge$df)

# plots in PCA/SVD space
mpridge <- pca.ridge(mridge)
traceplot(mpridge, X="df")
biplot(mpridge, radius=0.25)

genridge documentation built on May 2, 2019, 5:46 p.m.