def test_fail_nonvector_input(self): with warnings.catch_warnings(record=True): unit_root.kpss(self.x) # should be fine x = np.random.rand(20, 2) with pytest.raises(ValueError): unit_root.kpss(x)
def test_pval(self): with warnings.catch_warnings(record=True): kpss_stat, pval, lags, crits = unit_root.kpss(self.x, 'c', 3) assert pval == 0.01 with warnings.catch_warnings(record=True): kpss_stat, pval, lags, crits = unit_root.kpss(self.x, 'ct', 3) assert pval == 0.01
def test_teststat(self): with warnings.catch_warnings(record=True): kpss_stat, pval, lags, crits = unit_root.kpss(self.x, 'c', 3) assert_almost_equal(kpss_stat, 5.0169, 3) with warnings.catch_warnings(record=True): kpss_stat, pval, lags, crits = unit_root.kpss(self.x, 'ct', 3) assert_almost_equal(kpss_stat, 1.1828, 3)
def test_fail_unclear_hypothesis(self): # these should be fine with warnings.catch_warnings(record=True): unit_root.kpss(self.x, 'c') unit_root.kpss(self.x, 'C') unit_root.kpss(self.x, 'ct') unit_root.kpss(self.x, 'CT') with pytest.raises(ValueError): unit_root.kpss(self.x, "unclear hypothesis")
def test_store(self): with warnings.catch_warnings(record=True): kpss_stat, pval, crit, store = unit_root.kpss(self.x, 'c', 3, True) # assert attributes, and make sure they're correct assert store.nobs == len(self.x) assert store.lags == 3
def test_lags(self): with warnings.catch_warnings(record=True): kpss_stat, pval, lags, crits = unit_root.kpss(self.x, 'c') assert_equal(lags, int(np.ceil(12. * np.power(len(self.x) / 100., 1 / 4.))))