Skip to content

Commit 36d4eca

Browse files
igerberclaude
andcommitted
Align TROP implementation with reference and improve numerical stability
Key changes to match the reference implementation: 1. Unit distance computation: Now computes RMSE from the average of treated units over pre-treatment periods, matching the paper's Equation 3. 2. Time distance computation: Centers weights around the treatment period midpoint (T - T_treat/2) rather than individual observations. 3. Global weight matrix: Computes weights once as outer product of unit and time weights, matching reference implementation. 4. Numerical stability improvements: - Truncated SVD reconstruction using only non-zero singular values - Input/output sanitization for NaN/Inf values - Suppress expected numerical warnings during ill-conditioned matmul - Proper handling of edge cases in soft-thresholding All 23 tests pass with no warnings. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent a00d284 commit 36d4eca

1 file changed

Lines changed: 136 additions & 115 deletions

File tree

0 commit comments

Comments
 (0)