Skip to main content

Module logistic

Module logistic 

Source
Expand description

Diagnostics for binary logistic regression — a different statistical framework from OLS, not an extension of it, and provided here as its own self-contained set of types.

Logistic regression models P(y = 1) = 1/(1 + e^{−Xβ}) and is fit by maximum likelihood; there is no closed-form hat matrix and residuals are not Gaussian. So the diagnostics are the ones that are actually defined for this likelihood:

§Response convention

The response must be binary, coded 0.0 / 1.0, with both classes present. As with OLS the caller owns the design matrix, including any intercept column.

§Separation

When the classes are perfectly (or quasi-) separable the maximum-likelihood coefficients diverge to ±∞ and no finite fit exists. IRLS then fails to converge and construction returns RegressionError::NotConverged rather than reporting enormous, meaningless coefficients.

Structs§

GoodnessOfFit
Bundle of overall logistic goodness-of-fit statistics.
HosmerLemeshow
Result of the Hosmer–Lemeshow goodness-of-fit test.
LogisticFit
A fitted binary logistic-regression model.

Functions§

cooks_distance
Cook’s-distance analogue for logistic regression (Pregibon):
deviance_residuals
Deviance residuals sign(yᵢ − pᵢ)·√(−2[yᵢ ln pᵢ + (1 − yᵢ) ln(1 − pᵢ)]).
leverage
Logistic leverage — the diagonal of the weighted hat matrix H = W^{1/2}X(XᵀWX)⁻¹XᵀW^{1/2}, i.e. hᵢ = wᵢ · xᵢᵀ(XᵀWX)⁻¹xᵢ with wᵢ = pᵢ(1 − pᵢ).
pearson_residuals
Pearson residuals (yᵢ − pᵢ) / √(pᵢ(1 − pᵢ)).