nnpiv.semiparametrics.DML_dynamic

class nnpiv.semiparametrics.DML_dynamic(Y, D1, D2, X1=None, X2=None, V=None, v_values=None, include_V=True, ci_type='pointwise', loc_kernel='gau', bw_loc='silverman', estimator='MR', d1=1, d2=1, treatment_path=None, nu_score='regression', model1=<nnpiv.rkhs.rkhsiv.RKHSIVL2 object>, nn_1=False, alpha=0.05, n_folds=5, n_rep=1, inner_n_jobs=None, random_seed=123, prop_score=sklearn.linear_model.LogisticRegression, CHIM=False, verbose=True, fitargs1=None, opts=None)[source]

Debiased Machine Learning for two-period dynamic treatment effects.

The target is the path-specific counterfactual mean E[Y(d1, d2)] for the treatment path d=(d1,d2). For S1=(1, X1’)’ and S2=(1, X1’, X2’)’, define pi1_d(S1)=P(D1=d1|S1), pi2_d(S2)=P(D2=d2|S2,D1=d1), delta_d(W)=E[Y|S2,D1=d1,D2=d2], and nu_d(W)=E[delta_d(W)|S1,D1=d1]. In the package convention, the remaining nuisance weights are alpha_d(W)=1(D1=d1,D2=d2) / {pi1_d(S1) pi2_d(S2)} and eta_d(W)=1(D1=d1) / pi1_d(S1). The main estimator evaluates the doubly robust score

nu(W) + alpha(W) * {Y - delta(W)} + eta(W) * {delta(W) - nu(W)}.

This is the paper’s generic bilinear score with h1=nu, h2=delta, h3=alpha, and h4=eta.

The first-period state regression nu can be fitted either by regressing delta(W) on S1 among D1=d1 observations or by using the sequential doubly-robust learner (S-DRL) pseudo-outcome delta(W)+1(D2=d2)/pi2(S2){Y-delta(W)} among D1=d1 observations.

Parameters
  • Y (array-like) – Final outcome variable.

  • D1 (array-like) – Binary treatment in period 1.

  • D2 (array-like) – Binary treatment in period 2.

  • X1 (array-like, optional) – Baseline covariates for period 1.

  • X2 (array-like, optional) – Intermediate covariates observed after D1 and before D2.

  • V (array-like, optional) – Localization covariates. Supplying V changes the estimand to a finite-bandwidth kernel-ratio target. These are period-1 variables and are appended to X1 when include_V is True.

  • v_values (array-like, optional) – Values for localization.

  • include_V (bool, optional) – Include localization covariates in the nuisance models.

  • ci_type (str, optional) – Type of confidence interval (‘pointwise’, ‘uniform’).

  • loc_kernel (str, optional) – Kernel for localization. Options include ‘gau’, ‘epa’, ‘uni’, ‘tri’, etc.

  • bw_loc (str, optional) – Bandwidth for localization.

  • estimator (str, optional) – Estimator type (‘MR’, ‘OR’, ‘IPW’).

  • d1 (int, optional) – First-period treatment value in the target path.

  • d2 (int, optional) – Second-period treatment value in the target path.

  • treatment_path (tuple, optional) – Alternative way to provide (d1, d2). If supplied, overrides d1 and d2.

  • nu_score (str, optional) – Method used to fit nu_d(W): ‘regression’ or ‘S-DRL’.

  • model1 (estimator /(list), optional) – Model for the outcome stage. Outcome learners must implement the package NPIV-style interface fit(Z, T, Y) and predict(T). Since the dynamic estimator uses a nested sequential regression, pass a list [delta_model, nu_model] when the two stages use distinct models. If a single model is supplied, it is used for both delta_d(W) and nu_d(W).

  • nn_1 (bool /(list), optional) – Use neural network for the outcome stage. For sequential fitting, pass [delta_is_nn, nu_is_nn].

  • alpha (float, optional) – Significance level for confidence intervals.

  • n_folds (int, optional) – Number of folds for estimation.

  • n_rep (int, optional) – Number of repetitions for estimation.

  • inner_n_jobs (int, optional) – Number of parallel jobs for inner fold processing. If None, defaults to min(n_folds, available_cores).

  • random_seed (int, optional) – Seed for random number generator.

  • prop_score (estimator, optional) – Classification model with predict_proba for the sequential propensities.

  • CHIM (bool, optional) – Use CHIM method for dealing with limited overlap.

  • verbose (bool, optional) – Print progress information.

  • fitargs1 (dict /(list), optional) – Arguments for fitting the outcome stage. For sequential fitting, pass [delta_fitargs, nu_fitargs].

  • opts (dict, optional) – Additional options.