Repository navigation
Fix/727 wilson factorization (lag-0 vs frequency-0) (#727) - #735
Open
emanueldellipaoli01-a11y wants to merge 3 commits into
Open
emanueldellipaoli01-a11y wants to merge 3 commits into
emanueldellipaoli01-a11y wants to merge 3 commits into
Conversation
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.
Fixes #727
The Wilson factorization was incorrectly using the zero-frequency value instead of the lag-zero coefficient. The initial factor is now computed as the upper Cholesky factor of the lag-zero covariance, and both the returned covariance and transfer function are computed from the lag-zero factor.
The causal-part (bracket) operator now retains the upper triangle of the lag-zero coefficient, with a half-weighted diagonal. The Nyquist lag is handled separately for even-length transforms, and the lower triangle is no longer zeroed at frequency zero.
In
pairwise_spectral_granger, the spectral density is now multiplied by the sampling frequency before factorization, ensuring that the innovation covariance is correctly scaled whenfs != 1. The previously unusedterm_critargument is also passed to the factorization, and the convergence check is now relative to the factor scale.Added regression tests covering the bracket operator, the upper Cholesky convention, recovery of a known VAR factor, invariance to signal amplitude, and correct covariance scaling when
fs != 1. The release notes have also been updated.In
test_pairwise_spectral_granger_against_r_grangers, the maximum deviation from the R reference for the second component drops from 0.034 to 0.010, while the mean deviation decreases from 0.017 to 0.0014. For the first component, the maximum deviation increases slightly from 0.0828 to 0.0852, so the corresponding tolerance has been raised from 0.085 to 0.09.The factorization also converges in 6 iterations instead of 37 on this dataset.