Skip to content

Fix Yule Walker to handle singular matrices - #8364

Closed
jeffhandl wants to merge 2 commits into
statsmodels:mainfrom
jeffhandl:patch-1
Closed

jeffhandl wants to merge 2 commits into
statsmodels:mainfrom
jeffhandl:patch-1

Conversation

@jeffhandl

Copy link
Copy Markdown

Written to respond to this issue: #8363

  • closes #xxxx
  • tests added / passed.
  • code/documentation is well formatted.
  • properly formatted commit message. See
    NumPy's guide.
Details

Notes:

  • It is essential that you add a test when making code changes. Tests are not
    needed for doc changes.
  • When adding a new function, test values should usually be verified in another package (e.g., R/SAS/Stata).
  • When fixing a bug, you must add a test that would produce the bug in main and
    then show that it is fixed with the new code.
  • New code additions must be well formatted. Changes should pass flake8. If on Linux or OSX, you can
    verify you changes are well formatted by running
    git diff upstream/main -u -- "*.py" | flake8 --diff --isolated
    
    assuming flake8 is installed. This command is also available on Windows
    using the Windows System for Linux once flake8 is installed in the
    local Linux environment. While passing this test is not required, it is good practice and it help
    improve code quality in statsmodels.
  • Docstring additions must render correctly, including escapes and LaTeX.

@bashtage

Copy link
Copy Markdown
Member

Should probably be @ not *. Overall, I'm not sure about this in general since YW isn't identified when the matrix is singular. Might be better to raise an explicit exception. Do you think the solution given by pinv is useful when singular?

@michaelbrundage

Copy link
Copy Markdown

There are extensions of YW to the singular case, for example https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1907039
An alternate implementation would be to wrap the original solve() line with a try/except, log a warning when the except branch is taken and fall back on pinv() in that case.

@josef-pkt

Copy link
Copy Markdown
Member

This might be an uncommon enough case that we should warn users.

e.g. try except with solve
if singular, then warnings.warn with message like "matrix is singular, using pinv", and then use pinv

This should make it into 0.14 in the next few days.

@josef-pkt josef-pkt added this to the 0.14 milestone Dec 6, 2022
@josef-pkt josef-pkt mentioned this pull request Dec 6, 2022
16 of 20 tasks
@josef-pkt

Copy link
Copy Markdown
Member

rewritten and merged in #8567

@jeffhandl @michaelbrundage Thanks for PR and comments

@josef-pkt josef-pkt closed this Dec 9, 2022
@josef-pkt josef-pkt added superseded Used for PRs with content that is superseded by a newer PR and removed prio-elev labels Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-tsa superseded Used for PRs with content that is superseded by a newer PR type-enh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants