diffindiff 1.2.1__tar.gz → 1.2.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: diffindiff
3
- Version: 1.2.1
3
+ Version: 1.2.2
4
4
  Summary: diffindiff: Python library for convenient Difference-in-Differences Analyses
5
5
  Author: Thomas Wieland
6
6
  Author-email: geowieland@googlemail.com
@@ -24,6 +24,8 @@ Dynamic: summary
24
24
 
25
25
  This Python library is designed for performing Difference-in-Differences (DiD) analyses in a convenient way. It allows users to construct datasets, define treatment and control groups, and set treatment periods. DiD model analyses may be conducted with both datasets created by built-in functions and ready-to-use external datasets. Both simultaneous and staggered adoption are supported. The library allows for various extensions, such as two-way fixed effects models, group- or individual-specific effects, and post-treatment periods. Additionally, it includes functions for visualizing results, such as plotting DiD coefficients with confidence intervals and illustrating the temporal evolution of staggered treatments.
26
26
 
27
+ The diffindiff package is currently being extensively revised (v2.0.0 and following).
28
+
27
29
 
28
30
  ## Author
29
31
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  This Python library is designed for performing Difference-in-Differences (DiD) analyses in a convenient way. It allows users to construct datasets, define treatment and control groups, and set treatment periods. DiD model analyses may be conducted with both datasets created by built-in functions and ready-to-use external datasets. Both simultaneous and staggered adoption are supported. The library allows for various extensions, such as two-way fixed effects models, group- or individual-specific effects, and post-treatment periods. Additionally, it includes functions for visualizing results, such as plotting DiD coefficients with confidence intervals and illustrating the temporal evolution of staggered treatments.
4
4
 
5
+ The diffindiff package is currently being extensively revised (v2.0.0 and following).
6
+
5
7
 
6
8
  ## Author
7
9
 
@@ -2,8 +2,8 @@
2
2
  # Name: didanalysis (diffindiff)
3
3
  # Purpose: Analysis functions for difference-in-differences analyses
4
4
  # Author: Thomas Wieland (geowieland@googlemail.com)
5
- # Version: 1.2.0
6
- # Last update: 2025-03-25 19:30
5
+ # Version: 1.2.2
6
+ # Last update: 2025-04-03 06:55
7
7
  # Copyright (c) 2025 Thomas Wieland
8
8
  #-------------------------------------------------------------------------------
9
9
 
@@ -13,6 +13,7 @@ from statsmodels.formula.api import ols
13
13
  import numpy as np
14
14
  import matplotlib.pyplot as plt
15
15
  from matplotlib.dates import DateFormatter
16
+ import warnings
16
17
  from diffindiff import didtools
17
18
 
18
19
 
@@ -111,6 +112,8 @@ class did_model:
111
112
  self,
112
113
  full = True
113
114
  ):
115
+
116
+ warnings.warn("This function will be fundamentally changed in a future version (v2.0.0 and subsequent) of the diffindiff package.", FutureWarning)
114
117
 
115
118
  model_results = self.data[0]
116
119
  model_config = self.data[1]
@@ -497,6 +500,8 @@ class did_model:
497
500
 
498
501
  def effects(self):
499
502
 
503
+ warnings.warn("This function will be replaced by the treatment_effects() function in a future version (v2.0.0 and subsequent versions) of the diffindiff package.", FutureWarning)
504
+
500
505
  model_results = self.data[0]
501
506
 
502
507
  effects_df = pd.DataFrame (columns = ["effect_name", "coef", "SE", "t", "p", "CI_lower", "CI_upper"])
@@ -575,15 +580,21 @@ class did_model:
575
580
 
576
581
  def fixef(self):
577
582
 
583
+ warnings.warn("This function is deprecated and will be removed in a future version (v2.0.0 and subsequent) of the diffindiff package.", FutureWarning)
584
+
578
585
  fixed_effects = self.data[4]
579
586
  return fixed_effects
580
587
 
581
588
  def indef(self):
582
589
 
590
+ warnings.warn("This function is deprecated and will be removed in a future version (v2.0.0 and subsequent) of the diffindiff package.", FutureWarning)
591
+
583
592
  individual_effects = self.data[5]
584
593
  return individual_effects
585
594
 
586
595
  def groupef(self):
596
+
597
+ warnings.warn("This function is deprecated and will be removed in a future version (v2.0.0 and subsequent) of the diffindiff package.", FutureWarning)
587
598
 
588
599
  group_effects = self.data[6]
589
600
  return group_effects
@@ -981,7 +992,9 @@ class did_model:
981
992
  plot_size: list = [7, 6],
982
993
  scale_plot: bool = True
983
994
  ):
984
-
995
+
996
+ warnings.warn("This function is deprecated and will be removed in a future version (v2.0.0 and subsequent) of the diffindiff package.", FutureWarning)
997
+
985
998
  effects = self.effects()
986
999
 
987
1000
  if sort_by == "coef":
@@ -1035,6 +1048,8 @@ class did_model:
1035
1048
  central_tendency = "mean"
1036
1049
  ):
1037
1050
 
1051
+ warnings.warn("This function is deprecated and will be removed in a future version (v2.0.0 and subsequent) of the diffindiff package.", FutureWarning)
1052
+
1038
1053
  model_config = self.data[1]
1039
1054
  if not model_config["GTE"]:
1040
1055
  raise ValueError ("Model does not include group treatment effects. Set GTE=True an define grouping variable using group_by.")
@@ -1101,6 +1116,8 @@ class did_model:
1101
1116
  show_central_tendency = False,
1102
1117
  central_tendency = "mean"
1103
1118
  ):
1119
+
1120
+ warnings.warn("This function is deprecated and will be removed in a future version (v2.0.0 and subsequent) of the diffindiff package.", FutureWarning)
1104
1121
 
1105
1122
  model_config = self.data[1]
1106
1123
  if not model_config["ITE"]:
@@ -2,8 +2,8 @@
2
2
  # Name: diddata (diffindiff)
3
3
  # Purpose: Creating data for Difference-in-Differences Analysis
4
4
  # Author: Thomas Wieland (geowieland@googlemail.com)
5
- # Version: 1.2.1
6
- # Last update: 2025-03-25 20:16
5
+ # Version: 1.2.2
6
+ # Last update: 2025-04-03 06:59
7
7
  # Copyright (c) 2025 Thomas Wieland
8
8
  #-------------------------------------------------------------------------------
9
9
 
@@ -2,8 +2,8 @@
2
2
  # Name: didtools (diffindiff)
3
3
  # Purpose: Creating data for Difference-in-Differences Analysis
4
4
  # Author: Thomas Wieland (geowieland@googlemail.com)
5
- # Version: 1.2.0
6
- # Last update: 2025-03-25 19:27
5
+ # Version: 1.2.2
6
+ # Last update: 2025-04-03 06:54
7
7
  # Copyright (c) 2025 Thomas Wieland
8
8
  #-------------------------------------------------------------------------------
9
9
 
@@ -143,41 +143,47 @@ def is_parallel(
143
143
  pre_post = False,
144
144
  alpha = 0.05
145
145
  ):
146
-
147
- if pre_post:
148
- return None
149
-
146
+
150
147
  modeldata_isnotreatment = is_notreatment(
151
148
  data = data,
152
149
  unit_col = unit_col,
153
150
  treatment_col = treatment_col
154
- )
155
- if not modeldata_isnotreatment:
156
- return None
151
+ )
152
+
153
+ if pre_post or not modeldata_isnotreatment:
154
+ parallel = "not_tested"
155
+ test_ols_model = None
157
156
 
158
157
  treatment_group = modeldata_isnotreatment[1]
159
- first_day_of_treatment = min(data[(data[unit_col].isin(treatment_group)) & (data[treatment_col] == 1)][time_col])
160
158
 
161
- data_test = data[data[time_col] < first_day_of_treatment].copy()
162
- data_test["TG"] = 0
163
- data_test.loc[data_test[unit_col].isin(treatment_group), "TG"] = 1
164
-
165
- if "date_counter" not in data_test.columns:
166
- data_test = date_counter(
167
- df = data_test,
168
- date_col = time_col,
169
- new_col = "date_counter"
170
- )
171
- data_test["TG_x_t"] = data_test["TG"]*data_test["date_counter"]
172
-
173
- test_ols_model = ols(f'{outcome_col} ~ TG + date_counter + TG_x_t', data = data_test).fit()
174
- coef_TG_x_t_p = test_ols_model.pvalues["TG_x_t"]
175
-
176
- if coef_TG_x_t_p < alpha:
177
- parallel = False
159
+ if len(data[(data[unit_col].isin(treatment_group)) & (data[treatment_col] == 1)]) > 0:
160
+
161
+ first_day_of_treatment = min(data[(data[unit_col].isin(treatment_group)) & (data[treatment_col] == 1)][time_col])
162
+
163
+ data_test = data[data[time_col] < first_day_of_treatment].copy()
164
+ data_test["TG"] = 0
165
+ data_test.loc[data_test[unit_col].isin(treatment_group), "TG"] = 1
166
+
167
+ if "date_counter" not in data_test.columns:
168
+ data_test = date_counter(
169
+ df = data_test,
170
+ date_col = time_col,
171
+ new_col = "date_counter"
172
+ )
173
+ data_test["TG_x_t"] = data_test["TG"]*data_test["date_counter"]
174
+
175
+ test_ols_model = ols(f'{outcome_col} ~ TG + date_counter + TG_x_t', data = data_test).fit()
176
+ coef_TG_x_t_p = test_ols_model.pvalues["TG_x_t"]
177
+
178
+ if coef_TG_x_t_p < alpha:
179
+ parallel = False
180
+ else:
181
+ parallel = True
182
+
178
183
  else:
179
- parallel = True
180
-
184
+ parallel = "not_tested"
185
+ test_ols_model = None
186
+
181
187
  return [
182
188
  parallel,
183
189
  test_ols_model
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: diffindiff
3
- Version: 1.2.1
3
+ Version: 1.2.2
4
4
  Summary: diffindiff: Python library for convenient Difference-in-Differences Analyses
5
5
  Author: Thomas Wieland
6
6
  Author-email: geowieland@googlemail.com
@@ -24,6 +24,8 @@ Dynamic: summary
24
24
 
25
25
  This Python library is designed for performing Difference-in-Differences (DiD) analyses in a convenient way. It allows users to construct datasets, define treatment and control groups, and set treatment periods. DiD model analyses may be conducted with both datasets created by built-in functions and ready-to-use external datasets. Both simultaneous and staggered adoption are supported. The library allows for various extensions, such as two-way fixed effects models, group- or individual-specific effects, and post-treatment periods. Additionally, it includes functions for visualizing results, such as plotting DiD coefficients with confidence intervals and illustrating the temporal evolution of staggered treatments.
26
26
 
27
+ The diffindiff package is currently being extensively revised (v2.0.0 and following).
28
+
27
29
 
28
30
  ## Author
29
31
 
@@ -7,7 +7,7 @@ def read_README():
7
7
 
8
8
  setup(
9
9
  name='diffindiff',
10
- version='1.2.1',
10
+ version='1.2.2',
11
11
  description='diffindiff: Python library for convenient Difference-in-Differences Analyses',
12
12
  packages=find_packages(include=["diffindiff", "diffindiff.tests"]),
13
13
  include_package_data=True,
File without changes
File without changes