pymargins.GLMAdapter¶
- class pymargins.GLMAdapter¶
Base adapter for any model with prediction μ = g⁻¹(Xβ + offset).
Covers all GLM families uniformly. Concrete subclasses for statsmodels’ GLM and similar frameworks fill in framework-specific extraction.
- Implementations of predict typically use either:
jax-native: write the link inverse in JAX (logit, log, identity, probit are all available in jax.scipy.special)
custom JVP with link.inverse_deriv: use _gradients.make_glm_jvp_wrapper
Both produce identical numerical results; choose based on the discussion in the design docs.
- __init__()¶
Methods
__init__()attach(session)Attach this adapter to a Margins session.
bootstrap_state()Replay state for a refitted adapter.
coefficients()Return β̂ as a 1D JAX array.
column_index_of_variable(name)Return the design-matrix column index corresponding to a variable.
covariance([vcov_spec])Return Σ̂ as a 2D JAX array.
design_matrix_from_df(df)Build a design matrix from a concrete DataFrame of evaluation rows.
predict(beta, X[, offset])Prediction on the response scale, JAX-compatible.
refit(resampled_data, *[, index])Refit the model on resampled data, returning a new adapter.
variable_metadata()Return per-variable metadata used by averaging and validation.
Attributes
gradient_backend_recommendationRecommend pure autodiff for GLM adapters.
n_outcomesNumber of outcome classes for multi-outcome models, default 1.
outcome_labelsOutcome class labels for multi-outcome models, or None.
supported_inference_methodsGLM adapters support delta, simulation, and bootstrap inference.
supports_jax_autodiffGLM adapters typically use JAX-native link inverses or analytical JVP.
training_dataThe training data used to fit the model.