feat(conformal): one-sided alternatives + covariates in the CWZ proxy#669
Conversation
Extends the SyntheticControl conformal layer (CWZ 2021) with both
user-locked extensions:
(a) alternative={"two-sided","greater","less"} on conformal_test /
conformal_confidence_intervals / conformal_average_effect. One-sided
tests use the SIGNED average-effect statistic S(u)=T_*^{-1/2} sum u_t,
grounded in Remark 1's statistic freedom + eq 2 (the paper has NO
section 7 - the prior TODO/REGISTRY "(§7 signed-t)" wording was a
Firpo-Possebom cross-contamination, fixed here). q=1 enforced for
one-sided. CI inversion reports half-line HULLS: the infinite side
attaches because p -> 1 in the accepted direction; contiguous is
RECOMPUTED against the final reported ray (Algorithm 1 has no
monotonicity guarantee after per-candidate proxy refits); an
all-rejected scanned grid reports the infinite side + an uncertified
NaN finite endpoint as grid_limited (never a false empty set).
(b) covariates=[...] stacks pivoted-variable matching rows RAW into the
constrained-LS proxy objective per the paper's note after eq 6;
residuals/statistic stay outcome-only; exchangeability preserved.
EXOGENEITY ASSUMPTION warned on every covariate run: Z(theta0)
null-imputes only the outcome, so covariates enter as observed
(no-intervention) values - a policy-affected covariate leaks treated
post-period information into the proxy. Block-collapsed average-effect
covariates collapse with the same T*-block structure; pointwise CIs
precompute the covariate panel once and slice per (pre, t) sub-series.
DiagnosticReport's conformal block carries alternative + covariates for
all three kinds. Scope excludes (c) the AR/innovation-permutation path
(TODO row rewritten to track only that remainder).
Tests (5 local review rounds): hand-rolled signed-statistic permutation
oracle; directional rejection; half-line endpoints bracketing the
two-sided interval; missed-ray grid_limited (9-block fixture - the
single-post-slot tie structure floors p at 1/n_blocks); deterministic
non-contiguous patterns incl. rejected-toward-infinity; proxy-weight
mechanism; exogenous covariate fixture + assumption-warning assertion;
report propagation; permutation floor with covariates. All pre-existing
conformal + SC + diagnostic-report suites pass unchanged. Reference
scoping: the authors' scinference R package anchors only the base
machinery; extensions anchor to paper formulas via the oracle tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lbd6nqWmg4snvvBmegwqiw
|
Overall Assessment ✅ Looks good. No unmitigated P0/P1 findings. Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation / Tests
|
…proxy bullet Review P3: the bullet both allowed covariate rows in the objective and said outcomes-only; the invariant is that residuals/statistic are outcome-only regardless of covariate rows. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lbd6nqWmg4snvvBmegwqiw
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good. No unmitigated P0/P1 findings. Executive Summary
Methodology
Code Quality No findings. Performance No findings. The added covariate-row work is small relative to the existing per-grid proxy refits. Maintainability No findings. The new behavior is reasonably localized in Tech Debt
Security No findings. Documentation / Tests
|
Summary
alternative={"two-sided","greater","less"}) onconformal_test/conformal_confidence_intervals/conformal_average_effect. One-sided tests use the SIGNED average-effect statisticS(û)=T_*^{-1/2}·Σ û_t, grounded in CWZ Remark 1's statistic freedom + eq 2 — the paper has no §7; this PR also fixes the prior "(§7 signed-t)" citation in TODO/REGISTRY (a Firpo-Possebom cross-contamination).q=1enforced for one-sided. CI inversion reports half-line HULLS: the infinite side attaches becausep → 1in the accepted direction;contiguousis recomputed against the final reported ray (Algorithm 1 has no monotonicity guarantee after per-candidate proxy refits); an all-rejected scanned grid reports the infinite side + an uncertified NaN finite endpoint asgrid_limited, never a false empty set.covariates=[...]): pivoted-variable matching rows stack RAW into the constrained-LS objective per the paper's note after eq 6; residuals/statistic stay outcome-only; exchangeability preserved. Exogeneity assumption warned on every covariate run:Z(θ0)null-imputes only the outcome, so covariates enter as observed (no-intervention) values — a policy-affected covariate leaks treated post-period information into the proxy. Block-collapsed average-effect covariates collapse with the sameT*-block structure; pointwise CIs precompute the covariate panel once.DiagnosticReport's conformal block carriesalternative+covariatesfor all three kinds. Scope excludes (c) the AR/innovation-permutation path (TODO row rewritten to track only that remainder).Methodology references (required if estimator / math changes)
Validation
TestConformalOneSided(hand-rolled signed-statistic permutation oracle vs eq 2 on full moving-block enumeration; directional rejection; half-line endpoints; missed-ray grid_limited on a 9-block fixture; deterministic non-contiguous scripted-p patterns incl. rejected-toward-infinity; report propagation) +TestConformalCovariates(proxy-weight mechanism with outcome-only residuals; exogenous fixture + assumption-warning assertion; validation errors; one-sided×covariates composition; permutation floor). All pre-existing conformal/SC/diagnostic-report suites pass unchanged.scinferenceR package implements only the base machinery (neither extension), so the extensions anchor to the paper formulas via the oracle tests.Security / privacy
Generated with Claude Code