alpha
= 1) or elastic net (0 < alpha
< 1). The outcome (y
) may be continuous or binary.
relaxnet(x, y, family = c("gaussian", "binomial"), nlambda = 100, alpha = 1, relax = TRUE, relax.nlambda = 100, relax.max.vars = min(nrow(x), ncol(x)) * 0.8, lambda = NULL, relax.lambda.index = NULL, relax.lambda.list = NULL, ...)
"sparseMatrix"
as in package Matrix
). Must have unique colnames.
family="gaussian"
. For family="binomial"
should be either a factor with two levels, or a two-column matrix of counts or proportions.
lambda
values - default is 100. Determines how fine the grid of lambda values should be.
glmnet
).
ncol(x)
> nrow(x)
and alpha
< 1, it may make sense to use a value > nrow(x)
, but this may lead to increased computation time.
glmnet
). Optional and meant primarily for use by cv.relaxnet
.
cv.relaxnet
. Ignored if lambda argument is NULL
.
cv.relaxnet
. Ignored if lambda argument is NULL
.
standardize = FALSE
will probably work correctly, but setting an offset probably won't.
glmnet
on the entire x
matrix.
FALSE
, then several of the other elements of this result will be set to NA
.
glmnet
fits gotten by running glmnet
on the distinct subsets of the columns of x
resulting along the solution path of lambda values.
relax.fit.times
records times for these removed models as well. This logical vector shows which of the models whose timings are given in relax.fit.times
were actually kept and have results given in relax.glmnet.fits
above. Hopefully this will not be necessary in later versions.
Jerome Friedman, Trevor Hastie, Rob Tibshirani (2010) Regularization Paths for Generalized Linear Models via Coordinate Descent. Journal of Statistical Software 33(1)
Nicolai Meinshausen (2007) Relaxed Lasso Computational Statistics and Data Analysis 52(1), 374-393
glmnet
, cv.relaxnet
, predict.relaxnet
## generate predictor matrix
nobs <- 100
nvars <- 200
set.seed(23)
x <- matrix(rnorm(nobs * nvars), nobs, nvars)
## make sure it has unique colnames
colnames(x) <- paste("x", 1:ncol(x), sep = "")
## let y depend on first 5 columns plus noise
y <- rowSums(x[, 1:5]) + rnorm(nrow(x))
## default is family = "gaussian"
result1 <- relaxnet(x, y)
summary(result1)
## now fit family = "binomial" model
y.bin <- rbinom(nrow(x), 1, prob = plogis(0.2 * rowSums(x[, 1:5])))
result2 <- relaxnet(x, y.bin, family = "binomial")
summary(result2)
Run the code above in your browser using DataLab