| Title: | Regularized Parametric Modal Regression: Lasso, Elastic Net and Ridge |
|---|---|
| Description: | Variable selection and estimation for parametric modal regression with continuous positive responses (Gamma, Weibull and Lognormal families) under Lasso, elastic-net, ridge and adaptive-Lasso penalties. The conditional mode is linked to a linear predictor through a logarithmic link using the mode reparameterization of Galarza and Lachos (2026) <doi:10.48550/arXiv.2603.07099>. The penalized log-likelihood is maximized with a proximal Newton algorithm (iteratively reweighted penalized least squares): at each iteration the modal log-likelihood is replaced by a local quadratic surrogate in the linear predictor, which yields a pseudo-response and a working weight in closed form, and the resulting weighted penalized least-squares subproblem is solved by the coordinate-descent solver of 'glmnet' (Friedman, Hastie and Tibshirani, 2010, <doi:10.18637/jss.v033.i01>). The regularization parameter is chosen along a warm-started path by the extended Bayesian information criterion of Chen and Chen (2008) <doi:10.1093/biomet/asn034>. |
| Authors: | Christian E. Galarza [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-4818-6006>, affiliation: Escuela Superior Politécnica del Litoral, Guayaquil, Ecuador), Víctor H. Lachos [aut] (ORCID: <https://orcid.org/0000-0002-7239-2459>, affiliation: University of Connecticut, Storrs, CT, USA), Dashun Liu [aut] (affiliation: University of Connecticut, Storrs, CT, USA) |
| Maintainer: | Christian E. Galarza <[email protected]> |
| License: | GPL-3 |
| Version: | 0.3.0 |
| Built: | 2026-11-05 01:22:48 UTC |
| Source: | https://github.com/chedgala/modalnet |
Generates positive responses whose conditional mode is
under the Gamma, Weibull or
Lognormal mode reparameterization used by modal_net.
generate_modal_data(X, gamma, phi, family = c("gamma", "weibull", "lognormal"))generate_modal_data(X, gamma, phi, family = c("gamma", "weibull", "lognormal"))
X |
covariate matrix without intercept. |
gamma |
coefficient vector of length |
phi |
dispersion parameter. |
family |
one of |
A list with y, mode and mean.
X <- matrix(rnorm(100 * 5), 100, 5) d <- generate_modal_data(X, c(1, 0.5, -0.5, 0, 0, 0), phi = 0.3, family = "weibull") str(d)X <- matrix(rnorm(100 * 5), 100, 5) d <- generate_modal_data(X, c(1, 0.5, -0.5, 0, 0, 0), phi = 0.3, family = "weibull") str(d)
Fits the modal regression model ,
where is the conditional mode of a positive response, by
maximizing the penalized log-likelihood
with the Lasso, elastic-net, ridge or adaptive-Lasso penalty on
the slopes (the intercept is never penalized). The Gamma, Weibull and Lognormal
families are available, each written in terms of its mode through the
reparameterization of Galarza and Lachos (2026).
modal_net( y, X, family = c("gamma", "weibull", "lognormal"), lambda = NULL, nlambda = 50, lambda.min.ratio = NULL, alpha = 1, penalty.factor = NULL, gamma_ebic = 0.5, dfmax = NULL, line_search = TRUE, standardize = TRUE, tol = 1e-06, maxit = 200, verbose = FALSE )modal_net( y, X, family = c("gamma", "weibull", "lognormal"), lambda = NULL, nlambda = 50, lambda.min.ratio = NULL, alpha = 1, penalty.factor = NULL, gamma_ebic = 0.5, dfmax = NULL, line_search = TRUE, standardize = TRUE, tol = 1e-06, maxit = 200, verbose = FALSE )
y |
numeric vector of positive responses. |
X |
numeric matrix (or data frame) of covariates, |
family |
one of |
lambda |
optional user-supplied decreasing sequence of penalty values.
If |
nlambda |
length of the automatic grid. |
lambda.min.ratio |
smallest grid value as a fraction of the largest;
default |
alpha |
elastic-net mixing parameter passed to glmnet:
|
penalty.factor |
optional vector of length |
gamma_ebic |
the EBIC constant |
dfmax |
the path stops once more than |
line_search |
logical; use the backtracking safeguard
|
standardize |
passed to glmnet; standardize the columns of
|
tol |
relative tolerance on the penalized objective. |
maxit |
maximum number of proximal Newton iterations per grid point. |
verbose |
logical; report progress along the path through
|
The estimator is computed by a proximal Newton algorithm, equivalently
an iteratively reweighted penalized least-squares (IRPLS) scheme. At each
iteration the modal log-likelihood is replaced by its second-order expansion
in the linear predictor , which yields a pseudo-response
and a working weight in closed form:
Gamma: , ;
Weibull: , ;
Lognormal: , (the surrogate is exact).
The update of is then the weighted penalized least-squares
problem ,
solved exactly by the cyclical coordinate descent of glmnet with
observation weights, so that variable selection is performed by the
optimizer itself (exact zeros, no thresholding). An optional backtracking
line search keeps the penalized objective monotone. The dispersion
is then updated by maximizing the profile log-likelihood (closed
form for the Lognormal family, one-dimensional optimization otherwise).
The regularization parameter is chosen by path following: a decreasing grid
is built once from the initial
pseudo-response, the algorithm is run to convergence at each grid point with
a warm start at the previous solution, and the extended BIC
is evaluated across the converged fits. The initialization uses a lightly
penalized Gaussian Lasso of on , which stays well
defined when .
The penalty is
on the standardized columns ( given by penalty.factor), and
is expressed on the scale used by glmnet, whose weights
are rescaled to sum to . For the Lasso this makes the Lognormal fit at
penalty coincide with the Gaussian Lasso of at
the same (slopes identical, intercepts differing by
exactly ). For alpha < 1, glmnet divides its ridge
term by the standard deviation of the response it receives; the inner call
compensates for this, so the penalty above holds exactly for every
alpha.
An object of class "ModalNet", a list with components
gamma |
estimated coefficients (intercept first) at the EBIC-selected
|
phi |
estimated dispersion at the selected |
selected |
indices of the selected (nonzero) covariates. |
lambda |
selected penalty. |
loglik, ebic, df
|
values at the selected penalty. |
path |
list with the whole path: |
fitted.mode |
fitted conditional modes |
mean_const |
the constant |
boundary |
|
plus family, n, p, gamma_ebic, call.
Galarza, C. E. and Lachos, V. H. (2026). A proximal Newton algorithm for penalized modal regression with high-dimensional positive responses.
Galarza, C. E. and Lachos, V. H. (2026). Parametric modal regression for right-censored positive responses. arXiv preprint doi:10.48550/arXiv.2603.07099.
Friedman, J., Hastie, T. and Tibshirani, R. (2010). Regularization paths for generalized linear models via coordinate descent. Journal of Statistical Software, 33(1), 1–22. doi:10.18637/jss.v033.i01.
Chen, J. and Chen, Z. (2008). Extended Bayesian information criteria for model selection with large model spaces. Biometrika, 95, 759–771. doi:10.1093/biomet/asn034.
set.seed(1) n <- 200; p <- 30 X <- matrix(rnorm(n * p), n, p) gamma_true <- c(1, 0.6, -0.5, 0.4, rep(0, p - 3)) dat <- generate_modal_data(X, gamma_true, phi = 0.3, family = "gamma") fit <- modal_net(dat$y, X, family = "gamma") fit summary(fit) plot(fit)set.seed(1) n <- 200; p <- 30 X <- matrix(rnorm(n * p), n, p) gamma_true <- c(1, 0.6, -0.5, 0.4, rep(0, p - 3)) dat <- generate_modal_data(X, gamma_true, phi = 0.3, family = "gamma") fit <- modal_net(dat$y, X, family = "gamma") fit summary(fit) plot(fit)
Print, summarize and extract the components of a model fitted by
modal_net.
## S3 method for class 'ModalNet' print(x, digits = 4, ...) ## S3 method for class 'ModalNet' summary(object, digits = 4, ...) ## S3 method for class 'summary.ModalNet' print(x, digits = 4, ...) ## S3 method for class 'ModalNet' coef(object, s = NULL, ...) ## S3 method for class 'ModalNet' fitted(object, ...) ## S3 method for class 'ModalNet' logLik(object, ...)## S3 method for class 'ModalNet' print(x, digits = 4, ...) ## S3 method for class 'ModalNet' summary(object, digits = 4, ...) ## S3 method for class 'summary.ModalNet' print(x, digits = 4, ...) ## S3 method for class 'ModalNet' coef(object, s = NULL, ...) ## S3 method for class 'ModalNet' fitted(object, ...) ## S3 method for class 'ModalNet' logLik(object, ...)
x, object
|
a |
digits |
number of decimal places to print. |
... |
unused. |
s |
optional penalty value; |
print.ModalNet and print.summary.ModalNet return their
argument invisibly.
summary.ModalNet returns an object of class "summary.ModalNet",
a list with the coefficient table of the selected covariates (estimates on
the log-mode scale and their exponentials), the dispersion, the selected
penalty, the log-likelihood, EBIC and degrees of freedom, the names of the
selected covariates, the mode-mean constant with the
implied mean-scale intercept, and a data frame summarizing the path.
coef.ModalNet returns the named coefficient vector (intercept first),
fitted.ModalNet the fitted conditional modes, and
logLik.ModalNet an object of class "logLik".
set.seed(2) X <- matrix(rnorm(150 * 10), 150, 10) dat <- generate_modal_data(X, c(0.5, 0.8, -0.6, rep(0, 8)), phi = 0.2, family = "weibull") fit <- modal_net(dat$y, X, family = "weibull") print(fit) s <- summary(fit) s$coefficients coef(fit) head(fitted(fit)) logLik(fit)set.seed(2) X <- matrix(rnorm(150 * 10), 150, 10) dat <- generate_modal_data(X, c(0.5, 0.8, -0.6, rep(0, 8)), phi = 0.2, family = "weibull") fit <- modal_net(dat$y, X, family = "weibull") print(fit) s <- summary(fit) s$coefficients coef(fit) head(fitted(fit)) logLik(fit)
Plot the EBIC curve and the coefficient path of a ModalNet fit
## S3 method for class 'ModalNet' plot(x, which = c(1, 2), ...)## S3 method for class 'ModalNet' plot(x, which = c(1, 2), ...)
x |
a |
which |
|
... |
further graphical arguments (ignored). |
The "ModalNet" object, invisibly. Called for its side effect:
the EBIC against , with the selected value marked, and
the coefficient paths on the log-mode scale.
set.seed(4) X <- matrix(rnorm(150 * 10), 150, 10) dat <- generate_modal_data(X, c(1, 0.6, -0.4, rep(0, 8)), phi = 0.3, family = "lognormal") fit <- modal_net(dat$y, X, family = "lognormal") plot(fit) plot(fit, which = 2)set.seed(4) X <- matrix(rnorm(150 * 10), 150, 10) dat <- generate_modal_data(X, c(1, 0.6, -0.4, rep(0, 8)), phi = 0.3, family = "lognormal") fit <- modal_net(dat$y, X, family = "lognormal") plot(fit) plot(fit, which = 2)
Predict conditional modes (or means) from a fitted ModalNet model
## S3 method for class 'ModalNet' predict(object, newdata, type = c("mode", "link", "mean"), ...)## S3 method for class 'ModalNet' predict(object, newdata, type = c("mode", "link", "mean"), ...)
object |
a |
newdata |
covariate matrix with the same columns as the training
|
type |
|
... |
unused. |
A numeric vector with one prediction per row of newdata
(or of the training matrix), on the scale chosen by type.
set.seed(3) X <- matrix(rnorm(120 * 8), 120, 8) dat <- generate_modal_data(X, c(1, 0.7, -0.5, rep(0, 6)), phi = 0.3, family = "gamma") fit <- modal_net(dat$y[1:100], X[1:100, ], family = "gamma") new <- X[101:120, ] cbind(mode = predict(fit, new), mean = predict(fit, new, type = "mean"))[1:5, ]set.seed(3) X <- matrix(rnorm(120 * 8), 120, 8) dat <- generate_modal_data(X, c(1, 0.7, -0.5, rep(0, 6)), phi = 0.3, family = "gamma") fit <- modal_net(dat$y[1:100], X[1:100, ], family = "gamma") new <- X[101:120, ] cbind(mode = predict(fit, new), mean = predict(fit, new, type = "mean"))[1:5, ]
Riboflavin (vitamin B2) production rate of Bacillus subtilis together
with the expression levels of the 100 genes with the largest empirical
variance, for fermentation runs. This is the
riboflavinV100 subset used by Schelldorfer et al. (2011) and in
Galarza and Lachos (2026), derived from the riboflavin data of
Bühlmann, Kalisch and Meier (2014) distributed with the hdi package.
riboflavinV100riboflavinV100
A list with two components:
ynumeric vector of length 71: riboflavin production rate on
the original (positive) scale, obtained as exp() of the
log-production rate of the hdi data.
xnumeric matrix of log gene expression
levels (column names are the gene identifiers).
The 71 runs are repeated measurements on 28 strains; the analyses
in the literature, and the one in the package examples, treat them as
independent. The model is scale equivariant, so y may be rescaled
(for instance divided by its mean) for numerical convenience without
changing the selected set or the slopes.
Bühlmann, P., Kalisch, M. and Meier, L. (2014). High-dimensional statistics with a view towards applications in biology. Annual Review of Statistics and Its Application, 1, 255–278. doi:10.1146/annurev-statistics-022513-115545. Data from the R package hdi (GPL).
Schelldorfer, J., Bühlmann, P. and van de Geer, S. (2011). Estimation for high-dimensional linear mixed-effects models using L1-penalization. Scandinavian Journal of Statistics, 38, 197–214. doi:10.1111/j.1467-9469.2011.00740.x.
data(riboflavinV100) y <- riboflavinV100$y / mean(riboflavinV100$y) fit <- modal_net(y, riboflavinV100$x, family = "gamma") colnames(riboflavinV100$x)[fit$selected]data(riboflavinV100) y <- riboflavinV100$y / mean(riboflavinV100$y) fit <- modal_net(y, riboflavinV100$x, family = "gamma") colnames(riboflavinV100$x)[fit$selected]