
Generalized Means Rotation (GMR) with optional subsetting and interaction control
Source:R/gmr.R
gmr.RdComputes a rotation (direction) `r` representing the contribution of the first column of `X` to the multivariate ENA matrix `V`. Supports optional subsetting by `groups`, optional inclusion of interaction terms when computing adjusted contributions.
Usage
gmr(
V,
X,
groups = NULL,
alpha = 1,
lambda = "lambda.min",
interactions = TRUE,
verbose = TRUE
)Arguments
- V
Numeric ENA matrix (units × connections) ready for rotation.
- X
Data frame or matrix of predictors; the first column is the target.
- groups
Optional vector specifying target groups to subset. If `NULL` (default), all rows are used.
- alpha
Elastic-net mixing parameter forwarded to `get_x1_main_effect` (default `1` — Lasso).
- lambda
Lambda selection for `cv.glmnet` forwarded to `get_x1_main_effect` (default `"lambda.min"`).
- interactions
Logical; if `TRUE` (default) interactions are included when computing the adjusted contribution.
- verbose
Logical; if `TRUE` (default) the function emits messages about fails or successes.
Value
A numeric vector `r` (length = ncol(V)) giving the normalized rotation direction. Attributes attached:
- `target`
The full-length target vector (un-subsetted).
- `Vx1`
The unadjusted fitted values (`lm(V ~ target)`) embedded in a full-length matrix (rows outside subset filled with zeros).
If no valid direction can be found (including SVD failure), returns `NULL` and issues a warning.