pub fn compute_envelopeaudit(
kkt_residual_norm: f64,
referencegradient: &Array1<f64>,
ridge_used: f64,
ridge_assumed: f64,
beta: &Array1<f64>,
abs_tolerance: f64,
rel_tolerance: f64,
) -> EnvelopeAuditExpand description
Compute the inner KKT residual to detect envelope theorem violations.
The analytic gradient calculation assumes that P-IRLS found an exact stationary point where ∇_β L = 0. If this is not true (due to stabilization ridge, Firth adjustments, or early termination), the “indirect term” of the chain rule becomes significant and the gradient will be wrong.
§Arguments
kkt_residual_norm- Norm of the full inner gradient ||∇_β L|| at the PIRLS solutionreferencegradient- Reference gradient scale (typically S_λ β) for relative normalizationridge_used- Ridge added by PIRLS for stabilizationbeta- Current coefficient estimatetolerance- Threshold for flagging violations