diffindiff 2.5.1__tar.gz → 2.5.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.
- {diffindiff-2.5.1 → diffindiff-2.5.2}/PKG-INFO +11 -7
- {diffindiff-2.5.1 → diffindiff-2.5.2}/README.md +10 -6
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff/config.py +3 -3
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff/didanalysis.py +11 -6
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff/didanalysis_helper.py +2 -2
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff/diddata.py +58 -5
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff.egg-info/PKG-INFO +11 -7
- {diffindiff-2.5.1 → diffindiff-2.5.2}/setup.py +1 -1
- {diffindiff-2.5.1 → diffindiff-2.5.2}/MANIFEST.in +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff/__init__.py +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff/didtools.py +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff/tests/__init__.py +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff/tests/data/Corona_Hesse.xlsx +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff/tests/data/counties_DE.csv +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff/tests/data/curfew_DE.csv +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff/tests/tests_diffindiff.py +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff.egg-info/SOURCES.txt +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff.egg-info/dependency_links.txt +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff.egg-info/requires.txt +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/diffindiff.egg-info/top_level.txt +0 -0
- {diffindiff-2.5.1 → diffindiff-2.5.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: diffindiff
|
|
3
|
-
Version: 2.5.
|
|
3
|
+
Version: 2.5.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
|
|
@@ -22,14 +22,14 @@ Thomas Wieland [ORCID](https://orcid.org/0000-0001-5168-9846) [EMail](mailto:geo
|
|
|
22
22
|
- 💻 GitHub Repository: [diffindiff_official](https://github.com/geowieland/diffindiff_official)
|
|
23
23
|
- 📄 DOI (Zenodo): [10.5281/zenodo.18656820](https://doi.org/10.5281/zenodo.18656820)
|
|
24
24
|
|
|
25
|
-
A
|
|
25
|
+
A case study that utilizes the diffindiff library is available on [arXiv](https://arxiv.org/abs/2605.21464).
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
## Citation
|
|
29
29
|
|
|
30
30
|
If you use this software, please cite:
|
|
31
31
|
|
|
32
|
-
Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.5.
|
|
32
|
+
Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.5.2) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
## Installation
|
|
@@ -53,6 +53,7 @@ pip install git+https://github.com/geowieland/diffindiff_official.git
|
|
|
53
53
|
- Define custom treatment and control groups as well as treatment periods
|
|
54
54
|
- Create ready-to-fit DiD data objects
|
|
55
55
|
- Create predictive counterfactuals
|
|
56
|
+
- Create a synthetic control unit
|
|
56
57
|
- **DiD analysis**:
|
|
57
58
|
- Perform standard DiD analysis with pre-post data
|
|
58
59
|
- Perform DiD analysis with two-way fixed effects models
|
|
@@ -66,6 +67,7 @@ pip install git+https://github.com/geowieland/diffindiff_official.git
|
|
|
66
67
|
- Including after-treatment period
|
|
67
68
|
- Perform Triple Difference (DDD) analysis
|
|
68
69
|
- Perform DiD analysis with demeaned data
|
|
70
|
+
- Perform Synthetic DiD analysis
|
|
69
71
|
- **Diagnosis tools and extensions of analyses**:
|
|
70
72
|
- Add own counterfactuals or create counterfactuals based on machine learning or OLS regression models
|
|
71
73
|
- Bonferroni correction for treatment effects
|
|
@@ -177,9 +179,11 @@ See the /tests directory for usage examples of most of the included functions.
|
|
|
177
179
|
This software was developed without the use of AI-generated code. The Continue Agent in Microsoft Visual Studio Code using the GPT-5 mini model (by OpenAI) was used solely to assist in drafting and refining docstrings for documentation. The corresponding guidelines and constraints defined by the author are documented in `AGENTS-docstrings.md` in the [public GitHub repository](https://github.com/geowieland/diffindiff_official).
|
|
178
180
|
|
|
179
181
|
|
|
180
|
-
## What's new (v2.5.
|
|
182
|
+
## What's new (v2.5.2)
|
|
181
183
|
|
|
184
|
+
- Extensions
|
|
185
|
+
- New functions DiffData.get_synthetic_control_weightings() and DiffData.get_synthetic_control_fitmetrics() for accessing control unit weightings and fit metrics of the synthetic control unit
|
|
182
186
|
- Bugfixes
|
|
183
|
-
-
|
|
184
|
-
|
|
185
|
-
- Some
|
|
187
|
+
- DiffModel.placebo() now checks control group size and returns warning when no. of control units is equal to 1, not allowing any placebo test
|
|
188
|
+
- Other
|
|
189
|
+
- Some updates of documentation and README
|
|
@@ -14,14 +14,14 @@ Thomas Wieland [ORCID](https://orcid.org/0000-0001-5168-9846) [EMail](mailto:geo
|
|
|
14
14
|
- 💻 GitHub Repository: [diffindiff_official](https://github.com/geowieland/diffindiff_official)
|
|
15
15
|
- 📄 DOI (Zenodo): [10.5281/zenodo.18656820](https://doi.org/10.5281/zenodo.18656820)
|
|
16
16
|
|
|
17
|
-
A
|
|
17
|
+
A case study that utilizes the diffindiff library is available on [arXiv](https://arxiv.org/abs/2605.21464).
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
## Citation
|
|
21
21
|
|
|
22
22
|
If you use this software, please cite:
|
|
23
23
|
|
|
24
|
-
Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.5.
|
|
24
|
+
Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.5.2) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
## Installation
|
|
@@ -45,6 +45,7 @@ pip install git+https://github.com/geowieland/diffindiff_official.git
|
|
|
45
45
|
- Define custom treatment and control groups as well as treatment periods
|
|
46
46
|
- Create ready-to-fit DiD data objects
|
|
47
47
|
- Create predictive counterfactuals
|
|
48
|
+
- Create a synthetic control unit
|
|
48
49
|
- **DiD analysis**:
|
|
49
50
|
- Perform standard DiD analysis with pre-post data
|
|
50
51
|
- Perform DiD analysis with two-way fixed effects models
|
|
@@ -58,6 +59,7 @@ pip install git+https://github.com/geowieland/diffindiff_official.git
|
|
|
58
59
|
- Including after-treatment period
|
|
59
60
|
- Perform Triple Difference (DDD) analysis
|
|
60
61
|
- Perform DiD analysis with demeaned data
|
|
62
|
+
- Perform Synthetic DiD analysis
|
|
61
63
|
- **Diagnosis tools and extensions of analyses**:
|
|
62
64
|
- Add own counterfactuals or create counterfactuals based on machine learning or OLS regression models
|
|
63
65
|
- Bonferroni correction for treatment effects
|
|
@@ -169,9 +171,11 @@ See the /tests directory for usage examples of most of the included functions.
|
|
|
169
171
|
This software was developed without the use of AI-generated code. The Continue Agent in Microsoft Visual Studio Code using the GPT-5 mini model (by OpenAI) was used solely to assist in drafting and refining docstrings for documentation. The corresponding guidelines and constraints defined by the author are documented in `AGENTS-docstrings.md` in the [public GitHub repository](https://github.com/geowieland/diffindiff_official).
|
|
170
172
|
|
|
171
173
|
|
|
172
|
-
## What's new (v2.5.
|
|
174
|
+
## What's new (v2.5.2)
|
|
173
175
|
|
|
176
|
+
- Extensions
|
|
177
|
+
- New functions DiffData.get_synthetic_control_weightings() and DiffData.get_synthetic_control_fitmetrics() for accessing control unit weightings and fit metrics of the synthetic control unit
|
|
174
178
|
- Bugfixes
|
|
175
|
-
-
|
|
176
|
-
|
|
177
|
-
- Some
|
|
179
|
+
- DiffModel.placebo() now checks control group size and returns warning when no. of control units is equal to 1, not allowing any placebo test
|
|
180
|
+
- Other
|
|
181
|
+
- Some updates of documentation and README
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
# Author: Thomas Wieland
|
|
5
5
|
# ORCID: 0000-0001-5168-9846
|
|
6
6
|
# mail: geowieland@googlemail.com
|
|
7
|
-
# Version: 1.0.
|
|
8
|
-
# Last update: 2026-07-
|
|
7
|
+
# Version: 1.0.23
|
|
8
|
+
# Last update: 2026-07-14 19:48
|
|
9
9
|
# Copyright (c) 2025-2026 Thomas Wieland
|
|
10
10
|
#-----------------------------------------------------------------------
|
|
11
11
|
|
|
12
12
|
# Basic config:
|
|
13
13
|
|
|
14
14
|
PACKAGE_NAME = "diffindiff"
|
|
15
|
-
PACKAGE_VERSION = "2.5.
|
|
15
|
+
PACKAGE_VERSION = "2.5.2"
|
|
16
16
|
|
|
17
17
|
VERBOSE = False
|
|
18
18
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
# Author: Thomas Wieland
|
|
5
5
|
# ORCID: 0000-0001-5168-9846
|
|
6
6
|
# mail: geowieland@googlemail.com
|
|
7
|
-
# Version: 2.4.
|
|
8
|
-
# Last update: 2026-07-
|
|
7
|
+
# Version: 2.4.3
|
|
8
|
+
# Last update: 2026-07-14 19:49
|
|
9
9
|
# Copyright (c) 2024-2026 Thomas Wieland
|
|
10
10
|
#-----------------------------------------------------------------------
|
|
11
11
|
|
|
@@ -1422,10 +1422,15 @@ class DiffModel:
|
|
|
1422
1422
|
model_data_c[time_col] = pd.to_datetime(model_data_c[time_col])
|
|
1423
1423
|
model_data_c[unit_col] = model_data_c[unit_col].astype(str)
|
|
1424
1424
|
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1425
|
+
if control_group_N < 2:
|
|
1426
|
+
print(f"WARNING: Model includes one control unit only: '{control_group[0]}'. Placebo analysis requires size of control group >1. Original model is returned.")
|
|
1427
|
+
return self
|
|
1428
|
+
|
|
1429
|
+
else:
|
|
1430
|
+
units_random_sample = model_data_c[unit_col].sample(
|
|
1431
|
+
n = int(round(divide*control_group_N*resample, 0)),
|
|
1432
|
+
random_state = random_state
|
|
1433
|
+
).astype(str).tolist()
|
|
1429
1434
|
|
|
1430
1435
|
model_data_c[TG_col_] = 0
|
|
1431
1436
|
model_data_c.loc[(model_data_c[unit_col].isin(units_random_sample)), TG_col_] = 1
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
# Author: Thomas Wieland
|
|
5
5
|
# ORCID: 0000-0001-5168-9846
|
|
6
6
|
# mail: geowieland@googlemail.com
|
|
7
|
-
# Version: 1.2.
|
|
8
|
-
# Last update: 2026-07-
|
|
7
|
+
# Version: 1.2.3
|
|
8
|
+
# Last update: 2026-07-14 19:44
|
|
9
9
|
# Copyright (c) 2025-2026 Thomas Wieland
|
|
10
10
|
#-----------------------------------------------------------------------
|
|
11
11
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
# Author: Thomas Wieland
|
|
5
5
|
# ORCID: 0000-0001-5168-9846
|
|
6
6
|
# mail: geowieland@googlemail.com
|
|
7
|
-
# Version: 2.3.
|
|
8
|
-
# Last update: 2026-07-
|
|
7
|
+
# Version: 2.3.2
|
|
8
|
+
# Last update: 2026-07-16 18:52
|
|
9
9
|
# Copyright (c) 2024-2026 Thomas Wieland
|
|
10
10
|
#-----------------------------------------------------------------------
|
|
11
11
|
|
|
@@ -815,7 +815,8 @@ class DiffData:
|
|
|
815
815
|
unit_time_col_original,
|
|
816
816
|
covariates,
|
|
817
817
|
treatment_cols,
|
|
818
|
-
timestamp
|
|
818
|
+
timestamp,
|
|
819
|
+
synthetic_control
|
|
819
820
|
):
|
|
820
821
|
|
|
821
822
|
"""
|
|
@@ -840,6 +841,8 @@ class DiffData:
|
|
|
840
841
|
Mapping of treatment columns metadata.
|
|
841
842
|
timestamp : dict
|
|
842
843
|
Timestamp metadata.
|
|
844
|
+
synthetic_control : dict
|
|
845
|
+
If included, data for a synthetic control unit, else None.
|
|
843
846
|
Returns
|
|
844
847
|
-------
|
|
845
848
|
None
|
|
@@ -855,7 +858,8 @@ class DiffData:
|
|
|
855
858
|
unit_time_col_original,
|
|
856
859
|
covariates,
|
|
857
860
|
treatment_cols,
|
|
858
|
-
timestamp
|
|
861
|
+
timestamp,
|
|
862
|
+
synthetic_control
|
|
859
863
|
]
|
|
860
864
|
|
|
861
865
|
def get_did_modeldata_df (self):
|
|
@@ -1060,6 +1064,46 @@ class DiffData:
|
|
|
1060
1064
|
"""
|
|
1061
1065
|
|
|
1062
1066
|
return self.data[7]
|
|
1067
|
+
|
|
1068
|
+
def get_synthetic_control_weightings(self):
|
|
1069
|
+
|
|
1070
|
+
"""
|
|
1071
|
+
Return weightings of the synthetic control unit (if included in the DiffData object).
|
|
1072
|
+
|
|
1073
|
+
Returns
|
|
1074
|
+
-------
|
|
1075
|
+
pandas.DataFrame
|
|
1076
|
+
Weighting by control unit.
|
|
1077
|
+
|
|
1078
|
+
Examples
|
|
1079
|
+
--------
|
|
1080
|
+
>>> my_diffdata.get_synthetic_control_weightings()
|
|
1081
|
+
"""
|
|
1082
|
+
|
|
1083
|
+
if len(self.data[8]) > 0:
|
|
1084
|
+
return self.data[8]["weights"]
|
|
1085
|
+
else:
|
|
1086
|
+
print("The DiffData object does not include a synthetic control unit.")
|
|
1087
|
+
|
|
1088
|
+
def get_synthetic_control_fitmetrics(self):
|
|
1089
|
+
|
|
1090
|
+
"""
|
|
1091
|
+
Return fit metrics of the synthetic control unit (if included in the DiffData object).
|
|
1092
|
+
|
|
1093
|
+
Returns
|
|
1094
|
+
-------
|
|
1095
|
+
list
|
|
1096
|
+
Fit metrics (dict) and data points with residuals (pandas.DataFrame).
|
|
1097
|
+
|
|
1098
|
+
Examples
|
|
1099
|
+
--------
|
|
1100
|
+
>>> my_diffdata.get_synthetic_control_fitmetrics()
|
|
1101
|
+
"""
|
|
1102
|
+
|
|
1103
|
+
if len(self.data[8]) > 0:
|
|
1104
|
+
return self.data[8]["fit_metrics"]
|
|
1105
|
+
else:
|
|
1106
|
+
print("The DiffData object does not include a synthetic control unit.")
|
|
1063
1107
|
|
|
1064
1108
|
def add_covariates(
|
|
1065
1109
|
self,
|
|
@@ -2033,6 +2077,14 @@ class DiffData:
|
|
|
2033
2077
|
verbose = False
|
|
2034
2078
|
)
|
|
2035
2079
|
|
|
2080
|
+
self.data[7] = helper.create_timestamp(function="add_synthetic")
|
|
2081
|
+
|
|
2082
|
+
self.data[8] = {
|
|
2083
|
+
"weights": weights_pd,
|
|
2084
|
+
"fit_metrics": synthetic_fit_metrics,
|
|
2085
|
+
"process_unit": process_unit
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2036
2088
|
return self
|
|
2037
2089
|
|
|
2038
2090
|
def summary(self):
|
|
@@ -2489,7 +2541,8 @@ def merge_data(
|
|
|
2489
2541
|
unit_time_col_original,
|
|
2490
2542
|
[],
|
|
2491
2543
|
treatment_cols,
|
|
2492
|
-
timestamp
|
|
2544
|
+
timestamp,
|
|
2545
|
+
{}
|
|
2493
2546
|
)
|
|
2494
2547
|
|
|
2495
2548
|
if verbose:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: diffindiff
|
|
3
|
-
Version: 2.5.
|
|
3
|
+
Version: 2.5.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
|
|
@@ -22,14 +22,14 @@ Thomas Wieland [ORCID](https://orcid.org/0000-0001-5168-9846) [EMail](mailto:geo
|
|
|
22
22
|
- 💻 GitHub Repository: [diffindiff_official](https://github.com/geowieland/diffindiff_official)
|
|
23
23
|
- 📄 DOI (Zenodo): [10.5281/zenodo.18656820](https://doi.org/10.5281/zenodo.18656820)
|
|
24
24
|
|
|
25
|
-
A
|
|
25
|
+
A case study that utilizes the diffindiff library is available on [arXiv](https://arxiv.org/abs/2605.21464).
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
## Citation
|
|
29
29
|
|
|
30
30
|
If you use this software, please cite:
|
|
31
31
|
|
|
32
|
-
Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.5.
|
|
32
|
+
Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.5.2) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
## Installation
|
|
@@ -53,6 +53,7 @@ pip install git+https://github.com/geowieland/diffindiff_official.git
|
|
|
53
53
|
- Define custom treatment and control groups as well as treatment periods
|
|
54
54
|
- Create ready-to-fit DiD data objects
|
|
55
55
|
- Create predictive counterfactuals
|
|
56
|
+
- Create a synthetic control unit
|
|
56
57
|
- **DiD analysis**:
|
|
57
58
|
- Perform standard DiD analysis with pre-post data
|
|
58
59
|
- Perform DiD analysis with two-way fixed effects models
|
|
@@ -66,6 +67,7 @@ pip install git+https://github.com/geowieland/diffindiff_official.git
|
|
|
66
67
|
- Including after-treatment period
|
|
67
68
|
- Perform Triple Difference (DDD) analysis
|
|
68
69
|
- Perform DiD analysis with demeaned data
|
|
70
|
+
- Perform Synthetic DiD analysis
|
|
69
71
|
- **Diagnosis tools and extensions of analyses**:
|
|
70
72
|
- Add own counterfactuals or create counterfactuals based on machine learning or OLS regression models
|
|
71
73
|
- Bonferroni correction for treatment effects
|
|
@@ -177,9 +179,11 @@ See the /tests directory for usage examples of most of the included functions.
|
|
|
177
179
|
This software was developed without the use of AI-generated code. The Continue Agent in Microsoft Visual Studio Code using the GPT-5 mini model (by OpenAI) was used solely to assist in drafting and refining docstrings for documentation. The corresponding guidelines and constraints defined by the author are documented in `AGENTS-docstrings.md` in the [public GitHub repository](https://github.com/geowieland/diffindiff_official).
|
|
178
180
|
|
|
179
181
|
|
|
180
|
-
## What's new (v2.5.
|
|
182
|
+
## What's new (v2.5.2)
|
|
181
183
|
|
|
184
|
+
- Extensions
|
|
185
|
+
- New functions DiffData.get_synthetic_control_weightings() and DiffData.get_synthetic_control_fitmetrics() for accessing control unit weightings and fit metrics of the synthetic control unit
|
|
182
186
|
- Bugfixes
|
|
183
|
-
-
|
|
184
|
-
|
|
185
|
-
- Some
|
|
187
|
+
- DiffModel.placebo() now checks control group size and returns warning when no. of control units is equal to 1, not allowing any placebo test
|
|
188
|
+
- Other
|
|
189
|
+
- Some updates of documentation and README
|
|
@@ -7,7 +7,7 @@ def read_README():
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name='diffindiff',
|
|
10
|
-
version='2.5.
|
|
10
|
+
version='2.5.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|