Skip to contents

Fits the logistic regression model documented in full at fast_logistic_regression_cpp (log-odds-ratio interpretation, IRLS/L-BFGS/Newton-Raphson optimization) via that C++ backend, returning only the point estimate \(\hat\beta\) — no variance-covariance matrix or per-coefficient standard errors are computed. Unlike fast_logistic_regression_with_var, this function does not attempt to detect or retry on (quasi-)complete separation; if the underlying C++ fit errors for any reason, this function silently returns b as a vector of NAs (of length ncol(X)) rather than raising an error or retrying with fewer covariates.

Usage

fast_logistic_regression(
  X,
  y,
  optimization_alg = "lbfgs",
  warm_start_beta = NULL,
  warm_start_fisher_info = NULL
)

Arguments

X

A numeric matrix of predictor variables. It is assumed that an intercept column (e.g., a column of ones) is already included in X if desired.

y

A numeric vector of the response variable, expected to be binary (0 or 1).

optimization_alg

Optimization algorithm: "lbfgs" (default), "newton_raphson", or "irls".

warm_start_beta

Optional starting values for the coefficients.

warm_start_fisher_info

Optional initial Fisher Information matrix.

Value

A list containing the following component:

b

A numeric vector of the estimated logistic regression coefficients \(\hat\beta\), or a vector of NA_real_ (length ncol(X)) if the underlying fit errored.

See also

fast_logistic_regression_cpp for the underlying backend and full model documentation; fast_logistic_regression_with_var for the variance- augmented, separation-retrying variant.

Examples

X = matrix(rnorm(500), 100, 5)
y = rbinom(100, 1, 0.5)
fast_logistic_regression(X, y)
#> $b
#> [1] -0.01556099 -0.08757211 -0.19399375 -0.10932153  0.26606962
#>