
Robust Multivariable Odds Ratios with L2 / Ridge Inversion
Source:R/ml.R
consortium_multivariable_risk_factors.RdFits multivariable logistic regression using L2 ridge penalization and QR orthogonalization to eliminate collinear columns and prevent Hessian singularity on high-dimensional clinical feature matrices.
Usage
consortium_multivariable_risk_factors(
X,
y,
binary_cols = NULL,
regularize = NULL,
alpha = 1,
domain_mapping = NULL,
standardize_continuous = TRUE,
drop_collinear = TRUE,
cluster_col = NULL,
increments = NULL
)Arguments
- X
Data frame or numeric matrix of predictors.
- y
Binary numeric vector of outcome indicators (0 or 1).
- binary_cols
Optional character vector of binary column names. If
NULL, auto-detected.- regularize
Logical; whether to apply L2 ridge regularization. Default
NULLmeansTRUE, exceptFALSEwhencluster_colis given, so clustered standard errors are those of an unpenalised fit.- alpha
Numeric; L2 regularization penalty parameter lambda (default
1.0).- domain_mapping
Optional named character vector mapping feature names to clinical domains.
- standardize_continuous
Logical; whether continuous features are scaled to 1-SD units (default
TRUE).- drop_collinear
Logical; whether linearly dependent columns are dropped via QR decomposition (default
TRUE).- cluster_col
Optional cluster identifier (typically
subject_id) for repeated stays per patient: a column name ofX(never used as a predictor) or a vector with one value per row. When given, standard errors, CIs and p-values use the patient-clustered (Huber-White) sandwich estimator with theG/(G-1) * (n-1)/(n-k)small-sample correction.- increments
Optional named list
list(feature = c(size, label)), e.g.list(sbp = list(10, "per 10 mmHg")). The table gainsstd_beta(beta per 1 SD of the original feature) and, for listed features,increment,or_increment,or_increment_ci_95_lowerandor_increment_ci_95_upper(odds ratio persizeoriginal units).