Skip to content

Commit 98029d1

Browse files
igerberclaude
andcommitted
Fix circular import risk, add missing README params for PR #165 round 3
Duplicate _SPARSE_DENSE_THRESHOLD in two_stage_bootstrap.py to eliminate cross-import from two_stage.py. Add bootstrap_weights param to README ImputationDiD/TwoStageDiD constructors and n_bootstrap minimum note to TROP. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3b2e40d commit 98029d1

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,7 @@ TROP(
19831983
max_iter=100, # Max iterations for factor estimation
19841984
tol=1e-6, # Convergence tolerance
19851985
alpha=0.05, # Significance level for CIs
1986-
n_bootstrap=200, # Bootstrap replications
1986+
n_bootstrap=200, # Bootstrap replications (minimum 2; TROP requires bootstrap for SEs)
19871987
seed=None # Random seed
19881988
)
19891989
```
@@ -2103,6 +2103,7 @@ ImputationDiD(
21032103
alpha=0.05, # Significance level for CIs
21042104
cluster=None, # Column for cluster-robust SEs
21052105
n_bootstrap=0, # Bootstrap iterations (0 = analytical)
2106+
bootstrap_weights='rademacher', # 'rademacher', 'mammen', or 'webb'
21062107
seed=None, # Random seed
21072108
rank_deficient_action='warn', # 'warn', 'error', or 'silent'
21082109
horizon_max=None, # Max event-study horizon
@@ -2157,6 +2158,7 @@ TwoStageDiD(
21572158
alpha=0.05, # Significance level for CIs
21582159
cluster=None, # Column for cluster-robust SEs (defaults to unit)
21592160
n_bootstrap=0, # Bootstrap iterations (0 = analytical GMM SEs)
2161+
bootstrap_weights='rademacher', # 'rademacher', 'mammen', or 'webb'
21602162
seed=None, # Random seed
21612163
rank_deficient_action='warn', # 'warn', 'error', or 'silent'
21622164
horizon_max=None, # Max event-study horizon

diff_diff/two_stage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
# Maximum number of elements before falling back to per-column sparse aggregation.
3333
# 10M float64 elements ≈ 80 MB peak allocation. Above this, per-column .getcol()
34-
# trades throughput for bounded memory.
34+
# trades throughput for bounded memory. Keep in sync with two_stage_bootstrap.py.
3535
_SPARSE_DENSE_THRESHOLD = 10_000_000
3636

3737
from diff_diff.linalg import solve_ols

diff_diff/two_stage_bootstrap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
from diff_diff.linalg import solve_ols
1717
from diff_diff.staggered_bootstrap import _generate_bootstrap_weights_batch
18-
from diff_diff.two_stage import _SPARSE_DENSE_THRESHOLD
18+
# Maximum number of elements before falling back to per-column sparse aggregation.
19+
# Keep in sync with two_stage.py.
20+
_SPARSE_DENSE_THRESHOLD = 10_000_000
1921
from diff_diff.two_stage_results import TwoStageBootstrapResults
2022

2123
__all__ = [

0 commit comments

Comments
 (0)