diff-diff 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diff_diff/__init__.py +167 -0
- diff_diff/bacon.py +1027 -0
- diff_diff/diagnostics.py +876 -0
- diff_diff/estimators.py +976 -0
- diff_diff/honest_did.py +1493 -0
- diff_diff/power.py +1350 -0
- diff_diff/prep.py +1338 -0
- diff_diff/results.py +690 -0
- diff_diff/staggered.py +1853 -0
- diff_diff/sun_abraham.py +1198 -0
- diff_diff/synthetic_did.py +540 -0
- diff_diff/twfe.py +357 -0
- diff_diff/utils.py +1350 -0
- diff_diff/visualization.py +1391 -0
- diff_diff-1.1.0.dist-info/METADATA +1954 -0
- diff_diff-1.1.0.dist-info/RECORD +18 -0
- diff_diff-1.1.0.dist-info/WHEEL +5 -0
- diff_diff-1.1.0.dist-info/top_level.txt +1 -0
diff_diff/__init__.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""
|
|
2
|
+
diff-diff: A library for Difference-in-Differences analysis.
|
|
3
|
+
|
|
4
|
+
This library provides sklearn-like estimators for causal inference
|
|
5
|
+
using the difference-in-differences methodology.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from diff_diff.bacon import (
|
|
9
|
+
BaconDecomposition,
|
|
10
|
+
BaconDecompositionResults,
|
|
11
|
+
Comparison2x2,
|
|
12
|
+
bacon_decompose,
|
|
13
|
+
)
|
|
14
|
+
from diff_diff.diagnostics import (
|
|
15
|
+
PlaceboTestResults,
|
|
16
|
+
leave_one_out_test,
|
|
17
|
+
permutation_test,
|
|
18
|
+
placebo_group_test,
|
|
19
|
+
placebo_timing_test,
|
|
20
|
+
run_all_placebo_tests,
|
|
21
|
+
run_placebo_test,
|
|
22
|
+
)
|
|
23
|
+
from diff_diff.estimators import (
|
|
24
|
+
DifferenceInDifferences,
|
|
25
|
+
MultiPeriodDiD,
|
|
26
|
+
SyntheticDiD,
|
|
27
|
+
TwoWayFixedEffects,
|
|
28
|
+
)
|
|
29
|
+
from diff_diff.honest_did import (
|
|
30
|
+
DeltaRM,
|
|
31
|
+
DeltaSD,
|
|
32
|
+
DeltaSDRM,
|
|
33
|
+
HonestDiD,
|
|
34
|
+
HonestDiDResults,
|
|
35
|
+
SensitivityResults,
|
|
36
|
+
compute_honest_did,
|
|
37
|
+
sensitivity_plot,
|
|
38
|
+
)
|
|
39
|
+
from diff_diff.power import (
|
|
40
|
+
PowerAnalysis,
|
|
41
|
+
PowerResults,
|
|
42
|
+
SimulationPowerResults,
|
|
43
|
+
compute_mde,
|
|
44
|
+
compute_power,
|
|
45
|
+
compute_sample_size,
|
|
46
|
+
simulate_power,
|
|
47
|
+
)
|
|
48
|
+
from diff_diff.prep import (
|
|
49
|
+
aggregate_to_cohorts,
|
|
50
|
+
balance_panel,
|
|
51
|
+
create_event_time,
|
|
52
|
+
generate_did_data,
|
|
53
|
+
make_post_indicator,
|
|
54
|
+
make_treatment_indicator,
|
|
55
|
+
rank_control_units,
|
|
56
|
+
summarize_did_data,
|
|
57
|
+
validate_did_data,
|
|
58
|
+
wide_to_long,
|
|
59
|
+
)
|
|
60
|
+
from diff_diff.results import (
|
|
61
|
+
DiDResults,
|
|
62
|
+
MultiPeriodDiDResults,
|
|
63
|
+
PeriodEffect,
|
|
64
|
+
SyntheticDiDResults,
|
|
65
|
+
)
|
|
66
|
+
from diff_diff.staggered import (
|
|
67
|
+
CallawaySantAnna,
|
|
68
|
+
CallawaySantAnnaResults,
|
|
69
|
+
CSBootstrapResults,
|
|
70
|
+
GroupTimeEffect,
|
|
71
|
+
)
|
|
72
|
+
from diff_diff.sun_abraham import (
|
|
73
|
+
SABootstrapResults,
|
|
74
|
+
SunAbraham,
|
|
75
|
+
SunAbrahamResults,
|
|
76
|
+
)
|
|
77
|
+
from diff_diff.utils import (
|
|
78
|
+
WildBootstrapResults,
|
|
79
|
+
check_parallel_trends,
|
|
80
|
+
check_parallel_trends_robust,
|
|
81
|
+
equivalence_test_trends,
|
|
82
|
+
wild_bootstrap_se,
|
|
83
|
+
)
|
|
84
|
+
from diff_diff.visualization import (
|
|
85
|
+
plot_bacon,
|
|
86
|
+
plot_event_study,
|
|
87
|
+
plot_group_effects,
|
|
88
|
+
plot_honest_event_study,
|
|
89
|
+
plot_power_curve,
|
|
90
|
+
plot_sensitivity,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
__version__ = "1.1.0"
|
|
94
|
+
__all__ = [
|
|
95
|
+
# Estimators
|
|
96
|
+
"DifferenceInDifferences",
|
|
97
|
+
"TwoWayFixedEffects",
|
|
98
|
+
"MultiPeriodDiD",
|
|
99
|
+
"SyntheticDiD",
|
|
100
|
+
"CallawaySantAnna",
|
|
101
|
+
"SunAbraham",
|
|
102
|
+
# Bacon Decomposition
|
|
103
|
+
"BaconDecomposition",
|
|
104
|
+
"BaconDecompositionResults",
|
|
105
|
+
"Comparison2x2",
|
|
106
|
+
"bacon_decompose",
|
|
107
|
+
"plot_bacon",
|
|
108
|
+
# Results
|
|
109
|
+
"DiDResults",
|
|
110
|
+
"MultiPeriodDiDResults",
|
|
111
|
+
"SyntheticDiDResults",
|
|
112
|
+
"PeriodEffect",
|
|
113
|
+
"CallawaySantAnnaResults",
|
|
114
|
+
"CSBootstrapResults",
|
|
115
|
+
"GroupTimeEffect",
|
|
116
|
+
"SunAbrahamResults",
|
|
117
|
+
"SABootstrapResults",
|
|
118
|
+
# Visualization
|
|
119
|
+
"plot_event_study",
|
|
120
|
+
"plot_group_effects",
|
|
121
|
+
"plot_sensitivity",
|
|
122
|
+
"plot_honest_event_study",
|
|
123
|
+
# Parallel trends testing
|
|
124
|
+
"check_parallel_trends",
|
|
125
|
+
"check_parallel_trends_robust",
|
|
126
|
+
"equivalence_test_trends",
|
|
127
|
+
# Wild cluster bootstrap
|
|
128
|
+
"WildBootstrapResults",
|
|
129
|
+
"wild_bootstrap_se",
|
|
130
|
+
# Placebo tests / diagnostics
|
|
131
|
+
"PlaceboTestResults",
|
|
132
|
+
"run_placebo_test",
|
|
133
|
+
"placebo_timing_test",
|
|
134
|
+
"placebo_group_test",
|
|
135
|
+
"permutation_test",
|
|
136
|
+
"leave_one_out_test",
|
|
137
|
+
"run_all_placebo_tests",
|
|
138
|
+
# Data preparation utilities
|
|
139
|
+
"make_treatment_indicator",
|
|
140
|
+
"make_post_indicator",
|
|
141
|
+
"wide_to_long",
|
|
142
|
+
"balance_panel",
|
|
143
|
+
"validate_did_data",
|
|
144
|
+
"summarize_did_data",
|
|
145
|
+
"generate_did_data",
|
|
146
|
+
"create_event_time",
|
|
147
|
+
"aggregate_to_cohorts",
|
|
148
|
+
"rank_control_units",
|
|
149
|
+
# Honest DiD sensitivity analysis
|
|
150
|
+
"HonestDiD",
|
|
151
|
+
"HonestDiDResults",
|
|
152
|
+
"SensitivityResults",
|
|
153
|
+
"DeltaSD",
|
|
154
|
+
"DeltaRM",
|
|
155
|
+
"DeltaSDRM",
|
|
156
|
+
"compute_honest_did",
|
|
157
|
+
"sensitivity_plot",
|
|
158
|
+
# Power analysis
|
|
159
|
+
"PowerAnalysis",
|
|
160
|
+
"PowerResults",
|
|
161
|
+
"SimulationPowerResults",
|
|
162
|
+
"compute_mde",
|
|
163
|
+
"compute_power",
|
|
164
|
+
"compute_sample_size",
|
|
165
|
+
"simulate_power",
|
|
166
|
+
"plot_power_curve",
|
|
167
|
+
]
|