Skip to content

PACF Fails When Matrix for Yule-Walker Equations is Singular #8363

Closed

Description

@jeffhandl

When we try to use the pacf function and the matrix for the Yule-Walker equations is singular, we get a LinAlgError and the code fails. This also leads to downstream failures. We could resolve this by instead using the psuedo-inverse function (numpy.linalg.pinv) when solving the equations here.

Here is an example of code that will currently fail with a LinAlgError.

import numpy as np 
from statsmodels.tsa.stattools import acf, kpss, pacf

pacf(np.ones(30), nlags=6)

Activity

  1. josef-pkt commented on Dec 8, 2022

    @josef-pkt
    Member

    a bit noisy if I add a warning to yule_walker

    from statsmodels.tsa.stattools import acf, kpss, pacf
    ​
    pacf(np.ones(30), nlags=6)
    ...\statsmodels\statsmodels\regression\linear_model.py:1486: ValueWarning: Matrix is singular, using pinv
      warnings.warn("Matrix is singular, using pinv", ValueWarning)
    ...\statsmodels\statsmodels\regression\linear_model.py:1486: ValueWarning: Matrix is singular, using pinv
      warnings.warn("Matrix is singular, using pinv", ValueWarning)
    ...\statsmodels\statsmodels\regression\linear_model.py:1486: ValueWarning: Matrix is singular, using pinv
      warnings.warn("Matrix is singular, using pinv", ValueWarning)
    ...\statsmodels\statsmodels\regression\linear_model.py:1486: ValueWarning: Matrix is singular, using pinv
      warnings.warn("Matrix is singular, using pinv", ValueWarning)
    ...\statsmodels\statsmodels\regression\linear_model.py:1486: ValueWarning: Matrix is singular, using pinv
      warnings.warn("Matrix is singular, using pinv", ValueWarning)
    ...\statsmodels\statsmodels\regression\linear_model.py:1486: ValueWarning: Matrix is singular, using pinv
      warnings.warn("Matrix is singular, using pinv", ValueWarning)
    array([1., 0., 0., 0., 0., 0., 0.])
    

    need to catch warning and warn only once in pacf

  2. added 2 commits that reference this issue on Dec 8, 2022
    59e7082
    ac96b47
  3. added this to the 0.14 milestone on Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions