feat(identification): combined zero-and-sign restrictions (ARW construction) - #218
Merged
Conversation
thomaspinder
force-pushed
the
feat/144-zero-sign-restrictions
branch
from
July 29, 2026 13:56
fbe444e to
5ca07cc
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #218 +/- ##
======================================
Coverage 95.0% 95.1%
======================================
Files 45 45
Lines 3099 3279 +180
Branches 380 417 +37
======================================
+ Hits 2945 3119 +174
- Misses 111 114 +3
- Partials 43 46 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…strictions (#144) Implements the recursive orthogonalisation of Arias, Rubio-Ramirez & Waggoner (2018). Writing P = L Q, an impact zero restriction "variable i does not respond to shock j" is the linear condition e_i' L q_j = 0 on the j-th column of Q. Columns are built one at a time, each drawn uniformly from the unit sphere of the null space of R_k = [ Z_k L ; q_1' ; ... ; q_{k-1}' ] (m = z_k + (k-1) rows) so the zeros hold exactly (to SVD precision) and orthogonality to the earlier columns holds by construction. Only the sign restrictions need accept/reject. Details worth flagging for review: - Shocks are ordered internally by zero count descending (stable, so ties keep user order and the unidentified_* padding stays last); columns are permuted back to shock_names order before returning, and rows are never permuted. The Rubio-Ramirez, Waggoner & Zha (2010) rank condition z_j <= n - j is checked on that sorted padded sequence at identify() entry, before any sampling. - On an early impact-sign failure the WHOLE candidate is abandoned and the recursion restarts from column 1. Redrawing only the offending column would be a distribution bug — q_k's law is conditional on q_1..q_{k-1}. Documented in a code comment at the failure site. - Failed draws become NaN with one summary warning; there is no fallback to L, which would silently violate the zero guarantee. on_failure="raise" is opt-in. This diverges from SignRestriction deliberately. - Diagnostics land on _last_diagnostics under a zero_sign_ prefix, not on _last_acceptance_rate, which the pipeline surfaces under the misleading name sign_restriction_acceptance_rate. - Candidates are unweighted: no volume-element correction for the ARW uniform-conditional prior. Called out in the class docstring; the two test-anchored regimes (no zeros -> Haar; exact identification -> point up to signs) are weight-free. Anchor test: with full triangular zeros every null space is one-dimensional, so P must be lower triangular with P P' = Sigma, i.e. the Cholesky factor up to column signs. Acceptance is 1.0 and |P| reproduces |cholesky(Sigma)| to 0.0 (bit-exact — the SVD returns the canonical basis vectors for that structure). Adding "+" diagonal signs pins P == cholesky(Sigma) exactly. SignRestriction is untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Egjd7ToFeb9TQqFnfRQZxV
…tion, how-to (#144) - reference/identification.md: ZeroSignRestriction in the autosummary. - explanation/identification.md: new section covering the ARW recursive construction (labelled equations for the zero condition, the recursion, and the rank condition), the exact-vs-set spectrum with Cholesky at one end and pure sign restrictions at the other, and a warning admonition stating the three distributional caveats honestly: draws are unweighted (no volume-element correction for the ARW uniform-conditional prior), retries are per-theta rather than joint, and sampling is over O(n) rather than SO(n). - how-to/zero-sign-restrictions.md: climate worked example — an activity shock has zero contemporaneous impact on the temperature anomaly, which is a physical-lag exclusion rather than a sign — plus the admissible-zero counting rule, the diagnostics attrs, and a warning admonition spelling out that failed draws are NaN and never fall back to Cholesky. - references.bib: ariasRubioRamirezWaggoner2018, rubioRamirezWaggonerZha2010. - CONTEXT.md: "Zero-and-sign restrictions (ARW construction)" entry, with "penalty-function zeros" listed under _Avoid_ (that is a different, approximate construction); IdentificationScheme adapter list refreshed. Sphinx build with warnings-as-errors reports no warnings from any of these pages; equations, citations, and both new pages render. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Egjd7ToFeb9TQqFnfRQZxV
…coefficients (#144) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Egjd7ToFeb9TQqFnfRQZxV
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Egjd7ToFeb9TQqFnfRQZxV
thomaspinder
force-pushed
the
feat/144-zero-sign-restrictions
branch
from
July 29, 2026 21:07
5ca07cc to
b6dbcab
Compare
…base conflict The rebase conflict resolution merged the new bibliography entry into the blanchardQuah1989 entry, dropping its closing brace. sphinxcontrib-bibtex then failed to parse references.bib, breaking build-docs and docs-linkcheck.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New
ZeroSignRestrictionidentification scheme: named impact-zero constraints and horizon-specific sign constraints in one scheme, via the Arias-Rubio-Ramírez-Waggoner recursive null-space construction — not a penalty approximation.z_j ≤ n − jon the sorted padded sequence) is checked deterministically atidentify()entry — impossible specifications fail with a named error before any sampling, distinct from low-acceptance runs, which warn with counts and diagnostics (zero_sign_acceptance_rate, failed fractions, mean attempts, max zero violation).SignRestriction), withon_failure="raise"opt-in.|chol(Σ)|bit-exactly (acceptance 1.0), and with positive-diagonal signs,chol(Σ)itself; an n=2 single-zero case matches the closed-form column analytically; signs-only mode is distributionally equivalent toSignRestriction(acceptance diff 0.0000).SignRestrictionis byte-untouched; the class is appended at end-of-file to stay out of the #183/#200/#208 conflict zones.Closes #144
Review
Planned by a Fable-tier planning agent; independently reviewed (verdict: approve, nothing blocking) — the reviewer re-derived the recursion, re-implemented it from scratch with scipy's null_space and reproduced all inspected cell distributions within MC error, verified the early-abandon path has exactly one failure exit, and confirmed the bit-exactness argument for the Cholesky anchor.
Tests
35 tests: the degenerate-Cholesky anchor, the n=2 closed form, generic zero/Σ/sign satisfaction to machine precision, permuted-ordering invisibility, RWZ rejection, the failure policy three ways, diagnostics contract, and the SignRestriction equivalence. Fast suite: 562 passed, 29 deselected; ruff/ty clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Egjd7ToFeb9TQqFnfRQZxV