plot_diagnostics#
- SuperGLM.plot_diagnostics(
- X: object,
- y: NDArray,
- sample_weight: NDArray | None = None,
- offset: NDArray | None = None,
- *,
- n_sim: int = 100,
- figsize: tuple[float, float] | None = None,
- max_points: int = 50000,
- seed: int = 42,
- residual_type: str = 'auto',
GLM/GAM diagnostic figure with simulation-based Q-Q envelope.
Four panels using quantile residuals (Dunn & Smyth 1996):
Q-Q with simulation envelope
Calibration (sample-weighted observed vs predicted)
Residuals vs Linear Predictor
Residual distribution (histogram + N(0,1) overlay)
- Parameters:
- Xpandas or eager Polars DataFrame
Design matrix.
- yNDArray
Response vector.
- sample_weightNDArray or None
Observation weights, read under the model’s declared
weight_semantics: replication counts under"frequency", precisions under"prior". The quantile residuals below take the row’s own marginal distribution from that contract, so a prior weight enters the reference distribution and a replication count does not.- offsetNDArray or None
Optional offset.
- n_simint
Number of simulation replicates for the Q-Q envelope.
- figsizetuple or None
Figure size in inches. Defaults to
(10, 8).- max_pointsint
Threshold for scatter vs hexbin rendering.
- seedint
Random seed for quantile residuals, simulation, and subsampling.
- residual_typestr
Deprecated since version Ignored.: All panels use quantile residuals.
- Returns:
- matplotlib.figure.Figure
A figure with 4 diagnostic subplots.