diff-diff 1.2.0__py3-none-any.whl → 1.2.1__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 CHANGED
@@ -98,7 +98,7 @@ from diff_diff.visualization import (
98
98
  plot_sensitivity,
99
99
  )
100
100
 
101
- __version__ = "1.2.0"
101
+ __version__ = "1.2.1"
102
102
  __all__ = [
103
103
  # Estimators
104
104
  "DifferenceInDifferences",
diff_diff/staggered.py CHANGED
@@ -1603,30 +1603,25 @@ class CallawaySantAnna:
1603
1603
  weights * bootstrap_atts_gt[b, gt_indices]
1604
1604
  )
1605
1605
 
1606
- # Compute bootstrap statistics
1607
- # ATT(g,t) statistics
1606
+ # Compute bootstrap statistics for ATT(g,t)
1608
1607
  gt_ses = {}
1609
1608
  gt_cis = {}
1610
1609
  gt_p_values = {}
1611
1610
 
1612
1611
  for j, gt in enumerate(gt_pairs):
1613
- original_effect = original_atts[j]
1614
- boot_dist = bootstrap_atts_gt[:, j]
1615
-
1616
- se = float(np.std(boot_dist, ddof=1))
1617
- ci = self._compute_percentile_ci(boot_dist, self.alpha)
1618
- p_value = self._compute_bootstrap_pvalue(original_effect, boot_dist)
1619
-
1612
+ se, ci, p_value = self._compute_effect_bootstrap_stats(
1613
+ original_atts[j], bootstrap_atts_gt[:, j]
1614
+ )
1620
1615
  gt_ses[gt] = se
1621
1616
  gt_cis[gt] = ci
1622
1617
  gt_p_values[gt] = p_value
1623
1618
 
1624
- # Overall ATT statistics
1625
- overall_se = float(np.std(bootstrap_overall, ddof=1))
1626
- overall_ci = self._compute_percentile_ci(bootstrap_overall, self.alpha)
1627
- overall_p_value = self._compute_bootstrap_pvalue(original_overall, bootstrap_overall)
1619
+ # Compute bootstrap statistics for overall ATT
1620
+ overall_se, overall_ci, overall_p_value = self._compute_effect_bootstrap_stats(
1621
+ original_overall, bootstrap_overall
1622
+ )
1628
1623
 
1629
- # Event study statistics
1624
+ # Compute bootstrap statistics for event study effects
1630
1625
  event_study_ses = None
1631
1626
  event_study_cis = None
1632
1627
  event_study_p_values = None
@@ -1637,16 +1632,14 @@ class CallawaySantAnna:
1637
1632
  event_study_p_values = {}
1638
1633
 
1639
1634
  for e in rel_periods:
1640
- original_effect = event_study_info[e]['effect']
1641
- boot_dist = bootstrap_event_study[e]
1642
-
1643
- event_study_ses[e] = float(np.std(boot_dist, ddof=1))
1644
- event_study_cis[e] = self._compute_percentile_ci(boot_dist, self.alpha)
1645
- event_study_p_values[e] = self._compute_bootstrap_pvalue(
1646
- original_effect, boot_dist
1635
+ se, ci, p_value = self._compute_effect_bootstrap_stats(
1636
+ event_study_info[e]['effect'], bootstrap_event_study[e]
1647
1637
  )
1638
+ event_study_ses[e] = se
1639
+ event_study_cis[e] = ci
1640
+ event_study_p_values[e] = p_value
1648
1641
 
1649
- # Group effect statistics
1642
+ # Compute bootstrap statistics for group effects
1650
1643
  group_effect_ses = None
1651
1644
  group_effect_cis = None
1652
1645
  group_effect_p_values = None
@@ -1657,14 +1650,12 @@ class CallawaySantAnna:
1657
1650
  group_effect_p_values = {}
1658
1651
 
1659
1652
  for g in groups:
1660
- original_effect = group_agg_info[g]['effect']
1661
- boot_dist = bootstrap_group[g]
1662
-
1663
- group_effect_ses[g] = float(np.std(boot_dist, ddof=1))
1664
- group_effect_cis[g] = self._compute_percentile_ci(boot_dist, self.alpha)
1665
- group_effect_p_values[g] = self._compute_bootstrap_pvalue(
1666
- original_effect, boot_dist
1653
+ se, ci, p_value = self._compute_effect_bootstrap_stats(
1654
+ group_agg_info[g]['effect'], bootstrap_group[g]
1667
1655
  )
1656
+ group_effect_ses[g] = se
1657
+ group_effect_cis[g] = ci
1658
+ group_effect_p_values[g] = p_value
1668
1659
 
1669
1660
  return CSBootstrapResults(
1670
1661
  n_bootstrap=self.n_bootstrap,
@@ -1817,6 +1808,35 @@ class CallawaySantAnna:
1817
1808
 
1818
1809
  return float(p_value)
1819
1810
 
1811
+ def _compute_effect_bootstrap_stats(
1812
+ self,
1813
+ original_effect: float,
1814
+ boot_dist: np.ndarray,
1815
+ ) -> Tuple[float, Tuple[float, float], float]:
1816
+ """
1817
+ Compute bootstrap statistics for a single effect.
1818
+
1819
+ Parameters
1820
+ ----------
1821
+ original_effect : float
1822
+ Original point estimate.
1823
+ boot_dist : np.ndarray
1824
+ Bootstrap distribution of the effect.
1825
+
1826
+ Returns
1827
+ -------
1828
+ se : float
1829
+ Bootstrap standard error.
1830
+ ci : Tuple[float, float]
1831
+ Percentile confidence interval.
1832
+ p_value : float
1833
+ Bootstrap p-value.
1834
+ """
1835
+ se = float(np.std(boot_dist, ddof=1))
1836
+ ci = self._compute_percentile_ci(boot_dist, self.alpha)
1837
+ p_value = self._compute_bootstrap_pvalue(original_effect, boot_dist)
1838
+ return se, ci, p_value
1839
+
1820
1840
  def get_params(self) -> Dict[str, Any]:
1821
1841
  """Get estimator parameters (sklearn-compatible)."""
1822
1842
  return {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diff-diff
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: A library for Difference-in-Differences causal inference analysis
5
5
  Author: diff-diff contributors
6
6
  License-Expression: MIT
@@ -1,4 +1,4 @@
1
- diff_diff/__init__.py,sha256=Phf8CQcV-bH2obbW0W5TQRgeWyq6Z7cLJxGwwZyNj_A,4169
1
+ diff_diff/__init__.py,sha256=qBIk3EAm-AzDDnul7ruuq1O6rLC8sNdfi9GW8F3h_g4,4169
2
2
  diff_diff/bacon.py,sha256=AgQOtGUN-gtMh8q6KsGmOiVF4uCCFG2IexbeKS0mBlQ,36819
3
3
  diff_diff/diagnostics.py,sha256=1yOKfauW9RP7alXYlaR8oq5tmol5T24idsfqzyAxBPQ,29572
4
4
  diff_diff/estimators.py,sha256=4Jj9xAnF39EWElweFoYUa91YnyELelT8mRDzZKZWj4E,35807
@@ -7,13 +7,13 @@ diff_diff/power.py,sha256=cpdbWG-lxqAKjeAoM_8Un8gYaDwADIeYdWUIkEBfXZg,42800
7
7
  diff_diff/prep.py,sha256=bTPXTWajBzdNVPcLQ_IBYjww63DhgS3Z37V9h5tsIgc,46985
8
8
  diff_diff/pretrends.py,sha256=NeYjTxC9s_iIj-3beYupiDAZROYaLjFIzbm-76XhqKk,36538
9
9
  diff_diff/results.py,sha256=qmostsUy7uqX2VjAT7qSUPS3W1q_K8bqBB2JuUri_-k,22097
10
- diff_diff/staggered.py,sha256=F-7CPXGtIEhpcaxQnJYXTfz3AvCoqVFOdZsHL7Izy8c,69010
10
+ diff_diff/staggered.py,sha256=DPx6VRlF67IryT8cXYq_gfdclQZEDHIYzQakR3OSvWA,69465
11
11
  diff_diff/sun_abraham.py,sha256=ux6igLILW7Y1bh3TK33P781ATUWJS4fkwrjnpTARPlU,41685
12
12
  diff_diff/synthetic_did.py,sha256=g_Es1H-Yi1UozGXyoW2ZDK8x7BrEEf73DWNqJD9mpGk,19303
13
13
  diff_diff/twfe.py,sha256=iB-hvmOQd97B5_3hWvoaYGCSfcwJbXfg6towhRYD_Bw,11931
14
14
  diff_diff/utils.py,sha256=F0vRZ32k065VsP4YcAcUdaF_dom834QOgYj3ZaGS2pI,44211
15
15
  diff_diff/visualization.py,sha256=1X074fUk_fZleAlHdSGYc-ihdShY9FJ6WoKmBFCV6oI,51537
16
- diff_diff-1.2.0.dist-info/METADATA,sha256=hmqUTkQVtv9oPW05KtB87lvl3NkOX4gjc8nhrWOK9qo,71789
17
- diff_diff-1.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
- diff_diff-1.2.0.dist-info/top_level.txt,sha256=-7mAFgjEQIA2okDLHlh5pDwBQXnsO1Z85qvtHjZILoQ,10
19
- diff_diff-1.2.0.dist-info/RECORD,,
16
+ diff_diff-1.2.1.dist-info/METADATA,sha256=-UoafGfh9HkQo_fGGcoSprBm-51fY1E4W7vab_tOPLs,71789
17
+ diff_diff-1.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
+ diff_diff-1.2.1.dist-info/top_level.txt,sha256=-7mAFgjEQIA2okDLHlh5pDwBQXnsO1Z85qvtHjZILoQ,10
19
+ diff_diff-1.2.1.dist-info/RECORD,,