logistic_enet: Compute the elastic net estimator for logistic regression

View source: R/RcppExports.R

logistic_enetR Documentation

Compute the elastic net estimator for logistic regression

Description

Compute the elastic net estimator for logistic regression

Usage

logistic_enet(Yr, Xr, lambda, gammar, theta, tol)

Arguments

Yr

Response vector of 1s and 0s

Xr

A design matrix with the first column a column of 1s

lambda

The tuning parameter governing the strength of the elastic net penalty

gammar

A vector of length ncol(X) - 1 giving the weights applied to each covariate in the elastic net penalization

theta

Value controlling the relative strength of the ridge and lasso penalties; 1 gives lasso.

tol

Convergence tolerance

Value

a list with the estimated coefficients, etc.

Examples

# generate some data
n <- 5000
p <- 40
b <- c(0,3,0,1,-2,0,rep(0,p-5)) # first is intercept
X <- cbind(rep(1,n),scale(matrix(rnorm(n*p),nrow=n),TRUE,TRUE))
eta <- X %*% b
Y <- rbinom(n,1,1/(1 + exp(-eta)))

# compute elastic net estimator  
logistic_enet(Y, X, lambda = 30, gammar = rep(1,p), theta = 0.5, tol = 0.0001)$b

gregorkb/aenetgt documentation built on Oct. 12, 2022, 11:51 a.m.