Skip to content

Commit

Permalink
Merge pull request #398 from bashtage/reg-results-pp
Browse files Browse the repository at this point in the history
ENH: Add regression results to Phillips-Perron test
  • Loading branch information
bashtage committed Jun 24, 2020
2 parents 4cb68db + a3f865b commit 3499c72
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions arch/tests/unitroot/test_unitroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ def test_pp(self):
assert_almost_equal(pp.stat, -108.1552688, DECIMAL_2)
pp.summary()

def test_pp_regression(self):
pp = PhillipsPerron(self.inflation, lags=12)
reg = pp.regression
assert len(reg.params) == 2
assert "(HAC) using 12 lags" in str(reg.summary())

def test_pp_bad_type(self):
pp = PhillipsPerron(self.inflation, lags=12)
with pytest.raises(ValueError):
Expand Down
13 changes: 13 additions & 0 deletions arch/unitroot/unitroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ def __init__(
self._stat_tau = None
self._test_name = "Phillips-Perron Test"
self._lags = lags
self._regression = None

def _check_specification(self) -> None:
trend_order = len(self._trend) if self._trend not in ("n", "nc") else 0
Expand Down Expand Up @@ -1126,6 +1127,7 @@ def _compute_statistic(self) -> None:
rhs = add_trend(rhs, trend)

resols = OLS(lhs, rhs).fit()
self._regression = OLS(lhs, rhs).fit(cov_type="HAC", cov_kwds={"maxlags": lags})
k = rhs.shape[1]
n, u = resols.nobs, resols.resid
if u.shape[0] < lags:
Expand Down Expand Up @@ -1189,6 +1191,17 @@ def test_type(self, value: str) -> None:
self._reset()
self._test_type = value

@property
def regression(self) -> RegressionResults:
"""
Returns OLS regression results for the specification used in the test
The results returned use a Newey-West covariance matrix with the same
number of lags as are used in the test statistic.
"""
self._compute_if_needed()
return self._regression


class KPSS(UnitRootTest, metaclass=AbstractDocStringInheritor):
"""
Expand Down

0 comments on commit 3499c72

Please sign in to comment.