extended.ridge: A custom wrapper for base function glmnet::glmnet(alpha=0).

View source: R/regression.R

extended.ridgeR Documentation

A custom wrapper for base function glmnet::glmnet(alpha=0).

Description

This function takes a matrix of candidate predictors X and a vector of response variables Y and performs ridge regression.

Usage

extended.ridge(X, Y, lambda = NULL, ytype = "continuous")

Arguments

X

an n by p matrix of candidate predictors.

Y

an n by 1 vector of responses

lambda

an optional lambda value. If no lambda is provided, an optimal lambda is automatically determined using glmnet::cv.glmnet(alpha=0).

ytype

description as to whether or not the response variable y is binary or continuous. Defaults to 'continuous'.

Examples

n <- 200      
p <- 500
s <- 10
beta <- rep(0, p)
beta[1:s] <- runif(s, 1/3, 1)
x <- rmvnorm(n = n, mean = rep(0, p), method = "svd")
signal <- sqrt(mean((x %*% beta)^2))
sigma <- as.numeric(signal / sqrt(10))  # SNR=10
y <- x %*% beta + rnorm(n)
extended.ridge(x,y)

snelson89/extendedglmnetGroup7 documentation built on May 12, 2022, 7:38 p.m.