Skip to content

Commit

Permalink
Merge pull request #708 from bashtage/fix-pip-pre
Browse files Browse the repository at this point in the history
MAINT: Make case less extreme
  • Loading branch information
bashtage committed Jan 5, 2024
2 parents ffe8292 + d2e8cb1 commit 256887c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions arch/tests/univariate/test_volatility.py
Original file line number Diff line number Diff line change
Expand Up @@ -1431,9 +1431,9 @@ def test_figarch(setup, initial_value):
assert_equal(figarch.num_params, 4)
assert_equal(figarch.truncation, trunc_lag)

params = np.array([0.1, 0.2, 0.4, 1.1])
params = np.array([0.1, 1.01, 0.4, 1.005])
with pytest.warns(InitialValueWarning):
figarch.simulate(params, 1000, rng.simulate([]))
figarch.simulate(params, 20, rng.simulate([]))


def test_figarch_no_phi(setup):
Expand Down
16 changes: 14 additions & 2 deletions arch/univariate/volatility.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
)
from arch.univariate.distribution import Normal
from arch.utility.array import AbstractDocStringInheritor, ensure1d
from arch.utility.exceptions import InitialValueWarning, initial_value_warning
from arch.utility.exceptions import (
InitialValueWarning,
ValueWarning,
initial_value_warning,
)

if TYPE_CHECKING:
from arch.univariate import recursions_python as rec
Expand Down Expand Up @@ -3143,7 +3147,15 @@ def simulate(
fdata[:truncation] = abs(data[:truncation]) ** power
omega = parameters[0]
beta = parameters[-1] if q else 0
omega_tilde = omega / (1 - beta)
if beta < 1:
omega_tilde = omega / (1 - beta)
else:
warn(
"beta >= 1.0, using omega as intercept since long-run variance "
"is ill-defined.",
ValueWarning,
)
omega_tilde = omega
for t in range(truncation, truncation + nobs + burn):
fsigma[t] = omega_tilde + lam_rev.dot(fdata[t - truncation : t])
sigma2[t] = fsigma[t] ** (2.0 / power)
Expand Down
4 changes: 4 additions & 0 deletions arch/utility/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@ class InfeasibleTestException(RuntimeError):

class PerformanceWarning(UserWarning):
"""Warning issued if recursions are run in CPython"""


class ValueWarning(UserWarning):
"""Warning issued if value is problematic but no fatal."""

0 comments on commit 256887c

Please sign in to comment.