@@ -476,3 +476,67 @@ def test_event_study_all_control_units():
476476
477477 # Check that result was created
478478 assert isinstance (result , cp .EventStudy )
479+
480+
481+ # ============================================================================
482+ # Tests for effect_summary
483+ # ============================================================================
484+
485+
486+ @pytest .mark .integration
487+ def test_event_study_pymc_effect_summary (mock_pymc_sample ):
488+ """Test EventStudy effect_summary method with PyMC model."""
489+ df = generate_event_study_data (n_units = 20 , n_time = 20 , treatment_time = 10 , seed = 42 )
490+
491+ result = cp .EventStudy (
492+ df ,
493+ formula = "y ~ C(unit) + C(time)" ,
494+ unit_col = "unit" ,
495+ time_col = "time" ,
496+ treat_time_col = "treat_time" ,
497+ event_window = (- 3 , 3 ),
498+ reference_event_time = - 1 ,
499+ model = cp .pymc_models .LinearRegression (sample_kwargs = sample_kwargs ),
500+ )
501+
502+ # Test effect_summary returns EffectSummary with table and text
503+ effect = result .effect_summary ()
504+ assert isinstance (effect .table , pd .DataFrame )
505+ assert isinstance (effect .text , str )
506+ assert "event_time" in effect .table .columns
507+ assert "mean" in effect .table .columns
508+
509+ # Check prose mentions key elements
510+ assert "Event study" in effect .text
511+ assert "k=" in effect .text
512+
513+ # Test with include_pretrend_check=False
514+ effect_no_pretrend = result .effect_summary (include_pretrend_check = False )
515+ assert isinstance (effect_no_pretrend .text , str )
516+
517+
518+ def test_event_study_sklearn_effect_summary ():
519+ """Test EventStudy effect_summary method with sklearn model."""
520+ df = generate_event_study_data (n_units = 20 , n_time = 20 , treatment_time = 10 , seed = 42 )
521+
522+ result = cp .EventStudy (
523+ df ,
524+ formula = "y ~ C(unit) + C(time)" ,
525+ unit_col = "unit" ,
526+ time_col = "time" ,
527+ treat_time_col = "treat_time" ,
528+ event_window = (- 3 , 3 ),
529+ reference_event_time = - 1 ,
530+ model = LinearRegression (),
531+ )
532+
533+ # Test effect_summary returns EffectSummary with table and text
534+ effect = result .effect_summary ()
535+ assert isinstance (effect .table , pd .DataFrame )
536+ assert isinstance (effect .text , str )
537+ assert "event_time" in effect .table .columns
538+ assert "mean" in effect .table .columns
539+
540+ # Check prose mentions key elements
541+ assert "Event study" in effect .text
542+ assert "k=" in effect .text
0 commit comments