Skip to content

Conversation

@igerber
Copy link
Owner

@igerber igerber commented Jan 15, 2026

Vectorize the weight influence function (WIF) computation in _compute_aggregated_se_with_wif() to achieve 4-10x speedup over R at all dataset scales while maintaining exact SE accuracy (0.0% difference).

Changes:

  • Replace O(n_units × n_keepers) nested loops with NumPy broadcasting
  • Use precomputed unit-group mapping instead of O(n) DataFrame lookups
  • Vectorize influence function aggregation with np.add.at()
  • Add indicator_matrix, if1/if2 matrix operations, and matrix multiply for wif_contrib = wif_matrix @ effects

Performance improvements (vs R's did package):

  • small: 2.7x → 10.5x faster
  • 1k: 1.0x → 8.8x faster
  • 5k: 0.5x → 6.8x faster
  • 10k: 0.4x → 5.3x faster
  • 20k: 0.3x → 4.2x faster

SE accuracy remains at 0.0% difference from R at all scales.

…tions

Vectorize the weight influence function (WIF) computation in
_compute_aggregated_se_with_wif() to achieve 4-10x speedup over R at all
dataset scales while maintaining exact SE accuracy (0.0% difference).

Changes:
- Replace O(n_units × n_keepers) nested loops with NumPy broadcasting
- Use precomputed unit-group mapping instead of O(n) DataFrame lookups
- Vectorize influence function aggregation with np.add.at()
- Add indicator_matrix, if1/if2 matrix operations, and matrix multiply
  for wif_contrib = wif_matrix @ effects

Performance improvements (vs R's did package):
- small: 2.7x → 10.5x faster
- 1k: 1.0x → 8.8x faster
- 5k: 0.5x → 6.8x faster
- 10k: 0.4x → 5.3x faster
- 20k: 0.3x → 4.2x faster

SE accuracy remains at 0.0% difference from R at all scales.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
igerber pushed a commit that referenced this pull request Jan 15, 2026
Reviews the vectorized WIF computation changes:
- Methodology correctness: PASS (mathematical equivalence verified)
- Code quality: PASS (clean vectorization, proper edge handling)
- Performance: PASS (4-10x faster than R, 0.0% SE difference)
- Tech debt: MINIMAL (clean extension of existing patterns)

Final verdict: APPROVE
@igerber igerber merged commit 01d2306 into main Jan 15, 2026
4 checks passed
@igerber igerber deleted the optimize-callaway-wif-performance branch January 15, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants