Skip to content

Commit 1e6bcd1

Browse files
igerberclaude
andcommitted
Update stale Rust doc comments and test docstring per review
Fix P3 items from code review: - Replace remaining "joint"/"twostep" wording in Rust doc comments and section headers with "global"/"local" - Rewrite TestTROPGlobalMethod docstring to match current global method semantics (single control-only fit with post-hoc residuals) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e432660 commit 1e6bcd1

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

rust/src/trop.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,12 +1081,12 @@ pub fn bootstrap_trop_variance<'py>(
10811081
}
10821082

10831083
// ============================================================================
1084-
// Joint method implementation
1084+
// Global method implementation
10851085
// ============================================================================
10861086

1087-
/// Compute global weights for joint method estimation.
1087+
/// Compute global weights for global method estimation.
10881088
///
1089-
/// Unlike twostep (which computes per-observation weights), joint uses global
1089+
/// Unlike local (which computes per-observation weights), global uses
10901090
/// weights based on:
10911091
/// - Time weights: distance to center of treated block
10921092
/// - Unit weights: RMSE to average treated trajectory over pre-periods
@@ -1196,7 +1196,7 @@ fn compute_joint_weights(
11961196
delta
11971197
}
11981198

1199-
/// Solve joint TWFE via weighted least squares (no low-rank, no tau).
1199+
/// Solve global TWFE via weighted least squares (no low-rank, no tau).
12001200
///
12011201
/// Minimizes: min Σ δ_{it}(Y_{it} - μ - α_i - β_t)²
12021202
///
@@ -1315,7 +1315,7 @@ fn solve_joint_no_lowrank(
13151315
Some((mu, alpha, beta))
13161316
}
13171317

1318-
/// Solve joint TWFE + low-rank via alternating minimization (no tau).
1318+
/// Solve global TWFE + low-rank via alternating minimization (no tau).
13191319
///
13201320
/// Minimizes: min Σ δ_{it}(Y_{it} - μ - α_i - β_t - L_{it})² + λ_nn||L||_*
13211321
///
@@ -1422,12 +1422,12 @@ fn solve_joint_with_lowrank(
14221422
Some((mu, alpha, beta, l))
14231423
}
14241424

1425-
/// Compute LOOCV score for joint method with specific parameter combination.
1425+
/// Compute LOOCV score for global method with specific parameter combination.
14261426
///
14271427
/// Following paper's Equation 5:
14281428
/// Q(λ) = Σ_{j,s: D_js=0} [τ̂_js^loocv(λ)]²
14291429
///
1430-
/// For joint method, we exclude each control observation, fit the joint model
1430+
/// For global method, we exclude each control observation, fit the global model
14311431
/// on remaining data, and compute the pseudo-treatment effect at the excluded obs.
14321432
///
14331433
/// # Returns
@@ -1502,7 +1502,7 @@ fn loocv_score_joint(
15021502
}
15031503
}
15041504

1505-
/// Perform LOOCV grid search for joint method using parallel grid search.
1505+
/// Perform LOOCV grid search for global method using parallel grid search.
15061506
///
15071507
/// Evaluates all combinations of (lambda_time, lambda_unit, lambda_nn) in parallel
15081508
/// and returns the combination with lowest LOOCV score.
@@ -1630,7 +1630,7 @@ pub fn loocv_grid_search_global<'py>(
16301630
Ok((best_lt, best_lu, best_ln, best_score, n_valid, n_attempted, first_failed))
16311631
}
16321632

1633-
/// Compute bootstrap variance estimation for TROP joint method in parallel.
1633+
/// Compute bootstrap variance estimation for TROP global method in parallel.
16341634
///
16351635
/// Performs unit-level block bootstrap, parallelizing across bootstrap iterations.
16361636
/// Uses stratified sampling to preserve treated/control unit ratio.
@@ -1737,7 +1737,7 @@ pub fn bootstrap_trop_variance_global<'py>(
17371737
}
17381738
}
17391739

1740-
// Compute weights and fit joint model
1740+
// Compute weights and fit global model
17411741
let delta = compute_joint_weights(
17421742
&y_boot.view(),
17431743
&d_boot.view(),

tests/test_trop.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,9 +2722,11 @@ def test_zero_weights_no_division_error(self):
27222722
class TestTROPGlobalMethod:
27232723
"""Tests for TROP method='global'.
27242724
2725-
The global method estimates a single scalar treatment effect τ via
2726-
weighted least squares, as opposed to the local method which
2727-
computes per-observation effects.
2725+
The global method fits a single model on control data with global
2726+
weights, then extracts per-observation treatment effects as
2727+
residuals (τ_it = Y_it - μ - α_i - β_t - L_it). ATT is the mean
2728+
of these effects. The local method instead fits a separate model
2729+
per treated observation with observation-specific weights.
27282730
"""
27292731

27302732
def test_global_basic(self, simple_panel_data):

0 commit comments

Comments
 (0)