diff_diff.TROP#
- class diff_diff.TROP[source]#
Bases:
TROPLocalMixin,TROPGlobalMixinTriply Robust Panel (TROP) estimator.
Implements the exact methodology from Athey, Imbens, Qu & Viviano (2025). TROP combines three robustness components:
Nuclear norm regularized factor model: Estimates interactive fixed effects L_it via matrix completion with nuclear norm penalty ||L||_*
Exponential distance-based unit weights: ω_j = exp(-λ_unit × d(j,i)) where d(j,i) is the RMSE of outcome differences between units
Exponential time decay weights: θ_s = exp(-λ_time × \(|s-t|\)) weighting pre-treatment periods by proximity to treatment
Tuning parameters (λ_time, λ_unit, λ_nn) are selected via leave-one-out cross-validation on control observations.
- Parameters:
method (str, default='local') –
Estimation method to use:
’local’: Per-observation model fitting following Algorithm 2 of Athey et al. (2025). Computes observation-specific weights and fits a model for each treated observation, averaging the individual treatment effects. More flexible but computationally intensive.
’global’: Computationally efficient adaptation using the (1-W) masking principle from Eq. 2. Fits a single model on control observations with global weights, then computes per-observation treatment effects as residuals: tau_it = Y_it - mu - alpha_i - beta_t - L_it for treated cells. ATT is the mean of these effects. For the paper’s full per-treated-cell estimator, use
method='local'.
lambda_time_grid (list, optional) – Grid of time weight decay parameters. 0.0 = uniform weights (disabled). Must not contain inf. Default: [0, 0.1, 0.5, 1, 2, 5].
lambda_unit_grid (list, optional) – Grid of unit weight decay parameters. 0.0 = uniform weights (disabled). Must not contain inf. Default: [0, 0.1, 0.5, 1, 2, 5].
lambda_nn_grid (list, optional) – Grid of nuclear norm regularization parameters. inf = factor model disabled (L=0). Default: [0, 0.01, 0.1, 1].
max_iter (int, default=100) – Maximum iterations for nuclear norm optimization.
tol (float, default=1e-6) – Convergence tolerance for optimization.
alpha (float, default=0.05) – Significance level for confidence intervals.
n_bootstrap (int, default=200) – Number of bootstrap replications for variance estimation. Must be >= 2.
seed (int, optional) – Random seed for reproducibility.
- results_#
Estimation results after calling fit().
- Type:
Examples
>>> from diff_diff import TROP >>> trop = TROP() >>> results = trop.fit( ... data, ... outcome='outcome', ... treatment='treated', ... unit='unit', ... time='period', ... ) >>> results.print_summary()
References
Athey, S., Imbens, G. W., Qu, Z., & Viviano, D. (2025). Triply Robust Panel Estimators. Working Paper. https://arxiv.org/abs/2508.21536
Methods
__init__([method, lambda_time_grid, ...])fit(data, outcome, treatment, unit, time[, ...])Fit the TROP model.
get_params()Get estimator parameters.
set_params(**params)Set estimator parameters.
Attributes
CONVERGENCE_TOL_SVDmax_itertoln_bootstrapseedlambda_time_gridlambda_unit_gridlambda_nn_gridalpha- __init__(method='local', lambda_time_grid=None, lambda_unit_grid=None, lambda_nn_grid=None, max_iter=100, tol=1e-06, alpha=0.05, n_bootstrap=200, seed=None)[source]#
- classmethod __new__(*args, **kwargs)#