Skip to content

Commit

Permalink
Merge pull request #392 from bashtage/allow-1-d-exog
Browse files Browse the repository at this point in the history
ENH: Allow 1d exog
  • Loading branch information
bashtage committed May 10, 2020
2 parents 55e0d00 + 54f0f09 commit 217eb05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions arch/tests/univariate/test_mean.py
Expand Up @@ -1141,3 +1141,13 @@ def test_no_variance():
mod = arch_model(np.ones(100))
with pytest.warns(ConvergenceWarning):
mod.fit(disp=DISPLAY)


def test_1d_exog():
y = np.random.standard_normal((300))
x = np.random.standard_normal((300))
am = arch_model(y, x, mean="ARX", lags=2, vol="ARCH", q=0)
res = am.fit()
am = arch_model(y, x[:, None], mean="ARX", lags=2, vol="ARCH", q=0)
res2 = am.fit()
assert_series_equal(res.params, res2.params)
2 changes: 2 additions & 0 deletions arch/univariate/mean.py
Expand Up @@ -444,6 +444,8 @@ def _generate_lag_names(self) -> List[str]:
def _check_specification(self) -> None:
"""Checks the specification for obvious errors """
if self._x is not None:
if self._x.ndim == 1:
self._x = self._x[:, None]
if self._x.ndim != 2 or self._x.shape[0] != self._y.shape[0]:
raise ValueError(
"x must be nobs by n, where nobs is the same as "
Expand Down

0 comments on commit 217eb05

Please sign in to comment.