Package 'ModalNet'

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

Help Index


Simulate data from a modal regression model

Description

Generates positive responses whose conditional mode is Mi=exp⁡(γ0+xi⊤γ)M_i = \exp(\gamma_0 + x_i^\top\gamma) under the Gamma, Weibull or Lognormal mode reparameterization used by modal_net.

Usage

generate_modal_data(X, gamma, phi, family = c("gamma", "weibull", "lognormal"))

Arguments

X

covariate matrix without intercept.

gamma

coefficient vector of length ncol(X) + 1 (intercept first).

phi

dispersion parameter.

family

one of "gamma", "weibull", "lognormal".

Value

A list with y, mode and mean.

Examples

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)

Methods for ModalNet fits

Description

Print, summarize and extract the components of a model fitted by modal_net.

Usage

## 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, ...)

Arguments

x, object

a "ModalNet" object (x is a "summary.ModalNet" object in print.summary.ModalNet).

digits

number of decimal places to print.

...

unused.

s

optional penalty value; coef() then returns the coefficients of the path at the grid value closest to s.

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 c(ϕ^)c(\hat\phi) 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".

Examples

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

Description

Plot the EBIC curve and the coefficient path of a ModalNet fit

Usage

## S3 method for class 'ModalNet'
plot(x, which = c(1, 2), ...)

Arguments

x

a "ModalNet" object.

which

1 for the EBIC curve, 2 for the coefficient path, c(1, 2) (default) for both side by side.

...

further graphical arguments (ignored).

Value

The "ModalNet" object, invisibly. Called for its side effect: the EBIC against log⁡λ\log\lambda, with the selected value marked, and the coefficient paths on the log-mode scale.

Examples

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

Description

Predict conditional modes (or means) from a fitted ModalNet model

Usage

## S3 method for class 'ModalNet'
predict(object, newdata, type = c("mode", "link", "mean"), ...)

Arguments

object

a "ModalNet" object.

newdata

covariate matrix with the same columns as the training X; if missing, the training matrix is used.

type

"mode" (default) returns M^\hat M, "link" the linear predictor log⁡M^\log \hat M, and "mean" the implied conditional mean c(ϕ^)M^c(\hat\phi)\hat M.

...

unused.

Value

A numeric vector with one prediction per row of newdata (or of the training matrix), on the scale chosen by type.

Examples

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 production in Bacillus subtilis (100 most variable genes)

Description

Riboflavin (vitamin B2) production rate of Bacillus subtilis together with the expression levels of the 100 genes with the largest empirical variance, for n=71n = 71 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.

Usage

riboflavinV100

Format

A list with two components:

y

numeric vector of length 71: riboflavin production rate on the original (positive) scale, obtained as exp() of the log-production rate of the hdi data.

x

numeric matrix 71×10071 \times 100 of log gene expression levels (column names are the gene identifiers).

Details

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.

Source

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).

References

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.

Examples

data(riboflavinV100)
y <- riboflavinV100$y / mean(riboflavinV100$y)
fit <- modal_net(y, riboflavinV100$x, family = "gamma")
colnames(riboflavinV100$x)[fit$selected]