@@ -1357,6 +1357,57 @@ def test_callaway_santanna_replicate_bootstrap_rejected(self):
13571357 survey_design = sd ,
13581358 )
13591359
1360+ def test_twfe_replicate_rejected (self ):
1361+ """TwoWayFixedEffects should reject replicate-weight designs."""
1362+ from diff_diff .twfe import TwoWayFixedEffects
1363+
1364+ data , rep_cols = TestEstimatorReplicateWeights ._make_staggered_replicate_data ()
1365+ sd = SurveyDesign (
1366+ weights = "weight" , replicate_weights = rep_cols ,
1367+ replicate_method = "JK1" ,
1368+ )
1369+ with pytest .raises (NotImplementedError , match = "TwoWayFixedEffects" ):
1370+ TwoWayFixedEffects ().fit (
1371+ data , outcome = "outcome" , treatment = "first_treat" ,
1372+ unit = "unit" , time = "time" , survey_design = sd ,
1373+ )
1374+
1375+ def test_stacked_did_replicate_rejected (self ):
1376+ """StackedDiD should reject replicate-weight designs."""
1377+ from diff_diff import StackedDiD
1378+
1379+ data , rep_cols = TestEstimatorReplicateWeights ._make_staggered_replicate_data ()
1380+ sd = SurveyDesign (
1381+ weights = "weight" , replicate_weights = rep_cols ,
1382+ replicate_method = "JK1" ,
1383+ )
1384+ with pytest .raises (NotImplementedError , match = "StackedDiD" ):
1385+ StackedDiD ().fit (
1386+ data , outcome = "outcome" , unit = "unit" , time = "time" ,
1387+ first_treat = "first_treat" , survey_design = sd ,
1388+ )
1389+
1390+ def test_invalid_replicate_scale_rejected (self ):
1391+ """Negative or zero replicate_scale should be rejected."""
1392+ with pytest .raises (ValueError , match = "positive finite" ):
1393+ SurveyDesign (
1394+ weights = "w" , replicate_weights = ["r1" , "r2" ],
1395+ replicate_method = "JK1" , replicate_scale = - 1.0 ,
1396+ )
1397+ with pytest .raises (ValueError , match = "positive finite" ):
1398+ SurveyDesign (
1399+ weights = "w" , replicate_weights = ["r1" , "r2" ],
1400+ replicate_method = "JK1" , replicate_scale = 0.0 ,
1401+ )
1402+
1403+ def test_invalid_replicate_rscales_rejected (self ):
1404+ """Negative replicate_rscales should be rejected."""
1405+ with pytest .raises (ValueError , match = "non-negative" ):
1406+ SurveyDesign (
1407+ weights = "w" , replicate_weights = ["r1" , "r2" ],
1408+ replicate_method = "JK1" , replicate_rscales = [- 1.0 , 1.0 ],
1409+ )
1410+
13601411
13611412# =============================================================================
13621413# Effective-sample and d.f. consistency tests
0 commit comments