Skip to main content

compute_envelopeaudit

Function compute_envelopeaudit 

Source
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,
) -> EnvelopeAudit
Expand 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 solution
  • referencegradient - Reference gradient scale (typically S_λ β) for relative normalization
  • ridge_used - Ridge added by PIRLS for stabilization
  • beta - Current coefficient estimate
  • tolerance - Threshold for flagging violations