Esempio n. 1
0
def test_adf_autolag():
    # GH#246
    d2 = macrodata.load_pandas().data

    for k_trend, tr in enumerate(['nc', 'c', 'ct', 'ctt']):
        x = np.log(d2['realgdp'].values)
        xd = np.diff(x)

        # check exog
        adf3 = unit_root.adfuller(x, maxlag=None, autolag='aic',
                                  regression=tr, store=True, regresults=True)
        st2 = adf3[-1]

        assert len(st2.autolag_results) == 15 + 1  # +1 for lagged level
        for l, res in sorted(list(st2.autolag_results.items()))[:5]:
            lag = l - k_trend
            # assert correct design matrices in _autolag
            assert_equal(res.model.exog[-10:, k_trend], x[-11:-1])
            assert_equal(res.model.exog[-1, k_trend + 1:], xd[-lag:-1][::-1])
            # min-ic lag of dfgls in Stata is also 2, or 9 for maic
            # with notrend
            assert st2.usedlag == 2

        # same result with lag fixed at usedlag of autolag
        adf2 = unit_root.adfuller(x, maxlag=2, autolag=None, regression=tr)
        assert_almost_equal(adf3[:2], adf2[:2], decimal=12)

    tr = 'c'
    # check maxlag with autolag
    adf3 = unit_root.adfuller(x, maxlag=5, autolag='aic',
                              regression=tr, store=True, regresults=True)
    assert len(adf3[-1].autolag_results) == 5 + 1

    adf3 = unit_root.adfuller(x, maxlag=0, autolag='aic',
                              regression=tr, store=True, regresults=True)
    assert len(adf3[-1].autolag_results) == 0 + 1
Esempio n. 2
0
 def test_store_str(self):
     store = unit_root.adfuller(self.y, regression="nc",
                                autolag=None, maxlag=1,
                                store=True)[-1]
     assert store.__str__() == 'Augmented Dickey-Fuller Test Results'
Esempio n. 3
0
 def setup_class(cls):
     cls.res1 = unit_root.adfuller(cls.y, autolag=None, **cls.kwargs)