diffindiff 2.0.7__tar.gz → 2.1.0__tar.gz

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.
Files changed (21) hide show
  1. {diffindiff-2.0.7 → diffindiff-2.1.0}/PKG-INFO +10 -4
  2. {diffindiff-2.0.7 → diffindiff-2.1.0}/README.md +9 -3
  3. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff/__init__.py +2 -1
  4. diffindiff-2.1.0/diffindiff/config.py +179 -0
  5. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff/didanalysis.py +716 -418
  6. diffindiff-2.1.0/diffindiff/didanalysis_helper.py +400 -0
  7. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff/diddata.py +245 -117
  8. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff/didtools.py +217 -102
  9. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff/tests/tests_diffindiff.py +8 -7
  10. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff.egg-info/PKG-INFO +10 -4
  11. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff.egg-info/SOURCES.txt +2 -0
  12. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff.egg-info/requires.txt +1 -0
  13. {diffindiff-2.0.7 → diffindiff-2.1.0}/setup.py +3 -2
  14. {diffindiff-2.0.7 → diffindiff-2.1.0}/MANIFEST.in +0 -0
  15. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff/tests/__init__.py +0 -0
  16. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff/tests/data/Corona_Hesse.xlsx +0 -0
  17. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff/tests/data/counties_DE.csv +0 -0
  18. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff/tests/data/curfew_DE.csv +0 -0
  19. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff.egg-info/dependency_links.txt +0 -0
  20. {diffindiff-2.0.7 → diffindiff-2.1.0}/diffindiff.egg-info/top_level.txt +0 -0
  21. {diffindiff-2.0.7 → diffindiff-2.1.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diffindiff
3
- Version: 2.0.7
3
+ Version: 2.1.0
4
4
  Summary: diffindiff: Python library for convenient Difference-in-Differences Analyses
5
5
  Author: Thomas Wieland
6
6
  Author-email: geowieland@googlemail.com
@@ -16,9 +16,15 @@ This Python library is designed for performing Difference-in-Differences (DiD) a
16
16
  Thomas Wieland [ORCID](https://orcid.org/0000-0001-5168-9846) [EMail](mailto:geowieland@googlemail.com)
17
17
 
18
18
 
19
- ## Updates v2.0.7
20
- - Bugfixes:
21
- - Specific definition of dependencies to ensure compatibility between statsmodels and scipy
19
+ ## Updates v2.1.0
20
+ - General:
21
+ - Increased modularization
22
+ - Increased harmonization with respect to outputs, internal naming etc.
23
+ - Extensions:
24
+ - Including treatment spillover effects in models
25
+ - Optional plotting of confidence or prediction intervals in didanalysis.DiffModel.plot()
26
+ - More plotting options in didanalysis.DiffModel.plot_treatment_effects()
27
+ - Optional progress messages for all functions with parameter verbose
22
28
 
23
29
 
24
30
  ## Features
@@ -8,9 +8,15 @@ This Python library is designed for performing Difference-in-Differences (DiD) a
8
8
  Thomas Wieland [ORCID](https://orcid.org/0000-0001-5168-9846) [EMail](mailto:geowieland@googlemail.com)
9
9
 
10
10
 
11
- ## Updates v2.0.7
12
- - Bugfixes:
13
- - Specific definition of dependencies to ensure compatibility between statsmodels and scipy
11
+ ## Updates v2.1.0
12
+ - General:
13
+ - Increased modularization
14
+ - Increased harmonization with respect to outputs, internal naming etc.
15
+ - Extensions:
16
+ - Including treatment spillover effects in models
17
+ - Optional plotting of confidence or prediction intervals in didanalysis.DiffModel.plot()
18
+ - More plotting options in didanalysis.DiffModel.plot_treatment_effects()
19
+ - Optional progress messages for all functions with parameter verbose
14
20
 
15
21
 
16
22
  ## Features
@@ -1,3 +1,4 @@
1
1
  from diffindiff.didanalysis import DiffModel, did_analysis
2
2
  from diffindiff.diddata import DiffGroups, create_groups, DiffTreatment, create_treatment, DiffData, merge_data, create_data
3
- from diffindiff.didtools import is_balanced, is_missing, is_simultaneous, is_notreatment, date_counter, check_columns, is_binary, is_parallel, unique, model_wrapper, treatment_times, clean_column_name, to_dummies
3
+ from diffindiff.didtools import is_balanced, is_missing, is_simultaneous, is_notreatment, date_counter, check_columns, is_binary, is_parallel, unique, model_wrapper, treatment_times, clean_column_name
4
+ from diffindiff.didanalysis_helper import create_fixed_effects, create_specific_time_trends, create_specific_treatment_effects, create_spillover
@@ -0,0 +1,179 @@
1
+ #-----------------------------------------------------------------------
2
+ # Name: config (diffindiff package)
3
+ # Purpose: Configuration for the diffindiff package
4
+ # Author: Thomas Wieland
5
+ # ORCID: 0000-0001-5168-9846
6
+ # mail: geowieland@googlemail.com
7
+ # Version: 1.0.0
8
+ # Last update: 2025-11-22 10:18
9
+ # Copyright (c) 2025 Thomas Wieland
10
+ #-----------------------------------------------------------------------
11
+
12
+ # Basic config:
13
+
14
+ VERBOSE = True
15
+
16
+ ROUND_PERCENT = 2
17
+
18
+ # Description texts:
19
+
20
+ DID_DESCRIPTION = "Difference in Differences (DiD) Analysis"
21
+ DDD_DESCRIPTION = "Difference in Difference in Differences (DDD) Analysis"
22
+
23
+ TREATMENT_DESCRIPTION = "Treatment"
24
+
25
+ TREATMENT_GROUP_DESCRIPTION = f"{TREATMENT_DESCRIPTION} group"
26
+ CONTROL_GROUP_DESCRIPTION = "Control group"
27
+ GROUPS_DESCRIPTION = f"{TREATMENT_DESCRIPTION} and {CONTROL_GROUP_DESCRIPTION}"
28
+
29
+ TREATMENT_PERIOD_DESCRIPTION = f"{TREATMENT_DESCRIPTION} period"
30
+ STUDY_PERIOD_DESCRIPTION = "Study period"
31
+
32
+ UNITS_DESCRIPTION = "Units"
33
+
34
+ DDD_GROUP_DESCRIPTION = "Group segmentation"
35
+
36
+ SUMMARY_LABELS = [
37
+ TREATMENT_DESCRIPTION,
38
+ UNITS_DESCRIPTION,
39
+ TREATMENT_GROUP_DESCRIPTION,
40
+ CONTROL_GROUP_DESCRIPTION
41
+ ]
42
+ SUMMARY_MAX_WIDTH = max(len(label) for label in SUMMARY_LABELS) + 1
43
+
44
+ # Data management:
45
+
46
+ DELIMITER = "_"
47
+ DELIMITER_INTERACT = "x"
48
+
49
+ COL_ABBREV = "col"
50
+
51
+ DUMMY_PREFIX = "DUMMY"
52
+ LOG_PREFIX = "log"
53
+ OBSERVED_SUFFIX = "observed"
54
+ EXPECTED_SUFFIX = "expected"
55
+ PREDICTED_SUFFIX = "pred"
56
+ CI_LOWER_SUFFIX = "CI_lower"
57
+ CI_UPPER_SUFFIX = "CI_upper"
58
+ PI_LOWER_SUFFIX = "PI_lower"
59
+ PI_UPPER_SUFFIX = "PI_upper"
60
+
61
+ TG_COL = "TG"
62
+ CG_COL = "CG"
63
+ TT_COL = "TT"
64
+ ATT_COL = "ATT"
65
+ TIME_COL = "t"
66
+ UNIT_COL = "unit"
67
+ UNIT_TIME_COL = f"{UNIT_COL}{DELIMITER}{TIME_COL}"
68
+ TIME_COUNTER_COL = "time_counter"
69
+
70
+
71
+ # Modeling config:
72
+
73
+ # Coefficients/effects types:
74
+
75
+ EFFECTS_TYPES = {
76
+ "ATE": {
77
+ "description": "Average treatment effect",
78
+ "model_results_key": "average_treatment_effects"
79
+ },
80
+ "AATE": {
81
+ "description": "Average after-treatment effect",
82
+ "model_results_key": "average_after_treatment_effects"
83
+ },
84
+ "beta_0": {
85
+ "description": "Control group baseline",
86
+ "model_results_key": "control_group_baseline"
87
+ },
88
+ "beta_1": {
89
+ "description": "Treatment group deviation",
90
+ "model_results_key": "treatment_group_deviation"
91
+ },
92
+ "delta_0": {
93
+ "description": "Non-treatment time effect",
94
+ "model_results_key": "non_treatment_time_effect"
95
+ },
96
+ "ATT": {
97
+ "description": "After-treatment time effect",
98
+ "model_results_key": "after_treatment_time_effects"
99
+ },
100
+ "FE": {
101
+ "description": "Fixed effects",
102
+ "model_results_key": "fixed_effects",
103
+ "types": {
104
+ 0: {
105
+ "FE": "unit",
106
+ "dummy_prefix": "UNIT",
107
+ "model_config_key": "FE_unit",
108
+ "description": "Fixed effects for observational units"
109
+ },
110
+ 1: {
111
+ "FE": "time",
112
+ "dummy_prefix": "TIME",
113
+ "model_config_key": "FE_time",
114
+ "description": "Fixed effects for time points"
115
+ },
116
+ 2: {
117
+ "FE": "group",
118
+ "dummy_prefix": "GROUP",
119
+ "model_config_key": "FE_group",
120
+ "description": "Fixed effects for groups"
121
+ },
122
+ }
123
+ },
124
+ "ITT": {
125
+ "description": "Individual time trends",
126
+ "model_results_key": "individual_time_trends",
127
+ "model_config_key": "ITT"
128
+ },
129
+ "ITE": {
130
+ "description": "Individual treatment effects",
131
+ "model_results_key": "individual_treatment_effects",
132
+ "model_config_key": "ITE"
133
+ },
134
+ "GTT": {
135
+ "description": "Group time trends",
136
+ "model_results_key": "group_time_trends",
137
+ "model_config_key": "GTT"
138
+ },
139
+ "GTE": {
140
+ "description": "Group treatment effects",
141
+ "model_results_key": "group_treatment_effects",
142
+ "model_config_key": "GTE"
143
+ },
144
+ "spillover": {
145
+ "description": "Treatment spillover effects",
146
+ "model_results_key": "treatment_spillover_effects",
147
+ "model_config_key": "spillover_effects"
148
+ }
149
+ }
150
+
151
+ FE_TYPES = [value["FE"] for value in EFFECTS_TYPES["FE"]["types"].values()]
152
+
153
+ # Time trends:
154
+ TIME_TRENDS_TYPES = [
155
+ list(EFFECTS_TYPES.keys())[7],
156
+ list(EFFECTS_TYPES.keys())[9]
157
+ ]
158
+
159
+ # Specific effects:
160
+ SPECIFIC_EFFFECTS_TYPES = [
161
+ list(EFFECTS_TYPES.keys())[8],
162
+ list(EFFECTS_TYPES.keys())[10]
163
+ ]
164
+
165
+ # Predictions:
166
+ PREDICTIONS_SUMMARY_FRAME_COLS = {
167
+ "mean": "Predicted mean",
168
+ "mean_se": "Predicted mean SE",
169
+ "mean_ci_lower": "Lower CI of mean",
170
+ "mean_ci_upper": "Upper CI of mean",
171
+ "obs_ci_lower": "Lower prediction interval",
172
+ "obs_ci_upper": "Upper prediction interval",
173
+ }
174
+ PREDICTIONS_SUMMARY_FRAME_COLS_LIST = list(PREDICTIONS_SUMMARY_FRAME_COLS.keys())
175
+ PREDICTIONS_SUMMARY_FRAME_DESCRIPTIONS = list(PREDICTIONS_SUMMARY_FRAME_COLS.values())
176
+
177
+ # Counterfactual:
178
+ COUNTERFAC_SUFFIX_CF = "counterfac"
179
+ COUNTERFAC_SUFFIX_PRED_CF = f"{DELIMITER}{PREDICTED_SUFFIX}{DELIMITER}{COUNTERFAC_SUFFIX_CF}"