Exemplo n.º 1
0
 def test_lags(self):
     # real GDP from macrodata data set
     with pytest.warns(InterpolationWarning):
         res = kpss(self.x, "c", nlags="auto")
     assert_equal(res[2], 9)
     # real interest rates from macrodata data set
     res = kpss(sunspots.load().data["SUNACTIVITY"], "c", nlags="auto")
     assert_equal(res[2], 7)
     # volumes from nile data set
     with pytest.warns(InterpolationWarning):
         res = kpss(nile.load().data["volume"], "c", nlags="auto")
     assert_equal(res[2], 5)
     # log-coinsurance from randhie data set
     with pytest.warns(InterpolationWarning):
         res = kpss(randhie.load().data["lncoins"], "ct", nlags="auto")
     assert_equal(res[2], 75)
     # in-vehicle time from modechoice data set
     with pytest.warns(InterpolationWarning):
         res = kpss(modechoice.load().data["invt"], "ct", nlags="auto")
     assert_equal(res[2], 18)
Exemplo n.º 2
0
 def test_lags(self):
     # real GDP from macrodata data set
     with pytest.warns(InterpolationWarning):
         res = kpss(self.x, 'c', nlags='auto')
     assert_equal(res[2], 9)
     # real interest rates from macrodata data set
     res = kpss(sunspots.load(True).data['SUNACTIVITY'], 'c', nlags='auto')
     assert_equal(res[2], 7)
     # volumes from nile data set
     with pytest.warns(InterpolationWarning):
         res = kpss(nile.load(True).data['volume'], 'c', nlags='auto')
     assert_equal(res[2], 5)
     # log-coinsurance from randhie data set
     with pytest.warns(InterpolationWarning):
         res = kpss(randhie.load(True).data['lncoins'], 'ct', nlags='auto')
     assert_equal(res[2], 75)
     # in-vehicle time from modechoice data set
     with pytest.warns(InterpolationWarning):
         res = kpss(modechoice.load(True).data['invt'], 'ct', nlags='auto')
     assert_equal(res[2], 18)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
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',
Exemplo n.º 6
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', ])

series = {