Generalized method of moments estimator with JAX-powered derivatives.
The estimator uses JAX to evaluate gradients and Jacobians while relying on the pyensmallen optimization backend for numerical minimization. It supports two-step GMM through an optimal weighting matrix update and provides asymptotic as well as bootstrap-based uncertainty estimates.
Compute bootstrap standard errors using the fast score bootstrap method.
This method is computationally more efficient than the full bootstrap. It bootstraps the score functions (moment conditions) rather than recomputing the GMM estimator for each bootstrap sample.
Parameters
Name
Type
Description
Default
n_bootstrap
int
Number of bootstrap draws.
1000
seed
int or None
Random seed for reproducibility.
None
verbose
bool
Whether to print bootstrap progress.
False
Returns
Name
Type
Description
ndarray of shape (n_params,)
Bootstrap standard errors for the fitted parameter vector.
compute_asymptotic_variance
EnsmallenEstimator.compute_asymptotic_variance()
Compute the asymptotic covariance matrix and standard errors.
Returns
Name
Type
Description
None
Updates vtheta_ and std_errors_ in place.
fit
EnsmallenEstimator.fit(z, y, x, verbose=False)
Fit the GMM model using PyEnsmallen optimizer with JAX gradients.
Parameters
Name
Type
Description
Default
z
ndarray of shape (n_samples, n_instruments)
Instrument matrix.
required
y
ndarray of shape (n_samples,)
Outcome vector.
required
x
ndarray of shape (n_samples, n_params)
Regressor matrix. Include a column of ones if an intercept is desired.
required
verbose
bool
Whether to print optimization and inference warnings.
False
Returns
Name
Type
Description
None
Stores fitted parameters and inference results on the estimator.
gmm_objective
EnsmallenEstimator.gmm_objective(beta, gradient)
Compute GMM objective function value and gradient for PyEnsmallen.
Parameters
Name
Type
Description
Default
beta
ndarray of shape (n_params,)
Candidate parameter vector.
required
gradient
ndarray of shape (n_params,)
Output array filled in-place with the gradient of the criterion.
required
Returns
Name
Type
Description
float
Value of the GMM objective at beta.
iv_moment
EnsmallenEstimator.iv_moment(z, y, x, beta)
Standard IV moment function: z_i * (y_i - x_i’β).
Works with both NumPy and JAX arrays.
Parameters
Name
Type
Description
Default
z
ndarray
Instrument matrix.
required
y
ndarray
Outcome vector.
required
x
ndarray
Regressor matrix.
required
beta
ndarray
Parameter vector.
required
Returns
Name
Type
Description
ndarray
Matrix of per-observation moment conditions.
jacobian_moment_cond
EnsmallenEstimator.jacobian_moment_cond()
Compute Jacobian of moment conditions using JAX.
Returns
Name
Type
Description
ndarray of shape (n_moments, n_params)
Jacobian of the mean moment vector with respect to the parameters.