Skip to content

Commit a39a96f

Browse files
igerberclaude
andcommitted
fix: address CI review round 4 - panel=False guard, drop covariate_effects block
- P1: reject panel=False in data_generator_kwargs for panel-only estimators (TWFE, SA, Imputation, TwoStage, Stacked, Efficient); only CS supports repeated cross-sections under survey_config - P2: remove over-broad covariate_effects rejection (it affects baseline outcomes and ICC calibration, not realized population_att) - Add regression tests: panel=False rejected for TWFE, allowed for CS(panel=False) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a1d6199 commit a39a96f

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

diff_diff/power.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,12 +1943,16 @@ def simulate_power(
19431943
f"the input treatment_effect under covariate-interaction "
19441944
f"heterogeneity, which would make bias/coverage/RMSE misleading."
19451945
)
1946-
if "covariate_effects" in data_gen_kwargs:
1947-
raise ValueError(
1948-
"covariate_effects is not supported with survey_config. "
1949-
"Custom covariate effects can shift the realized population "
1950-
"ATT away from the input treatment_effect."
1951-
)
1946+
# Block panel=False for panel-only estimators. Only
1947+
# CallawaySantAnna supports repeated cross-sections.
1948+
if not data_gen_kwargs.get("panel", True):
1949+
_RCS_SUPPORTED = frozenset({"CallawaySantAnna"})
1950+
if estimator_name not in _RCS_SUPPORTED:
1951+
raise ValueError(
1952+
f"panel=False (repeated cross-sections) is not supported "
1953+
f"with {estimator_name} under survey_config. Only "
1954+
f"{sorted(_RCS_SUPPORTED)} support repeated cross-sections."
1955+
)
19521956

19531957
# SyntheticDiD placebo variance requires n_control > n_treated.
19541958
# Check after merging data_generator_kwargs so overrides of n_treated

tests/test_power.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,18 +2422,31 @@ def test_survey_rejects_te_covariate_interaction(self):
24222422
**_SIM_KW,
24232423
)
24242424

2425-
def test_survey_rejects_covariate_effects(self):
2426-
"""covariate_effects rejected (can shift population ATT)."""
2427-
with pytest.raises(ValueError, match="covariate_effects"):
2425+
def test_survey_rejects_panel_false_for_panel_only(self):
2426+
"""panel=False rejected for panel-only estimators (e.g., TWFE)."""
2427+
with pytest.raises(ValueError, match="panel=False.*not supported"):
24282428
simulate_power(
2429-
CallawaySantAnna(),
2430-
data_generator_kwargs={"covariate_effects": (0.5, 0.3)},
2429+
TwoWayFixedEffects(),
2430+
data_generator_kwargs={"panel": False},
24312431
survey_config=_SURVEY_CFG,
24322432
n_simulations=1,
24332433
seed=42,
24342434
**_SIM_KW,
24352435
)
24362436

2437+
def test_survey_allows_panel_false_for_cs(self):
2438+
"""panel=False allowed for CallawaySantAnna (supports RCS)."""
2439+
result = simulate_power(
2440+
CallawaySantAnna(panel=False),
2441+
treatment_effect=3.0,
2442+
data_generator_kwargs={"panel": False},
2443+
survey_config=_SURVEY_CFG,
2444+
n_simulations=10,
2445+
seed=42,
2446+
**_SIM_KW,
2447+
)
2448+
assert 0 <= result.power <= 1
2449+
24372450
# -- Closed-form deff tests --
24382451

24392452
def test_closed_form_deff_default(self):

0 commit comments

Comments
 (0)