logreg {rIsing} | R Documentation |
L1 Regularized logistic regression using OWL-QN L-BFGS-B optimization.
logreg(X, y, nlambda = 50, lambda.min.ratio = 0.001, lambda = NULL, scale = TRUE, type = 2)
X |
The design matrix. |
y |
Vector of binary observations of length equal to |
nlambda |
(positive integer) The number of parameters in the regularization path (default 50). |
lambda.min.ratio |
(non-negative double) The ratio of |
lambda |
A user-supplied vector of regularization parameters. Under the default option ( |
scale |
(boolean) Whether to scale |
type |
(integer 1 or 2) Type 1 aggregates the input data based on repeated rows in |
A list containing the matrix of fitted weights (wmat
), the vector of regularization parameters, sorted in decreasing order (lambda
), and the vector of log-likelihoods corresponding to lambda
(logliks
).
# simulate some linear regression data n <- 1e3 p <- 100 X <- matrix(rnorm(n*p),n,p) wt <- sample(seq(0,9),p+1,replace = TRUE) / 10 z <- cbind(1,X) %*% wt + rnorm(n) probs <- 1 / (1 + exp(-z)) y <- sapply(probs, function(p) rbinom(1,1,p)) m1 <- logreg(X, y) m2 <- logreg(X, y, nlambda = 100, lambda.min.ratio = 1e-4, type = 1) ## Not run: # Performance comparison library(glmnet) library(microbenchmark) nlambda = 50; lambda.min.ratio = 1e-3 microbenchmark( logreg_type1 = logreg(X, y, nlambda = nlambda, lambda.min.ratio = lambda.min.ratio, type = 1), logreg_type2 = logreg(X, y, nlambda = nlambda, lambda.min.ratio = lambda.min.ratio, type = 2), glmnet = glmnet(X, y, family = "binomial", nlambda = nlambda, lambda.min.ratio = lambda.min.ratio), times = 20L ) ## End(Not run)