|
| 1 | +Triple Difference (DDD) |
| 2 | +======================= |
| 3 | + |
| 4 | +Triple Difference estimator for designs where treatment requires two criteria. |
| 5 | + |
| 6 | +This module implements the methodology from Ortiz-Villavicencio & Sant'Anna (2025), |
| 7 | +which correctly handles covariate adjustment in DDD designs. Unlike naive implementations |
| 8 | +that difference two DiDs, this approach provides valid estimates when identification |
| 9 | +requires conditioning on covariates. |
| 10 | + |
| 11 | +**When to use DDD instead of DiD:** |
| 12 | + |
| 13 | +DDD allows for violations of parallel trends that are: |
| 14 | + |
| 15 | +- Group-specific (e.g., economic shocks affecting treatment states) |
| 16 | +- Partition-specific (e.g., trends affecting women everywhere) |
| 17 | + |
| 18 | +As long as these biases are additive, DDD differences them out. The key assumption |
| 19 | +is that the *differential* trend between eligible and ineligible units would be |
| 20 | +the same across groups. |
| 21 | + |
| 22 | +**Reference:** Ortiz-Villavicencio, M., & Sant'Anna, P. H. C. (2025). Better Understanding |
| 23 | +Triple Differences Estimators. *Working Paper*. `arXiv:2505.09942 <https://arxiv.org/abs/2505.09942>`_ |
| 24 | + |
| 25 | +.. module:: diff_diff.triple_diff |
| 26 | + |
| 27 | +TripleDifference |
| 28 | +---------------- |
| 29 | + |
| 30 | +Main estimator class for Triple Difference designs. |
| 31 | + |
| 32 | +.. autoclass:: diff_diff.TripleDifference |
| 33 | + :members: |
| 34 | + :undoc-members: |
| 35 | + :show-inheritance: |
| 36 | + :inherited-members: |
| 37 | + |
| 38 | + .. rubric:: Methods |
| 39 | + |
| 40 | + .. autosummary:: |
| 41 | + |
| 42 | + ~TripleDifference.fit |
| 43 | + ~TripleDifference.get_params |
| 44 | + ~TripleDifference.set_params |
| 45 | + |
| 46 | +TripleDifferenceResults |
| 47 | +----------------------- |
| 48 | + |
| 49 | +Results container for Triple Difference estimation. |
| 50 | + |
| 51 | +.. autoclass:: diff_diff.TripleDifferenceResults |
| 52 | + :members: |
| 53 | + :undoc-members: |
| 54 | + :show-inheritance: |
| 55 | + |
| 56 | + .. rubric:: Methods |
| 57 | + |
| 58 | + .. autosummary:: |
| 59 | + |
| 60 | + ~TripleDifferenceResults.summary |
| 61 | + ~TripleDifferenceResults.print_summary |
| 62 | + ~TripleDifferenceResults.to_dict |
| 63 | + ~TripleDifferenceResults.to_dataframe |
| 64 | + |
| 65 | +Convenience Function |
| 66 | +-------------------- |
| 67 | + |
| 68 | +.. autofunction:: diff_diff.triple_difference |
| 69 | + |
| 70 | +Estimation Methods |
| 71 | +------------------ |
| 72 | + |
| 73 | +The estimator supports three estimation methods: |
| 74 | + |
| 75 | +.. list-table:: |
| 76 | + :header-rows: 1 |
| 77 | + :widths: 15 35 50 |
| 78 | + |
| 79 | + * - Method |
| 80 | + - Description |
| 81 | + - When to use |
| 82 | + * - ``"dr"`` |
| 83 | + - Doubly robust |
| 84 | + - Recommended. Consistent if either outcome or propensity model is correct |
| 85 | + * - ``"reg"`` |
| 86 | + - Regression adjustment |
| 87 | + - Simple outcome regression with full interactions |
| 88 | + * - ``"ipw"`` |
| 89 | + - Inverse probability weighting |
| 90 | + - When propensity score model is well-specified |
| 91 | + |
| 92 | +Example Usage |
| 93 | +------------- |
| 94 | + |
| 95 | +Basic usage:: |
| 96 | + |
| 97 | + from diff_diff import TripleDifference |
| 98 | + |
| 99 | + ddd = TripleDifference(estimation_method='dr') |
| 100 | + results = ddd.fit( |
| 101 | + data, |
| 102 | + outcome='wages', |
| 103 | + group='policy_state', # 1=state enacted policy, 0=control state |
| 104 | + partition='female', # 1=women (affected by policy), 0=men |
| 105 | + time='post' # 1=post-policy, 0=pre-policy |
| 106 | + ) |
| 107 | + results.print_summary() |
| 108 | + |
| 109 | +With covariates:: |
| 110 | + |
| 111 | + results = ddd.fit( |
| 112 | + data, |
| 113 | + outcome='wages', |
| 114 | + group='policy_state', |
| 115 | + partition='female', |
| 116 | + time='post', |
| 117 | + covariates=['age', 'education', 'experience'] |
| 118 | + ) |
| 119 | + |
| 120 | +Using the convenience function:: |
| 121 | + |
| 122 | + from diff_diff import triple_difference |
| 123 | + |
| 124 | + results = triple_difference( |
| 125 | + data, |
| 126 | + outcome='wages', |
| 127 | + group='policy_state', |
| 128 | + partition='female', |
| 129 | + time='post', |
| 130 | + estimation_method='dr' |
| 131 | + ) |
0 commit comments