Skip to content

Commit cd73917

Browse files
igerberclaude
andcommitted
Fix CI review Round 13: per-period path uses raw Y under trends_linear
P1: When trends_linear=True without controls, _compute_per_period_dids and _compute_cohort_recentered_inputs now use raw y_pivot outcomes (not the first-differenced Z_mat). Previously the per-period path would double-difference the already-differenced outcomes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d20efde commit cd73917

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

diff_diff/chaisemartin_dhaultfoeuille.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,9 @@ def fit(
11471147
# path (L_max >= 1). The per-period path uses binary
11481148
# joiner/leaver categorization and is not part of the DID^X
11491149
# contract (Web Appendix Section 1.2).
1150-
Y_mat=Y_mat_raw if controls is not None else Y_mat,
1150+
# Use raw outcomes for per-period DID when controls or
1151+
# trends_linear is active (both transform Y_mat).
1152+
Y_mat=Y_mat_raw if controls is not None else (y_pivot.to_numpy() if _is_trends_linear else Y_mat),
11511153
N_mat=N_mat_orig,
11521154
periods=all_periods,
11531155
)
@@ -1581,7 +1583,8 @@ def fit(
15811583
) = _compute_cohort_recentered_inputs(
15821584
D_mat=D_mat,
15831585
# Phase 1 IF uses per-period structure: use raw outcomes
1584-
Y_mat=Y_mat_raw if controls is not None else Y_mat,
1586+
# when controls or trends_linear transform Y_mat.
1587+
Y_mat=Y_mat_raw if controls is not None else (y_pivot.to_numpy() if _is_trends_linear else Y_mat),
15851588
N_mat=N_mat_orig,
15861589
n_10_t_arr=n_10_t_arr,
15871590
n_00_t_arr=n_00_t_arr,

0 commit comments

Comments
 (0)