Select non-overlapping groups of predictors using adaptive ridge and a group L0 penalty. Groups can represent factor contrasts, spline coefficients, related measurements or other terms that should enter a model together.
Arguments
- group
Optional vector with one label per column of the supplied
X, excluding an automatically added intercept. Factors, integers and character labels are accepted; ordering and consecutive numbering are unnecessary. Label0or"0"identifies unpenalized terms. Intercepts andalways.includeterms remain unpenalized.NULLuses individual predictors.- group.multiplier
Optional positive penalty multipliers, one per penalized predictor group in first-appearance order, or a named vector matching the nonzero group labels. A scalar applies to every group. By default, named IC presets charge each group's coefficient dimension; a numeric
lambdacharges once per group. Returnedgroup.multipliervalues reproduce the preset when reusing its numeric lambda. Tuning uses dimension-based multipliers throughout its path and training folds.
Value
Fits retain group, group.multiplier, eligible-entry masks and
selected-block masks, together with the usual fit fields. Use the stored
multipliers with a numeric lambda to reproduce an IC-preset or tuned fit.
Details
For working coefficients \(b_{jc}=s_j\beta_{jc}\) and predictor group
\(G_g\), independent-channel selection (grouped=FALSE) uses
$$r_{gc}^2=\sum_{j\in G_g}b_{jc}^2.$$
Joint selection (grouped=TRUE) uses
$$r_g^2=\sum_c\sum_{j\in G_g}b_{jc}^2.$$
The norm prevents opposing signs from cancelling. The adaptive exponent is
fixed at \(\gamma=2\), and each penalized coefficient in a block receives
ridge diagonal
$$D_{jc}=\frac{\lambda a_g}{4r_g^2},$$
with the appropriate channel-specific norm for independent selection. Scalar
GLM working weights are divided by the channel's dispersion, so this expression
is on the likelihood scale. Equivalently, an unscaled weighted least-squares
system multiplies the diagonal by dispersion. Adaptive weights use coefficients
relative to zero; prior.mean remains the fixed ridge target.
The approximate selection target is
$$-2\ell(B,\psi)+\lambda\sum_g a_g\,1(r_g>0),$$
with separate blocks per response when grouped=FALSE. A numeric lambda uses
\(a_g=1\) by default. IC presets use the number of coefficients in the group,
multiplied by the number of responses for joint selection. Joint multinomial
groups use \((C-1)|G_g|\) dimensions for \(C\) CLR categories. Multinomial
predictor groups require grouped=TRUE. Noise parameters and compulsory terms
contribute to reported information criteria; their complexity charges are
constant across group-support comparisons.
Reported GIC, AIC and BIC count free nonzero coefficient entries, with the
usual mandatory-term, noise-parameter and CLR adjustments. Group size is
accounted for through these entries, without an additional size multiplier.
When a retained group contains exact zeros, its reported parameter count can
be smaller than the nominal group cost used in the adaptive-ridge update.
With zero ridge targets, the inverse-norm update is the quadratic majorization of a log-norm penalty. For an orthogonal block with curvature \(h\), its nonzero fixed point obeys \(r^2-\widehat r r+\lambda a_g/(4h)=0\); its existence boundary \(h\widehat r^2=\lambda a_g\) matches the block-L0 selection threshold. The unpenalized refit removes shrinkage on selected blocks. Coefficients can be zero inside a retained group, for example at a nonnegative boundary.
Hard thresholding removes whole blocks using thresh and normalized norms.
Explicit starting-zero exclusions remain binding for individual entries;
intercepts and compulsory terms remain eligible. Structural zero columns do
not enter solves. The returned sparse coefficient matrix retains the original
predictor dimensions. group_support_size, group_df and group_objective
in l0glmMetrics() describe the group fit, alongside coefficient-based scores.
Recognized scalar GLMs use a native C++ predictor-group IRLS driver, sharing
the family calculations and ridge solvers with ordinary models. For multiple
outcomes, native fits use up to ncores OpenMP channel threads;
BLAS runs with one thread inside those passes and its settings are restored.
The group penalty, step halving, dispersion updates and convergence checks
retain the same definitions in serial and parallel fits. External OSQP and
bigGlm solver callbacks run on the R thread.
Custom families, validation checkpoints, negative binomial with estimated
theta, joint multinomial and Cox models use the structured R driver and the
same group-selection rules.
Dense Gaussian identity fits reuse weighted cross-products on bounded active
designs; wider systems retain the Woodbury route. The Gaussian cache holds
at most 2,000 columns per channel and eight million entries across channels.
Standard scalar-family group fits also reuse the current and trial linear
predictors within each fit. Dense Gram updates preserve ordinary matrix
storage, and sparse inputs retain their sparse solver path.
Predictor-group screening and outcome preclustering are unavailable; use
screen="none" to fit a large group design directly. Local refinement tests
additions, deletions and exchanges of complete predictor groups, accepting
only improvements in the group objective (or supplied validation deviance).
Named presets and tuning refine the reported parameter-count IC. Numeric
penalties refine the weighted group-count objective; control.local$target
can explicitly choose "IC" or "L0".
Automatic refinement uses the selected coefficient-dimension limit described
in local_search. Cholesky is used for regular systems; a rank-deficient
unpenalized group refit can fall back to pivoted QR.
Examples
set.seed(41)
X <- matrix(rnorm(200 * 12), 200, 12)
group <- rep(seq_len(6), each=2)
group[11:12] <- 0
beta <- c(1.5, -1.5, 0, 0, 1, -1, rep(0, 6))
y <- 1 + as.numeric(X %*% beta) + rnorm(200)
fit <- l0glmFit(X, y, group=group, lambda="gic", intercept=TRUE,
local.search=FALSE)
l0glmMetrics(fit)[c("gic", "group_support_size", "group_df", "group_objective")]
same <- l0glmFit(X, y, group=group, lambda=fit$init.lambda,
group.multiplier=fit$group.multiplier, intercept=TRUE,
local.search=FALSE)
max(abs(coef(fit) - coef(same)))