ridge: Ridge regression

View source: R/ridge.R

ridgeR Documentation

Ridge regression

Description

Ridge regression

Usage

ridge(obj, ...)

## S3 method for class 'formula'
ridge(obj, data, subset, na.action, contrasts = NULL, ...)

## S3 method for class 'matrix'
ridge(obj, y, lambda, ...)

## S3 method for class 'ridge'
coef(
  object,
  lambda,
  which = 1:length(object$lambda),
  standardize = FALSE,
  drop = TRUE,
  ...
)

## S3 method for class 'ridge'
summary(object, lambda, which, ...)

## S3 method for class 'ridge'
predict(object, X, lambda, which = 1:length(object$lambda), drop = TRUE, ...)

## S3 method for class 'ridge'
confint(object, parm, level = 0.95, X, lambda, which, ...)

Arguments

obj

There are two options for running ridge(); either supply a formula and data frame as in lm(), or an X and y matrix as in glmnet(); see examples

...

Additional arguments to be passed to methods

data

If using the formula interface, a data.frame/list/environment containing the variables in the formula

subset

If using the formula interface, a vector describing the subset of the data to be used in fitting the model

na.action

If using the formula interface, a function indicating what should happen when the data contain NAs, as in lm()

contrasts

If using the formula interface, a list to be passed to model.matrix()

y

If using the matrix interface, the vector of responses

lambda

An optional value or vector of values for the regression coefficient; if not supplied, this will be set up automatically

object

A ridge object, as returned by ridge()

which

Indices of lambda at which coefficients / predictions are required. By default, all indices are returned. If lambda is specified, this will override which.

standardize

Return coefficients on standardized scale (default: FALSE)

drop

If requesting coefficients for a single lambda value, drop matrix down to a vector (default: TRUE)

X

Matrix of predictor values at which predictions are required.

parm

Which parameters to construct confidence intervals for; either a vector of indices or a vector of names (default: all)

level

Confidence level (default: 0.95)

See Also

plot.ridge(), coef.ridge(), predict.ridge(), summary.ridge(), confint.ridge()

Examples

attachData(pollution)
fit <- ridge(X, y)
summary(fit, lambda=0.1)
plot(fit)
plot(fit, xaxis='df')
plot(fit, xaxis='both')
plot(fit, standardize=TRUE)
coef(fit)
coef(fit, standardize=TRUE)
coef(fit, standardize=TRUE, lambda=0.1)
p1 <- cbind(1, std(X)) %*% coef(fit, standardize=TRUE, lambda=1)
p2 <- cbind(1, X) %*% coef(fit, lambda=1)
head(p1); head(p2) # identical

pbreheny/hdrm documentation built on Jan. 17, 2024, 8:53 p.m.