
Fast Log-Link Binomial Regression, Estimate Only (C++ Backend)
Source:R/RcppExports.R
fast_log_binomial_regression_cpp.RdFits a binary-response GLM with the log link (a relative-risk
model), \(\log \mu_i = \log \Pr(Y_i = 1) = x_i^\top \beta\) (equivalently
\(\mu_i = e^{x_i^\top \beta}\), constrained to stay below
\(1 - 10^{-8}\) so it remains a valid probability), via Fisher scoring
(IRLS) with a step-halving line search that rejects any Newton step whose
resulting \(\eta_i = x_i^\top \beta\) would push \(\mu_i\) out of range
or decrease the log-likelihood — the same boundary-constrained-line-search
mechanism documented in full at
fast_identity_binomial_regression_cpp (see that page for the
IRLS/line-search mechanics, which are shared verbatim between the log and
identity links here; only the link function itself, and hence the
coefficient scale, differs). Regression coefficients are directly
interpretable as log relative risks: \(e^{\beta_j}\) is the
multiplicative change in \(\Pr(Y = 1)\) per unit change in covariate
\(j\) — in contrast to
fast_identity_binomial_regression_cpp's risk-difference scale,
or a logit-link model's odds-ratio scale.
Usage
fast_log_binomial_regression_cpp(
X,
y_r,
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,
estimate_only = FALSE
)Arguments
- X
A numeric matrix of predictors, \(n \times p\); include an explicit intercept column if desired (no implicit intercept).
- y_r
A binary (0/1) numeric vector of responses, length \(n\).
- maxit
Maximum number of Fisher-scoring iterations.
- tol
Convergence tolerance, on the relative norm of the coefficient update step.
- fixed_idx
Optional integer indices of coefficients to hold fixed rather than estimate.
- fixed_values
Optional values to fix the parameters named by
fixed_idxat.- warm_start_beta
Optional starting values for coefficients. If provided,
smart_cold_startis 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\), on the log-relative-risk scale), mu_hat (fitted
probabilities, length \(n\)), working_weights (final IRLS
weights), iterations, converged (logical), and
fisher_information (the working-weights curvature matrix
\(X^\top W X\)).
See also
fast_identity_binomial_regression_cpp for the
identity-link (risk-difference) analog and the full IRLS/line-search
mechanics; fast_log_binomial_regression_with_var_cpp for the
variance-augmented variant; fast_log_binomial_regression_weighted_cpp
for the row-weighted variant.
Poisson
regression's log link is the closest common orientation point for a
log-link GLM. Analogous Python API:
statsmodels GLM
(families.Binomial(link=log())).