Пример #1
0
 def test_lags(self):
     # real GDP from macrodata data set
     with warnings.catch_warnings(record=True):
         lags = kpss(self.x, 'c', lags='auto')[2]
     assert_equal(lags, 9)
     # real interest rates from macrodata data set
     with warnings.catch_warnings(record=True):
         lags = kpss(sunspots.load().data['SUNACTIVITY'], 'c',
                     lags='auto')[2]
     assert_equal(lags, 7)
     # volumes from nile data set
     with warnings.catch_warnings(record=True):
         lags = kpss(nile.load().data['volume'], 'c', lags='auto')[2]
     assert_equal(lags, 5)
     # log-coinsurance from randhie data set
     with warnings.catch_warnings(record=True):
         lags = kpss(randhie.load().data['lncoins'], 'ct', lags='auto')[2]
     assert_equal(lags, 75)
     # in-vehicle time from modechoice data set
     with warnings.catch_warnings(record=True):
         lags = kpss(modechoice.load().data['invt'], 'ct', lags='auto')[2]
     assert_equal(lags, 18)
Пример #2
0

def test_adf_short_timeseries():
    # GH 262
    import numpy as np
    from arch.unitroot import ADF
    x = np.asarray([0., 0., 0., 0., 0., 0., 1., 1., 0., 0.])
    adf = ADF(x)
    assert_almost_equal(adf.stat, -2.236, decimal=3)
    assert adf.lags == 1


kpss_autolag_data = ((macrodata.load().data['realgdp'], 'c', 9),
                     (sunspots.load().data['SUNACTIVITY'], 'c', 7),
                     (nile.load().data['volume'], 'c', 5),
                     (randhie.load().data['lncoins'], 'ct', 75),
                     (modechoice.load().data['invt'], 'ct', 18))


@pytest.mark.filterwarnings('ignore::DeprecationWarning')
@pytest.mark.parametrize('data,trend,lags', kpss_autolag_data)
def test_kpss_data_dependent_lags(data, trend, lags):
    # real GDP from macrodata data set
    kpss = KPSS(data, trend=trend)
    assert_equal(kpss.lags, lags)


za_test_result = namedtuple('za_test_result',
                            ['stat', 'pvalue', 'lags', 'trend',
                             'max_lags', 'method', 'actual_lags', ])