Skip to content

Commit

Permalink
Catching another arch model exception
Browse files Browse the repository at this point in the history
  • Loading branch information
FelSiq committed Mar 24, 2021
1 parent 2b6f1cb commit f59793a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tspymfe/stat_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np
import arch.unitroot
import arch.utility.exceptions
import statsmodels.stats.stattools
import statsmodels.stats.diagnostic

Expand All @@ -16,14 +17,16 @@ def _extract_arch_module_pval(arch_result: t.Any) -> float:
try:
return arch_result.pvalue

except (IndexError, AssertionError):
except (
IndexError,
AssertionError,
arch.utility.exceptions.InfeasibleTestException,
):
# Note: catching a weird exceptions from arch module.
return np.nan

@classmethod
def ft_test_dw(
cls, ts_residuals: np.ndarray, normalize: bool = True
) -> float:
def ft_test_dw(cls, ts_residuals: np.ndarray, normalize: bool = True) -> float:
"""Durbin-Watson test statistic value.
This tests tries to detect autocorrelation of lag 1 in the given
Expand Down Expand Up @@ -212,9 +215,7 @@ def ft_test_adf(
of the American Statistical Association, 74:366a, 427-431,
DOI: 10.1080/01621459.1979.10482531
"""
stat, pvalue = statsmodels.tsa.stattools.adfuller(
ts, maxlag=max_nlags
)[:2]
stat, pvalue = statsmodels.tsa.stattools.adfuller(ts, maxlag=max_nlags)[:2]

if return_pval:
return pvalue
Expand Down

0 comments on commit f59793a

Please sign in to comment.