pymargins.WrappedFDAdapter

class pymargins.WrappedFDAdapter

Base for models with smooth predict but no exposed analytical derivative.

Uses _gradients.make_predict_with_fd_jvp to wrap the framework’s native predict with a JAX-compatible custom JVP. FD is hidden inside the JVP; downstream autodiff over the estimand structure remains exact.

Concrete subclasses provide native_predict(beta_np, X) and the wrapper is constructed automatically.

__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.

native_predict(beta_np, X)

Framework-native predict.

predict(beta, X[, offset])

FD-wrapped predict.

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_recommendation

Recommend wrapped_fd because predict uses finite-difference JVP.

n_outcomes

Number of outcome classes for multi-outcome models, default 1.

outcome_labels

Outcome class labels for multi-outcome models, or None.

supported_inference_methods

Wrapped-FD adapters support delta, simulation, and bootstrap.

supports_jax_autodiff

FD-based JVP is not native autodiff; flag for diagnostics.

training_data

The training data used to fit the model.