Skip to contents

Fits 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 NULL means TRUE, except FALSE when cluster_col is 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 of X (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 the G/(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 gains std_beta (beta per 1 SD of the original feature) and, for listed features, increment, or_increment, or_increment_ci_95_lower and or_increment_ci_95_upper (odds ratio per size original units).

Value

An S3 object of class consortium_risk_factors with Table 5 data frame, coefficients, standard errors, and methods.