@@ -27,7 +27,7 @@ The simplest DiD design has two groups (treated/control) and two periods (pre/po
2727 n_units = 100 ,
2828 n_periods = 10 ,
2929 treatment_effect = 5.0 ,
30- treatment_start = 5 ,
30+ treatment_period = 5 ,
3131 treatment_fraction = 0.5 ,
3232 )
3333
@@ -36,8 +36,8 @@ The simplest DiD design has two groups (treated/control) and two periods (pre/po
3636 results = did.fit(
3737 data,
3838 outcome = ' outcome' ,
39- treated = ' treated' ,
40- post = ' post'
39+ treatment = ' treated' ,
40+ time = ' post'
4141 )
4242
4343 # View results
@@ -75,8 +75,8 @@ Control for confounders with the ``covariates`` parameter:
7575 results = did.fit(
7676 data,
7777 outcome = ' outcome' ,
78- treated = ' treated' ,
79- post = ' post' ,
78+ treatment = ' treated' ,
79+ time = ' post' ,
8080 covariates = [' age' , ' income' ]
8181 )
8282
@@ -87,8 +87,8 @@ For panel data, cluster standard errors at the unit level:
8787
8888.. code-block :: python
8989
90- did = DifferenceInDifferences(cluster_col = ' unit_id' )
91- results = did.fit(data, outcome = ' y' , treated = ' treated' , post = ' post' )
90+ did = DifferenceInDifferences(cluster = ' unit_id' )
91+ results = did.fit(data, outcome = ' y' , treatment = ' treated' , time = ' post' )
9292
9393 Two-Way Fixed Effects
9494---------------------
@@ -103,7 +103,7 @@ For panel data with multiple periods:
103103 results = twfe.fit(
104104 data,
105105 outcome = ' outcome' ,
106- treated = ' treated' ,
106+ treatment = ' treated' ,
107107 unit = ' unit_id' ,
108108 time = ' period'
109109 )
@@ -117,19 +117,19 @@ Examine treatment effects over time:
117117
118118 from diff_diff import MultiPeriodDiD
119119
120- event = MultiPeriodDiD(reference_period = - 1 )
120+ event = MultiPeriodDiD()
121121 results = event.fit(
122122 data,
123123 outcome = ' outcome' ,
124- treated = ' treated' ,
124+ treatment = ' treated' ,
125125 time = ' period' ,
126- unit = ' unit_id ' ,
127- treatment_start = 5
126+ post_periods = [ 5 , 6 , 7 , 8 , 9 ] ,
127+ reference_period = 4
128128 )
129129
130130 # Plot the event study
131- from diff_diff import plot_event_study
132- fig = plot_event_study(results)
131+ from diff_diff.visualization import plot_event_study
132+ ax = plot_event_study(results)
133133
134134 Staggered Adoption
135135------------------
@@ -150,7 +150,7 @@ When treatment is adopted at different times across units:
150150 )
151151
152152 # View aggregated treatment effect
153- print (f " Overall ATT: { results.att :.3f } " )
153+ print (f " Overall ATT: { results.overall_att :.3f } " )
154154
155155 Parallel Trends Testing
156156-----------------------
@@ -159,15 +159,14 @@ Test the key identifying assumption:
159159
160160.. code-block :: python
161161
162- from diff_diff import check_parallel_trends
162+ from diff_diff.utils import check_parallel_trends
163163
164164 trends_result = check_parallel_trends(
165165 data,
166166 outcome = ' outcome' ,
167- unit = ' unit_id' ,
168167 time = ' period' ,
169- treated = ' treated' ,
170- pre_periods = 4
168+ treatment_group = ' treated' ,
169+ pre_periods = [ 0 , 1 , 2 , 3 ]
171170 )
172171
173172 if trends_result[' p_value' ] > 0.05 :
@@ -180,13 +179,13 @@ Assess robustness to parallel trends violations with Honest DiD:
180179
181180.. code-block :: python
182181
183- from diff_diff import HonestDiD, DeltaRM
182+ from diff_diff import HonestDiD
184183
185184 # Compute bounds under relative magnitudes restriction
186- honest = HonestDiD(delta = DeltaRM( M_bar = 1.0 ) )
185+ honest = HonestDiD(method = " relative_magnitude " , M = 1.0 )
187186 bounds = honest.fit(event_study_results)
188187
189- print (f " Robust CI: [ { bounds.robust_ci[ 0 ] :.3f } , { bounds.robust_ci[ 1 ] :.3f } ] " )
188+ print (f " Robust CI: [ { bounds.ci_lb :.3f } , { bounds.ci_ub :.3f } ] " )
190189
191190 Next Steps
192191----------
0 commit comments