Computes a rotation axis that best represents a target variable's
contribution to the ENA point space, after controlling for covariates via
Lasso (coordinate-descent, k-fold CV). Mirrors
rENA::ena.rotate.by.generalized().
Usage
generalized_means_rotation(
V,
x_model_matrix,
x_target,
x1_cols,
x_categorical,
x_n_groups,
x_subset,
has_y,
y_model_matrix,
y_target,
y1_cols,
y_categorical,
y_n_groups,
n_lambda = 50L,
k_folds = 5L,
lasso_eps = 0.01
)Arguments
- V
Numeric matrix (n_units x n_connections) — ENA points.
- x_model_matrix
Numeric matrix (n_units x p) — model matrix for x axis.
- x_target
Numeric vector length n — target variable (raw float for numeric; 0-based integer codes for categorical).
- x1_cols
Integer vector of 0-based column indices in
x_model_matrixthat belong to the target variable (unpenalized).- x_categorical
Logical — TRUE if target is categorical.
- x_n_groups
Integer — number of distinct groups (categorical only).
- x_subset
Integer vector of 0-based row indices to subset for the x-axis GMR step (pass
integer(0)to use all rows).- has_y
Logical — TRUE to compute a second GMR axis.
- y_model_matrix
Numeric matrix (n_units x p) — model matrix for y axis (ignored when
has_y = FALSE).- y_target
Numeric vector — y-axis target (ignored when
has_y = FALSE).- y1_cols
0-based column indices for y target (ignored when
has_y = FALSE).- y_categorical
Logical (ignored when
has_y = FALSE).- y_n_groups
Integer (ignored when
has_y = FALSE).- n_lambda
Length of the Lasso lambda path (default 50).
- k_folds
Cross-validation folds for lambda selection (default 5).
- lasso_eps
lambda_min = lasso_eps * lambda_max(default 0.01).
Details
The caller is responsible for building x_model_matrix (e.g. via
model.matrix()) and identifying x1_cols (0-based indices of
the target variable's columns, which receive penalty_factor = 0).
Categorical targets should be encoded as 0-based integers.