Skip to content

Commit

Permalink
Merge 4616a6b into aaf2f27
Browse files Browse the repository at this point in the history
  • Loading branch information
bashtage committed Jul 31, 2018
2 parents aaf2f27 + 4616a6b commit a8740f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions arch/tests/univariate/test_volatility.py
Expand Up @@ -603,6 +603,7 @@ def test_warnings(self):
garch = GARCH()
parameters = np.array([0.1, 0.2, 0.8, 4.0])
studt = StudentsT()
warnings.simplefilter('always', UserWarning)
with warnings.catch_warnings(record=True) as w:
garch.simulate(parameters, 1000, studt.simulate([4.0]))
assert_equal(len(w), 1)
Expand Down
11 changes: 10 additions & 1 deletion arch/unitroot/unitroot.py
Expand Up @@ -7,6 +7,7 @@
array, inf, abs, log, sort, polyval, empty, argwhere, arange, squeeze)
from numpy.linalg import pinv
from scipy.stats import norm
from pandas import DataFrame

from statsmodels.regression.linear_model import OLS
from statsmodels.tsa.tsatools import lagmat
Expand Down Expand Up @@ -167,6 +168,12 @@ def _df_select_lags(y, trend, max_lags, method):
return ic_best, best_lag


def _add_column_names(rhs, lags):
"""Return a DataFrame with named columns"""
lag_names = ['Diff.L{0}'.format(i) for i in range(1, lags + 1)]
return DataFrame(rhs, columns=['Level.L1'] + lag_names)


def _estimate_df_regression(y, trend, lags):
"""Helper function that estimates the core (A)DF regression
Expand Down Expand Up @@ -195,9 +202,10 @@ def _estimate_df_regression(y, trend, lags):
nobs = rhs.shape[0]
lhs = rhs[:, 0].copy() # lag-0 values are lhs, Is copy() necessary?
rhs[:, 0] = y[-nobs - 1:-1] # replace lag 0 with level of y
rhs = _add_column_names(rhs, lags)

if trend != 'nc':
rhs = add_trend(rhs[:, :lags + 1], trend)
rhs = add_trend(rhs.iloc[:, :lags + 1], trend)

return OLS(lhs, rhs).fit()

Expand Down Expand Up @@ -807,6 +815,7 @@ def _compute_statistic(self):
lags = self._lags

rhs = y[:-1, None]
rhs = _add_column_names(rhs, 0)
lhs = y[1:, None]
if trend != 'nc':
rhs = add_trend(rhs, trend)
Expand Down

0 comments on commit a8740f7

Please sign in to comment.