# API Reference


## Core model


The primary GAM interface for fitting, predicting, and inspecting models.


[GAM](GAM.md#whittaker.GAM)  
Generalized Additive Model with automatic smoothness selection.

[PredictionResult](PredictionResult.md#whittaker.PredictionResult)  
Container returned by [GAM.predict()](GAM.md#whittaker.GAM.predict) for `type="response"` or `type="link"`.

[TermsPredictionResult](TermsPredictionResult.md#whittaker.TermsPredictionResult)  
Container returned by `GAM.predict(type="terms")`.

[PosteriorPredictResult](PosteriorPredictResult.md#whittaker.PosteriorPredictResult)  
Container returned by [GAM.posterior_predict()](GAM.md#whittaker.GAM.posterior_predict).

[GoodnessOfFit](GoodnessOfFit.md#whittaker.GoodnessOfFit)  
Goodness-of-fit statistics returned by [GAM.goodness_of_fit()](GAM.md#whittaker.GAM.goodness_of_fit).

[GamCheckResult](GamCheckResult.md#whittaker.GamCheckResult)  
Container returned by [GAM.gam_check()](GAM.md#whittaker.GAM.gam_check), bundling residual diagnostics with fit summary

[CheckDataResult](CheckDataResult.md#whittaker.CheckDataResult)  
Structured diagnostic data underlying [check()](check.md#whittaker.check) plots.

[SensitivityResult](SensitivityResult.md#whittaker.SensitivityResult)  
Result of a smoothing-parameter sensitivity analysis.

[PartialDependenceResult](PartialDependenceResult.md#whittaker.PartialDependenceResult)  
Partial dependence data for one smooth term.

[SimultaneousCIResult](SimultaneousCIResult.md#whittaker.SimultaneousCIResult)  
Simultaneous confidence band for a smooth term.


## Inference


Result types from parametric and smooth tests, concurvity, influence diagnostics, derivatives, marginal effects, and contrasts.


[ParametricTestResult](ParametricTestResult.md#whittaker.ParametricTestResult)  
Result of a Wald test for a parametric coefficient.

[SmoothTestResult](SmoothTestResult.md#whittaker.SmoothTestResult)  
Result of an approximate test for H_0: f_j = 0.

[ConcurvityResult](ConcurvityResult.md#whittaker.ConcurvityResult)  
Concurvity diagnostics for smooth terms.

[KCheckResult](KCheckResult.md#whittaker.KCheckResult)  
Result of basis dimension adequacy check for a single smooth.

[InfluenceResult](InfluenceResult.md#whittaker.InfluenceResult)  
Observation-level influence diagnostics.

[DispersionTestResult](DispersionTestResult.md#whittaker.DispersionTestResult)  
Result of a dispersion test.

[VIFResult](VIFResult.md#whittaker.VIFResult)  
Variance inflation factor for a parametric term.

[DerivativeResult](DerivativeResult.md#whittaker.DerivativeResult)  
Result of smooth derivative estimation.

[MarginalEffectResult](MarginalEffectResult.md#whittaker.MarginalEffectResult)  
Result of marginal effect estimation for one smooth term.

[ContrastResult](ContrastResult.md#whittaker.ContrastResult)  
Result of a pairwise comparison between two conditions.


## Formula


Formula parsing and term specifications for model construction.


[Formula](Formula.md#whittaker.Formula)  
A parsed model formula: the structured representation of a [GAM](GAM.md#whittaker.GAM)'s right-hand side.

[SmoothTerm](SmoothTerm.md#whittaker.SmoothTerm)  
A smooth term, e.g. `s(x1, bs='cr', k=10)` or `te(x1, x2)`.

[LinearTerm](LinearTerm.md#whittaker.LinearTerm)  
A plain linear (parametric) term, e.g. `x1` or `group`.

[InteractionTerm](InteractionTerm.md#whittaker.InteractionTerm)  
A two-way parametric interaction between two bare covariates, e.g. `x1 * x2`.

[OffsetTerm](OffsetTerm.md#whittaker.OffsetTerm)  
An offset term, e.g. `offset(log_exposure)`.

[parse_formula()](parse_formula.md#whittaker.parse_formula)  
Parse *formula* into a `~whittaker.formula.terms.Formula`.


## Response families


Distributions and link functions for the response variable. Each family specifies a conditional distribution and a link function relating the linear predictor to the conditional mean.


[Family](Family.md#whittaker.Family)  
Abstract family defining the response distribution and link function.

[Gaussian](Gaussian.md#whittaker.Gaussian)  
Gaussian (Normal) family with identity link.

[Poisson](Poisson.md#whittaker.Poisson)  
Poisson family with log (canonical) link.

[Binomial](Binomial.md#whittaker.Binomial)  
Binomial family with logit (canonical) link.

[Gamma](Gamma.md#whittaker.Gamma)  
Gamma family with log link.

[NegativeBinomial](NegativeBinomial.md#whittaker.NegativeBinomial)  
Negative Binomial family with log link (NB2 parameterization).

[Beta](Beta.md#whittaker.Beta)  
Beta regression family with logit link.

[Tweedie](Tweedie.md#whittaker.Tweedie)  
Tweedie family with log link.

[TweedieEstimated](TweedieEstimated.md#whittaker.TweedieEstimated)  
Tweedie family with variance power estimated by profile likelihood.

[tw()](tw.md#whittaker.tw)  
Create a Tweedie family with estimated variance power.

[InverseGaussian](InverseGaussian.md#whittaker.InverseGaussian)  
Inverse Gaussian family with log link.

[CoxPH](CoxPH.md#whittaker.CoxPH)  
Cox proportional hazards family for survival analysis.

[OrderedCategorical](OrderedCategorical.md#whittaker.OrderedCategorical)  
Ordered categorical (proportional odds / cumulative logit) family.

[Multinomial](Multinomial.md#whittaker.Multinomial)  
Multinomial logistic family for unordered categorical responses.


## Distributional families (GAMLSS)


Location-scale-shape families for distributional regression, where multiple distribution parameters are modeled as smooth functions.


[GAMLSSFamily](GAMLSSFamily.md#whittaker.GAMLSSFamily)  
Abstract base class for GAMLSS distributional families.

[GaussianLS](GaussianLS.md#whittaker.GaussianLS)  
Gaussian location-scale family for GAMLSS.

[GammaLS](GammaLS.md#whittaker.GammaLS)  
Gamma location-scale family for GAMLSS.

[BetaLS](BetaLS.md#whittaker.BetaLS)  
Beta family for GAMLSS with mean-precision parameterisation.

[ZeroInflatedPoisson](ZeroInflatedPoisson.md#whittaker.ZeroInflatedPoisson)  
Zero-inflated Poisson (ZIP) family for GAMLSS.

[ZeroInflatedNegativeBinomial](ZeroInflatedNegativeBinomial.md#whittaker.ZeroInflatedNegativeBinomial)  
Zero-inflated negative binomial (ZINB) family for GAMLSS.


## Distributional regression


The GAMLSS fitting interface for distributional regression models.


[GAMLSS](GAMLSS.md#whittaker.GAMLSS)  
Generalized Additive Model for Location, Scale, and Shape.

[GAMLSSPrediction](GAMLSSPrediction.md#whittaker.GAMLSSPrediction)  
Result of [GAMLSS.predict()](GAMLSS.md#whittaker.GAMLSS.predict).


## Smooth basis types


Basis constructors for smooth terms. Each basis type can be specified in a formula via `bs=` or constructed directly for advanced use.


[SmoothBasis](SmoothBasis.md#whittaker.SmoothBasis)  
Abstract base class for all smooth basis types.

[TPRS](TPRS.md#whittaker.TPRS)  
Thin Plate Regression Splines (TPRS).

[CRS](CRS.md#whittaker.CRS)  
Cubic Regression Splines (natural cubic splines with quantile knots).

[PSpline](PSpline.md#whittaker.PSpline)  
P-Spline: B-spline basis with m-th order difference penalty.

[CyclicCRS](CyclicCRS.md#whittaker.CyclicCRS)  
Cyclic Cubic Regression Spline (periodic natural cubic spline).

[CyclicPSpline](CyclicPSpline.md#whittaker.CyclicPSpline)  
Cyclic P-Spline (periodic B-spline basis with circular difference penalty).

[ShrinkageTPRS](ShrinkageTPRS.md#whittaker.ShrinkageTPRS)  
Shrinkage Thin Plate Regression Spline.

[ShrinkageCRS](ShrinkageCRS.md#whittaker.ShrinkageCRS)  
Shrinkage Cubic Regression Spline.

[DuchonSpline](DuchonSpline.md#whittaker.DuchonSpline)  
Duchon spline basis.

[GaussianProcess](GaussianProcess.md#whittaker.GaussianProcess)  
Gaussian process (kriging) smooth basis.

[SoapFilm](SoapFilm.md#whittaker.SoapFilm)  
Soap film smooth for 2-D domains with complex boundaries.

[MRFBasis](MRFBasis.md#whittaker.MRFBasis)  
Markov random field basis for areal spatial data.

[AdaptiveTPRS](AdaptiveTPRS.md#whittaker.AdaptiveTPRS)  
Adaptive Thin Plate Regression Spline.

[RandomEffectBasis](RandomEffectBasis.md#whittaker.RandomEffectBasis)  
Random effect basis (one-hot encoding with identity penalty).

[FactorSmoothBasis](FactorSmoothBasis.md#whittaker.FactorSmoothBasis)  
Factor-smooth interaction basis (per-level smooth with shared penalties).

[TensorProductBasis](TensorProductBasis.md#whittaker.TensorProductBasis)  
Tensor product of marginal smooth bases (`te()`-style interaction smooth).

[TensorInteractionBasis](TensorInteractionBasis.md#whittaker.TensorInteractionBasis)  
Tensor product interaction basis (`ti()`-style pure interaction smooth).

[TensorProductBasisT2](TensorProductBasisT2.md#whittaker.TensorProductBasisT2)  
Tensor product basis with full penalty decomposition (`t2()`-style interaction smooth).


## Shape-constrained smooths


Monotone, convex, and concave smooth basis types with built-in shape enforcement.


[MonotonePSpline](MonotonePSpline.md#whittaker.MonotonePSpline)  
Shape-constrained P-spline: monotone increasing or decreasing.

[ConvexPSpline](ConvexPSpline.md#whittaker.ConvexPSpline)  
Shape-constrained P-spline: convex or concave.


## Quantile regression


Quantile GAMs with optional non-crossing constraints.


[QuantileGAM](QuantileGAM.md#whittaker.QuantileGAM)  
Non-crossing quantile GAM.

[QuantileGAMResult](QuantileGAMResult.md#whittaker.QuantileGAMResult)  
Result container for a fitted QuantileGAM.

[QuantileFamily](QuantileFamily.md#whittaker.QuantileFamily)  
Quantile regression via the Extended Log-F (ELF) pseudo-family.

[calibrate_sigma()](calibrate_sigma.md#whittaker.calibrate_sigma)  
Find the ELF bandwidth sigma that minimises out-of-sample ELF loss.


## Conformal prediction


Distribution-free prediction intervals via split, CV+, and jackknife+ conformal methods.


[conformal_fit()](conformal_fit.md#whittaker.conformal_fit)  
Fit a GAM with conformal calibration.

[conformal_coverage()](conformal_coverage.md#whittaker.conformal_coverage)  
Compute empirical coverage of conformal intervals on held-out data.

[ConformalPredictor](ConformalPredictor.md#whittaker.ConformalPredictor)  
A calibrated conformal predictor ready to produce intervals.

[ConformalResult](ConformalResult.md#whittaker.ConformalResult)  
Result of conformal prediction.


## Causal inference


Causal GAMs using double/debiased machine learning (DML), heterogeneous treatment effect estimation (CATE), and mediation analysis.


[CausalGAM](CausalGAM.md#whittaker.CausalGAM)  
Causal GAM for treatment effect estimation.

[TreatmentEffect](TreatmentEffect.md#whittaker.TreatmentEffect)  
Average treatment effect estimate with inference.

[CATEResult](CATEResult.md#whittaker.CATEResult)  
Conditional average treatment effect estimates.

[mediation_analysis()](mediation_analysis.md#whittaker.mediation_analysis)  
Causal mediation analysis with GAM nuisance models.

[MediationResult](MediationResult.md#whittaker.MediationResult)  
Mediation analysis results.


## Streaming and online GAMs


Incremental fitting via sufficient statistics for data that arrives in batches.


[StreamingGAM](StreamingGAM.md#whittaker.StreamingGAM)  
Streaming / online GAM.

[StreamingSnapshot](StreamingSnapshot.md#whittaker.StreamingSnapshot)  
A snapshot of streaming GAM state at a point in time.


## Multi-response GAMs


Joint fitting of multiple response variables with optional residual correlation modeling.


[MultiResponseGAM](MultiResponseGAM.md#whittaker.MultiResponseGAM)  
Multi-response GAM.

[MultiResponseResult](MultiResponseResult.md#whittaker.MultiResponseResult)  
Prediction result for multiple responses.

[ResidualCorrelation](ResidualCorrelation.md#whittaker.ResidualCorrelation)  
Estimated residual correlation structure.


## Functional regression


Scalar-on-function regression where predictors include functional covariates (curves).


[FunctionalGAM](FunctionalGAM.md#whittaker.FunctionalGAM)  
Scalar-on-function GAM.

[FunctionalTerm](FunctionalTerm.md#whittaker.FunctionalTerm)  
Specification for a functional covariate.

[CoefficientFunction](CoefficientFunction.md#whittaker.CoefficientFunction)  
Estimated coefficient function beta(t) for a functional term.


## Large datasets


Scalable GAM fitting for datasets that exceed memory or benefit from parallel computation.


[BigGAM](BigGAM.md#whittaker.BigGAM)  
GAM for large datasets using discretized fitting.

[PolarsGAM](PolarsGAM.md#whittaker.PolarsGAM)  
GAM that reads data from Polars LazyFrames, DataFrames, or files.

[DuckDBGAM](DuckDBGAM.md#whittaker.DuckDBGAM)  
GAM that reads data directly from DuckDB via SQL.


## Cross-validation


K-fold cross-validation for GAMs with deviance, MSE, and MAE scoring.


[cross_validate()](cross_validate.md#whittaker.cross_validate)  
K-fold cross-validation for a GAM specification.

[CVResult](CVResult.md#whittaker.CVResult)  
Result of [cross_validate()](cross_validate.md#whittaker.cross_validate).


## scikit-learn integration


GAM estimators compatible with the scikit-learn API for use in pipelines and grid search.


[GAMRegressor](GAMRegressor.md#whittaker.GAMRegressor)  
Scikit-learn compatible GAM regressor.

[GAMClassifier](GAMClassifier.md#whittaker.GAMClassifier)  
Scikit-learn compatible GAM classifier (binary).


## Serialization


Save and load fitted GAMs, and convert to/from mgcv-compatible dictionaries.


[save_gam()](save_gam.md#whittaker.save_gam)  
Save a fitted GAM to a `.npz` archive.

[load_gam()](load_gam.md#whittaker.load_gam)  
Load a fitted GAM from a `.npz` archive created by [save_gam](save_gam.md#whittaker.save_gam).

[from_mgcv_dict()](from_mgcv_dict.md#whittaker.from_mgcv_dict)  
Import an mgcv `gam` object exported as a dictionary.

[to_mgcv_dict()](to_mgcv_dict.md#whittaker.to_mgcv_dict)  
Export a fitted GAM as an mgcv-compatible dictionary.


## Datasets


Built-in synthetic datasets for testing and examples.


[load_dataset()](load_dataset.md#whittaker.load_dataset)  
Load a built-in example dataset.

[list_datasets()](list_datasets.md#whittaker.list_datasets)  
Return a list of all built-in datasets with their metadata.


## Model comparison


Compare fitted GAMs by information criteria, LOO-CV, WAIC, and stacking weights.


[compare()](compare.md#whittaker.compare)  
Compare multiple fitted GAMs in a summary table.

[ComparisonResult](ComparisonResult.md#whittaker.ComparisonResult)  
Result of comparing multiple fitted GAMs.

[ComparisonRow](ComparisonRow.md#whittaker.ComparisonRow)  
One row of a model comparison table.

[loo_compare()](loo_compare.md#whittaker.loo_compare)  
Compare two PSIS-LOO results computed on the same observations.

[LOOResult](LOOResult.md#whittaker.LOOResult)  
Result of PSIS-LOO cross-validation on a fitted GAM.

[LOOComparison](LOOComparison.md#whittaker.LOOComparison)  
Comparison of two PSIS-LOO results on the same data.

[waic_compare()](waic_compare.md#whittaker.waic_compare)  
Compare two WAIC results computed on the same observations.

[WAICResult](WAICResult.md#whittaker.WAICResult)  
Result of WAIC computation on a fitted GAM.

[WAICComparison](WAICComparison.md#whittaker.WAICComparison)  
Comparison of two WAIC results on the same data.

[stacking()](stacking.md#whittaker.stacking)  
Compute stacking weights for model averaging.

[StackingResult](StackingResult.md#whittaker.StackingResult)  
Result of stacking weight optimization.


## Posterior predictive checks


Simulate data from the posterior predictive distribution to assess model fit.


[PPCResult](PPCResult.md#whittaker.PPCResult)  
Result of a posterior predictive check on a fitted GAM.


## Plotting


Diagnostic and partial-effect plotting functions.


[check()](check.md#whittaker.check)  
Produce GAM diagnostic plots.

[partial_effects()](partial_effects.md#whittaker.partial_effects)  
Plot partial effects with confidence bands for each smooth term.


## Model matrix


Low-level model matrix construction from formulas and data.


[build_model_matrix()](build_model_matrix.md#whittaker.build_model_matrix)  
Assemble the full design matrix and penalty structure from a formula.

[predict_matrix()](predict_matrix.md#whittaker.predict_matrix)  
Build the prediction design matrix for new data.

[ModelMatrix](ModelMatrix.md#whittaker.ModelMatrix)  
Numeric design matrix, penalties, and metadata produced by :func:[build_model_matrix](build_model_matrix.md#whittaker.build_model_matrix).

[SmoothInfo](SmoothInfo.md#whittaker.SmoothInfo)  
Metadata describing where one smooth term lives inside a [ModelMatrix](ModelMatrix.md#whittaker.ModelMatrix).
