logistic_enet | R Documentation |
Compute the elastic net estimator for logistic regression
logistic_enet(Yr, Xr, lambda, gammar, theta, tol)
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 |
theta |
Value controlling the relative strength of the ridge and lasso penalties; 1 gives lasso. |
tol |
Convergence tolerance |
a list with the estimated coefficients, etc.
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.