Skip to content

Commit d759898

Browse files
authored
Merge pull request #566 from bashtage/fix-std-resid-numpy
BUG: Allow NumPy arrays in univariate models
2 parents 20774dc + 2e72f2e commit d759898

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

arch/tests/univariate/test_mean.py

+12
Original file line numberDiff line numberDiff line change
@@ -1321,3 +1321,15 @@ def test_last_obs_equiv_param(first, last, mean):
13211321
assert_allclose(res1.model._backcast, res2.model._backcast, rtol=RTOL)
13221322
assert_allclose(res1.params, res2.params, rtol=RTOL)
13231323
assert_allclose(cv1[np.isfinite(cv1)], cv2[np.isfinite(cv2)], rtol=RTOL)
1324+
1325+
1326+
@pytest.mark.parametrize("use_pandas", [True, False])
1327+
def test_all_attr_numpy_pandas(use_pandas):
1328+
data = SP500
1329+
if not use_pandas:
1330+
data = np.asanyarray(data)
1331+
mod = arch_model(data, p=1, o=1, q=1)
1332+
res = mod.fit(disp="off")
1333+
for attr in dir(res):
1334+
if not attr.startswith("_"):
1335+
getattr(res, attr)

arch/univariate/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,8 @@ def std_resid(self) -> Union[Float64Array, pd.Series]:
13001300
Residuals standardized by conditional volatility
13011301
"""
13021302
std_res = self.resid / self.conditional_volatility
1303-
std_res.name = "std_resid"
1303+
if isinstance(std_res, pd.Series):
1304+
std_res.name = "std_resid"
13041305
return std_res
13051306

13061307
def plot(

doc/source/changes/5.0.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ Version 5
44

55
Since 5.1
66
=========
7-
- Fix a bug in :func:`~arch.univariate.base.ARCHModelResult.forecast` and related
7+
- Fixed a bug in in :func:`~arch.univariate.base.ARCHModelResult.std_resid` that
8+
would raise an exception when the data used to construct the model with a NumPy
9+
array (:issue:`565`).
10+
- Fixed a bug in :func:`~arch.univariate.base.ARCHModelResult.forecast` and related
811
``forecast`` methods when producing multi-step forecasts usign simulation with
912
exogenous variables (:issue:`551`).
1013

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pytest>=5
1414
pytest-xdist
1515

1616
# formatting
17-
black[jupyter]==22.1.0
17+
black[jupyter]==22.3.0
1818
isort
1919
flake8
2020

0 commit comments

Comments
 (0)