Skip to content

Miscellaneous API

Various functionality not part of the main API, but we want to be exposed/searchable.

qq

QQResult

QQResult(theoretical: ndarray, residuals: ndarray, interval: tuple[ndarray, ndarray])

Results required for a qq plot.

qq_transform

qq_transform(
    gam: AbstractGAM,
    *,
    transform_to: Literal["normal", "uniform"] = "normal",
    level: float = 0.9,
) -> QQResult

Generate a QQ-plot by transforming the data to a known distribution.

This plots the theoretical quantiles against the transformed data. The data are transformed by 1) passing through the CDF implied by the model, and 2) passing to the quantile function of the distribution implied by transform_to.

Note

Using transform_to="uniform" may hide outliers/tail behaviour issues, as the data is constrained to [0, 1], which can be hard to assess visually.

Parameters:

  • gam (AbstractGAM) –

    The fitted GAM object. The family should support the CDF method, which can be checked with isinstance(family, SupportsCDF).

  • transform_to (Literal['normal', 'uniform'], default: 'normal' ) –

    The distribution to transform the residuals to.

  • level (float, default: 0.9 ) –

    The confidence level for the interval.

Returns:

  • QQResult ( QQResult ) –

    The results required for a qq plot.

qq_simulate

qq_simulate(
    gam: AbstractGAM,
    *,
    n_sim: int = 50,
    level: float = 0.9,
    type: Literal["deviance", "response", "pearson"] = "deviance",
) -> QQResult

Generate data for qq-plot via simulation from the family.

Parameters:

  • gam (AbstractGAM) –

    The fitted GAM object.

  • n_sim (int, default: 50 ) –

    The number of simulations to perform.

  • level (float, default: 0.9 ) –

    The level (i.e. 0.9 means 90% interval).

  • type (Literal['deviance', 'response', 'pearson'], default: 'deviance' ) –

    The type of residuals to use.