lm_ridge_beta: ridge regression (self-defined)

Description Usage Arguments Value Examples

View source: R/lm_ridge_beta.R

Description

This function is used to return ridge regression estimators.

Usage

1
lm_ridge_beta(X, Y, lambda)

Arguments

X

a design matrix containing all predictors.

Y

a response vector.

lambda

a lambda value specified, serving as the coefficient of the penalty terms.

Value

ridge regression estimators.

Examples

1
2
3
4
5
6
7
8
#If do not have a design matrix and a response vector,
#firstly turn the formula and dataset into the required matrix
mf<-model.frame(Sepal.Width~.,iris)
mt<-attr(mf,"terms")
X <- model.matrix(mt, mf)
Y <- as.matrix(model.response(mf))
#call the function
lm_ridge_beta(X,Y,10)

Jiachen1027/bis557 documentation built on Oct. 30, 2019, 7:41 p.m.