Skip to main content

Module glm

Module glm 

Source
Expand description

Generalized linear models (ISL ch 4) — logistic and Poisson regression by iteratively reweighted least squares (IRLS).

Each IRLS step is a weighted least-squares solve of (DᵀWD)β = DᵀWz, done with the engine’s linear_algebra::cholesky (no re-implemented solver); the Wald standard errors come from (DᵀWD)⁻¹ at convergence and the p-values from the Normal CDF in statistics::distributions. Kernel-class: DenseLinear per step (dispatch-ready); the IRLS loop itself is scalar CPU.

Re-exports§

pub use family::Family;
pub use multinomial::MultinomialLogistic;

Modules§

family
GLM exponential-family links — the per-family functions the IRLS loop needs. Both families use their canonical link.
multinomial
Multinomial logistic regression / softmax classifier (ISL ch 4.3.5, PRML ch 4).

Structs§

GlmModel
A fitted GLM. coefficients[0] is the intercept when fit_intercept.

Functions§

fit
Fit a GLM of y (length n) on a row-major n × p predictor matrix by IRLS. fit_intercept prepends a constant column. Fails closed: InvalidDimension, InsufficientData (n ≤ params), Singular (collinear / perfectly separated), NotConverged.
fit_logistic
Convenience: logistic regression (Bernoulli y ∈ {0,1}).
fit_poisson
Convenience: Poisson regression (count y ≥ 0).