pymargins.LinearPredictionAdapter¶
- class pymargins.LinearPredictionAdapter¶
Base for models whose prediction is exactly Xβ (no link function).
- Covers OLS, WLS, GLS, IV, panel models. predict() is trivially Path A:
- def predict(self, beta, X, offset=None):
return X @ beta + (offset if offset is not None else 0.0)
The complexity for these adapters lies in covariance(): handling the framework’s various vcov flavors (HC, cluster, HAC, GMM-style adjustments for IV, etc.).
- __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])Linear prediction: X @ beta + offset.
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 linear adapters.
n_outcomesNumber of outcome classes for multi-outcome models, default 1.
outcome_labelsOutcome class labels for multi-outcome models, or None.
supported_inference_methodsLinear adapters support delta, simulation, and bootstrap inference.
supports_jax_autodiffLinear prediction is trivially JAX-differentiable (X @ beta).
training_dataThe training data used to fit the model.