Skip to content

Fix TWFE demeaning and SDID plot labels - #489

Open
AliFozooni wants to merge 1 commit into
matheusfacure:masterfrom
AliFozooni:agent/fix-sdid-demeaning-and-labels
Open

Fix TWFE demeaning and SDID plot labels#489
AliFozooni wants to merge 1 commit into
matheusfacure:masterfrom
AliFozooni:agent/fix-sdid-demeaning-and-labels

Conversation

@AliFozooni

Copy link
Copy Markdown

Summary

  • write the two-way fixed-effects objective with an explicit intercept and fixed-effect normalization
  • correct double demeaning by adding back the grand mean, and define unit, time, and grand means over the full panel
  • update the implementation to match the displayed transformation
  • restore the California and synthetic-control legend labels in the final SDID figure

Why this matters

Subtracting both unit and time means removes the grand mean twice. Adding it back is the conventional within transformation and keeps the transformed variables centered, including the intercept shown in the regression output. The treatment coefficient is unchanged in this balanced specification, but the derivation and implementation now agree. The plot labels also identify the observed and counterfactual series correctly.

Validation

  • executed the affected notebook sequence and regenerated the two affected outputs
  • built the full Jupyter Book successfully
  • visually checked the regenerated SDID figure
  • validated the notebook JSON and checked the diff for whitespace errors

Closes #415
Closes #484
Closes #364
Closes #382
Closes #466

@AliFozooni
AliFozooni marked this pull request as ready for review August 15, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant