| sparsegl | R Documentation |
Fits regularization paths for sparse group-lasso penalized learning problems at a
sequence of regularization parameters lambda.
Note that the objective function for least squares is
RSS/(2n) + \lambda penalty
Users can also tweak the penalty by choosing a different penalty factor.
sparsegl(
x,
y,
group = NULL,
family = c("gaussian", "binomial"),
nlambda = 100,
lambda.factor = ifelse(nobs < nvars, 0.01, 1e-04),
lambda = NULL,
pf_group = sqrt(bs),
pf_sparse = rep(1, nvars),
intercept = TRUE,
asparse = 0.05,
standardize = TRUE,
lower_bnd = -Inf,
upper_bnd = Inf,
weights = NULL,
offset = NULL,
warm = NULL,
trace_it = 0,
dfmax = as.integer(max(group)) + 1L,
pmax = min(dfmax * 1.2, as.integer(max(group))),
eps = 1e-08,
maxit = 3e+06
)
x |
Double. A matrix of predictors, of dimension
|
y |
Double/Integer/Factor. The response variable.
Quantitative for |
group |
Integer. A vector of consecutive integers describing the grouping of the coefficients (see example below). |
family |
Character or function. Specifies the generalized linear model to use. Valid options are:
For any other type, a valid |
nlambda |
The number of |
lambda.factor |
A multiplicative factor for the minimal lambda in the
|
lambda |
A user supplied |
pf_group |
Penalty factor on the groups, a vector of the same
length as the total number of groups. Separate penalty weights can be applied
to each group of |
pf_sparse |
Penalty factor on l1-norm, a vector the same length as the
total number of columns in |
intercept |
Whether to include intercept in the model. Default is TRUE. |
asparse |
The relative weight to put on the |
standardize |
Logical flag for variable standardization (scaling) prior to fitting the model. Default is TRUE. |
lower_bnd |
Lower bound for coefficient values, a vector in length of 1
or of length the number of groups. Must be non-positive numbers only.
Default value for each entry is |
upper_bnd |
Upper for coefficient values, a vector in length of 1
or of length the number of groups. Must be non-negative numbers only.
Default value for each entry is |
weights |
Double vector. Optional observation weights. These can
only be used with a |
offset |
Double vector. Optional offset (constant predictor without a
corresponding coefficient). These can only be used with a
|
warm |
List created with |
trace_it |
Scalar integer. Larger values print more output during
the irls loop. Typical values are |
dfmax |
Limit the maximum number of groups in the model. Default is no limit. |
pmax |
Limit the maximum number of groups ever to be nonzero. For example once a group enters the model, no matter how many times it exits or re-enters model through the path, it will be counted only once. |
eps |
Convergence termination tolerance. Defaults value is |
maxit |
Maximum number of outer-loop iterations allowed at fixed lambda
value. Default is |
An object with S3 class "sparsegl". Among the list components:
call The call that produced this object.
b0 Intercept sequence of length length(lambda).
beta A p x length(lambda) sparse matrix of coefficients.
df The number of features with nonzero coefficients for each value of
lambda.
dim Dimension of coefficient matrix.
lambda The actual sequence of lambda values used.
npasses Total number of iterations summed over all lambda values.
jerr Error flag, for warnings and errors, 0 if no error.
group A vector of consecutive integers describing the grouping of the
coefficients.
nobs The number of observations used to estimate the model.
If sparsegl() was called with a stats::family() method, this may also
contain information about the deviance and the family used in fitting.
Liang, X., Cohen, A., Sólon Heinsfeld, A., Pestilli, F., and
McDonald, D.J. 2024.
sparsegl: An R Package for Estimating Sparse Group Lasso.
Journal of Statistical Software, Vol. 110(6): 1–23.
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v110.i06")}.
cv.sparsegl() and the plot(),
predict(), and coef()
methods for "sparsegl" objects.
n <- 100
p <- 20
X <- matrix(rnorm(n * p), nrow = n)
eps <- rnorm(n)
beta_star <- c(rep(5, 5), c(5, -5, 2, 0, 0), rep(-5, 5), rep(0, (p - 15)))
y <- X %*% beta_star + eps
groups <- rep(1:(p / 5), each = 5)
fit <- sparsegl(X, y, group = groups)
yp <- rpois(n, abs(X %*% beta_star))
fit_pois <- sparsegl(X, yp, group = groups, family = poisson())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.