Description Usage Arguments Value Examples
Fit a generalized linear model via penalized maximum likelihood. The regularization path is computed for the adaptive sparse group lasso penalty along a sequence of tuning parameter values. Supports linear and logistic regression.
1 2 3 4 |
x |
Input matrix of dimensions n by p. |
y |
Response vector of length n. For linear models
( |
index |
A vector of length p defining group membership for each covariate. |
family |
Response type. One of |
offset |
Optional. A vector of length n to be included in the linear predictor |
alpha |
Penalty mixing parameter. The penalty reduces to the adaptive
group lasso if |
lambda |
Optional. A vector of user-specified penalty tuning parameter
values at which to fit model. If |
lambda_min |
Smallest tuning parameter value, as a fraction of the largest parameter value in the sequence (the smallest value for which all coefficients are zero). |
nlambda |
The number of tuning parameter values in the sequence. |
maxit |
Maximum number of iterations until convergence |
thresh |
Convergence threshold for change in model coefficient values. |
gamma |
Backtracking parameter for use in gradient descent step |
step |
Initial gradient descent step size. |
standardize |
If |
grp_weights |
A vector of weights for each group of coefficients, the
same length as |
ind_weights |
A vector of weights for each indiviual coefficient, of length p. |
An object of class "asgl
"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # linear regression
n <- 500; p <- 20; groupsize <- 5
index <- ceiling(1:p / groupsize)
beta <- (-2:2)
x <- matrix(rnorm(n * p), ncol = p, nrow = n)
y <- as.vector(x[,1:5] %*% beta + 0.1 * rnorm(n))
asgl(x, y, index, family = "gaussian")
# logistic regression
eta <- x[, 1:5] %*% beta
prob <- exp(eta) / (1 + exp(eta))
y <- rbinom(n, 1, prob)
asgl(x, y, index, family = "binomial")
# adaptive weights
coefs <- glm.fit(x, y, family = binomial())$coefficients
ind_weights <- 1 / abs(coefs)
grp_weights <- numeric(length(unique(index)))
for (i in unique(index)) {
grp_weights[i] <- 1 / sqrt(sum(coefs[which(index == i)]^2))
}
asgl(x, y, index, family = "binomial",
grp_weights = grp_weights, ind_weights = ind_weights)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.