Skip to main content

solow_gam/
lib.rs

1//! # solow-gam
2//!
3//! Generalized additive models with penalized B-spline smooth terms.
4//!
5//! [`BSplines`] builds a quantile-knot B-spline basis for a single covariate
6//! together with a curvature ([`BSplines::cov_der2`]) penalty. [`GlmGam`] fits
7//! a GLM with one such smooth term plus an intercept by penalized iteratively
8//! reweighted least squares (P-IRLS) at a fixed smoothing parameter `alpha`,
9//! exposing the parameters, fitted values, effective degrees of freedom, and
10//! penalized deviance. Validated against an authoritative reference.
11//!
12//! ```
13//! use ndarray::Array1;
14//! use solow_gam::GlmGam;
15//! use solow_glm::Family;
16//!
17//! let x = Array1::linspace(0.0, 1.0, 60);
18//! let y = x.mapv(|xi| (2.0 * std::f64::consts::PI * xi).sin());
19//! let res = GlmGam::new(y, &x, 10, 3, 0.6, Family::Gaussian)
20//!     .unwrap()
21//!     .fit()
22//!     .unwrap();
23//! assert!(res.converged);
24//! assert!(res.edf_total > 0.0);
25//! ```
26
27mod bspline;
28mod cyclic;
29mod gam;
30mod gam_ext;
31
32pub use bspline::BSplines;
33pub use cyclic::CyclicCubicSplines;
34pub use gam::{GamResults, GlmGam};
35pub use gam_ext::{GamExtResults, GlmGamExt};