Skip to contents

Fits the same identity-link (risk-difference) binomial regression as fast_identity_binomial_regression_cpp (see that page for the full model and boundary-constrained IRLS line search) and additionally computes the variance of a single caller-selected coefficient, via a targeted diagonal-entry inversion of the working-weights Fisher information — this entry point does not compute or return a full variance-covariance matrix or a vector of standard errors for every coefficient, despite its name; only the one coefficient named by j gets a variance (ssq_b_j).

Usage

fast_identity_binomial_regression_with_var_cpp(
  X,
  y_r,
  j = 2L,
  maxit = 100L,
  tol = 1e-06,
  fixed_idx = NULL,
  fixed_values = NULL,
  warm_start_beta = NULL,
  smart_cold_start = TRUE,
  warm_start_weights = NULL,
  warm_start_fisher_info = NULL
)

Arguments

X

A numeric matrix of predictors, \(n \times p\).

y_r

A binary (0/1) numeric vector of responses, length \(n\).

j

1-based index (into X's columns) of the coefficient to compute ssq_b_j for.

maxit

Maximum number of Fisher-scoring iterations.

tol

Convergence tolerance.

fixed_idx

Optional integer indices of coefficients to hold fixed rather than estimate.

fixed_values

Optional values to fix the parameters named by fixed_idx at.

warm_start_beta

Optional starting values for coefficients. If provided, smart_cold_start is ignored.

warm_start_weights

Optional initial working weights for the first IRLS iteration.

warm_start_fisher_info

Optional initial Fisher Information matrix for the first IRLS iteration.

Value

A list with components b (estimated coefficients \(\hat\beta\)), ssq_b_j (the variance of \(\hat\beta_j\), or NA on failure), converged (logical), fisher_information (the working-weights curvature matrix used for ssq_b_j, present only on the success path), neg_ll/logLik (the negative/positive log-likelihood at \(\hat\beta\), present only on the success path), and the always-empty vcov/std_err/z_vals placeholders described in Details.

Details

Variance computation. The IRLS working-weights Fisher information \(X^\top W X\) (reused from the underlying fit if finite and correctly sized, else recomputed from the final working weights) is restricted to the free (non-fixed_idx) parameters and factorized via LDLT; ssq_b_j is then obtained from a single targeted diagonal-entry inversion (compute_diagonal_inverse_entry()) at the free-parameter position corresponding to j, not a full matrix inverse. If the underlying fit did not converge, or the LDLT factorization fails (e.g. a rank-deficient free-parameter information matrix), the function returns early with converged = FALSE, ssq_b_j = NA, and empty (zero-length/zero-dimension) vcov/std_err/z_vals placeholders — these three fields are only ever populated as empty placeholders, on both the success and failure paths; no caller should rely on them containing actual values.

See also

fast_identity_binomial_regression_cpp for the estimate-only variant and the full model documentation.