nnpiv.ensemble.EnsembleIVL2
- class nnpiv.ensemble.EnsembleIVL2(adversary='auto', learner='auto', n_iter=100, delta_scale='auto', delta_exp='auto', CV=False, alpha_scales='auto', n_alphas=30, n_folds=5)[source]
Empirical-L2-regularized ensemble IV estimator.
The effective learner penalty is
mu = alpha * delta_n**2, wheredelta_n = delta_scale / n**delta_exp. Cross-validation evaluates a critic trained on each training-fold residual through the held-out payoffmean(2 * residual * critic - critic**2).- Parameters
adversary (str or estimator) – Regression critic.
'auto'uses a shallowRandomForestRegressor.learner (str or estimator) – Regression learner.
'auto'uses a shallowRandomForestRegressor.n_iter (int) – Number of learners to average; must be positive.
delta_scale (str or float) – Numerator of
delta_n.'auto'uses 5.delta_exp (str or float) – Sample-size exponent in
delta_n.'auto'uses 0.4.CV (bool) – Whether to select
alphaby cross-validation.alpha_scales (str or iterable) – Candidate
alphascales.'auto'uses a geometric grid.n_alphas (int) – Size of the automatic candidate grid.
n_folds (int) – Number of cross-validation folds.
- best_alpha_
Selected scale when
CV=True.- Type
float
- fit(Z, T, Y, alpha=1.0, cross_validating=False)[source]
Fit the empirical-L2-regularized ensemble IV model.
- Parameters
Z (array-like) – Instrument covariates used by the critic.
T (array-like) – Covariates used by the learner function.
Y (array-like) – Scalar outcome.
alpha (float) – Positive scale in
mu = alpha * delta_n**2. Ignored whenCV=Trueon the outer fit.cross_validating (bool) – Internal guard that prevents recursive cross-validation while fitting a fold.
- Returns
Fitted ensemble IV model.
- Return type
self