Skip to main content

so_models/glm/
mod.rs

1//! Generalized Linear Models (GLM)
2//!
3//! This module implements Generalized Linear Models, which extend
4//! linear regression to response variables with non-normal distributions.
5//!
6//! # Key Components
7//!
8//! 1. **Distribution Families**: Gaussian, Binomial, Poisson, Gamma, Inverse Gaussian
9//! 2. **Link Functions**: Identity, Logit, Log, Inverse, etc.
10//! 3. **IRLS Algorithm**: Iteratively Reweighted Least Squares for estimation
11//! 4. **Model Diagnostics**: Deviance, Pearson chi-squared, AIC, BIC
12//!
13//! # Example Usage
14//!
15//! ```rust,no_run
16//! use so_models::glm::{GLM, Family, Link};
17//! use so_core::data::DataFrame;
18//! use so_core::formula::Formula;
19//!
20//! // Create a logistic regression model
21//! let model = GLM::new()
22//!     .family(Family::Binomial)
23//!     .link(Link::Logit)
24//!     .intercept(true);
25//!
26//! // Example data would be needed to fit the model
27//! // let formula = Formula::parse("y ~ x1 + x2").unwrap();
28//! // let data = DataFrame::from_series(...).unwrap();
29//! // let results = model.fit_formula(&formula, &data).unwrap();
30//! ```
31//!
32//! # References
33//!
34//! - McCullagh, P., & Nelder, J. A. (1989). *Generalized Linear Models*.
35//! - R's `glm()` function and statsmodels' GLM implementation.
36
37pub mod family;
38pub mod model;
39pub mod results;
40
41// Re-exports for convenience
42pub use family::{Family, Link, is_valid_link};
43pub use model::{GLM, GLMModelBuilder};
44pub use results::GLMResults;
45
46// Common prelude for GLM
47pub mod prelude {
48    pub use super::{Family, GLM, GLMModelBuilder, GLMResults, Link, is_valid_link};
49}