コード例 #1
0
def adf_test(timeseries, trend):
    from arch.unitroot import ADF
    adf = ADF(timeseries)
    adf.trend = str(trend)
    reg_res = adf.regression
    #print('ADF statistic: {0:0.4f}'.format(adf.stat))
    #print('ADF p-value: {0:0.4f}'.format(adf.pvalue))
    #print(reg_res.summary().as_text())
    return (adf.stat, adf.pvalue)
コード例 #2
0
 def test_no_change_lags_trend(self):
     adf = ADF(self.inflation)
     lags = adf.lags
     with pytest.warns(FutureWarning, match="Mutating unit root"):
         adf.lags = lags
     trend = adf.trend
     with pytest.warns(FutureWarning, match="Mutating unit root"):
         adf.trend = trend
     ml = adf.max_lags
     with pytest.warns(FutureWarning, match="Mutating unit root"):
         adf.max_lags = ml
コード例 #3
0
ファイル: test_unitroot.py プロジェクト: VolosSoftware/arch
 def test_adf_auto_t_stat(self):
     adf = ADF(self.inflation, method='t-stat')
     assert_equal(adf.lags, 10)
     old_stat = adf.stat
     adf.lags += 1
     assert adf.stat != old_stat
     old_stat = adf.stat
     assert_equal(adf.y, self.inflation)
     adf.trend = 'ctt'
     assert adf.stat != old_stat
     assert adf.trend == 'ctt'
     assert len(adf.valid_trends) == len(('nc', 'c', 'ct', 'ctt'))
     for d in adf.valid_trends:
         assert d in ('nc', 'c', 'ct', 'ctt')
     assert adf.null_hypothesis == 'The process contains a unit root.'
     assert adf.alternative_hypothesis == 'The process is weakly stationary.'
コード例 #4
0
 def test_adf_auto_t_stat(self):
     adf = ADF(self.inflation, method='t-stat')
     assert_equal(adf.lags, 10)
     old_stat = adf.stat
     adf.lags += 1
     assert adf.stat != old_stat
     old_stat = adf.stat
     assert_equal(adf.y, self.inflation)
     adf.trend = 'ctt'
     assert adf.stat != old_stat
     assert adf.trend == 'ctt'
     assert len(adf.valid_trends) == len(('nc', 'c', 'ct', 'ctt'))
     for d in adf.valid_trends:
         assert d in ('nc', 'c', 'ct', 'ctt')
     assert adf.null_hypothesis == 'The process contains a unit root.'
     assert adf.alternative_hypothesis == 'The process is weakly stationary.'
コード例 #5
0
ファイル: test_unitroot.py プロジェクト: yangyutu/arch
 def test_adf_auto_t_stat(self):
     adf = ADF(self.inflation, method="t-stat")
     assert_equal(adf.lags, 11)
     adf2 = ADF(self.inflation, method="t-stat", low_memory=True)
     assert_equal(adf2.lags, 11)
     old_stat = adf.stat
     adf.lags += 1
     assert adf.stat != old_stat
     old_stat = adf.stat
     assert_equal(adf.y, self.inflation)
     adf.trend = "ctt"
     assert adf.stat != old_stat
     assert adf.trend == "ctt"
     assert len(adf.valid_trends) == len(("nc", "c", "ct", "ctt"))
     for d in adf.valid_trends:
         assert d in ("nc", "c", "ct", "ctt")
     assert adf.null_hypothesis == "The process contains a unit root."
     assert adf.alternative_hypothesis == "The process is weakly " "stationary."
コード例 #6
0
ファイル: test_unitroot.py プロジェクト: chengshaozhe/arch
 def test_invalid_determinstic(self):
     adf = ADF(self.inflation)
     with pytest.raises(ValueError):
         adf.trend = 'bad-value'
コード例 #7
0
ファイル: test_unitroot.py プロジェクト: esvhd/arch
 def test_invalid_determinstic(self):
     adf = ADF(self.inflation)
     with pytest.raises(ValueError):
         adf.trend = 'bad-value'
コード例 #8
0
table1[t1_cols[0]] = np.mean(JC3).tolist()
table1[t1_cols[1]] = np.std(JC3).tolist()
table1[t1_cols[2]] = np.percentile(JC3, 25, axis=0).tolist()
table1[t1_cols[3]] = np.percentile(JC3, 50, axis=0).tolist()
table1[t1_cols[4]] = np.percentile(JC3, 75, axis=0).tolist()
table1.iloc[1, :] = table1.iloc[1, :] * 1000
table1.iloc[6, :] = table1.iloc[6, :] / 10000

### Table 2
JC1 = pd.read_csv('JC1.csv', header=0)
JC1 = JC1[['ore_price', 'growth', 'VIX', 'BDI']]
JC1_cols = JC1.columns.tolist()

adf_iron = ADF(JC1[JC1_cols[0]])
adf_iron.trend = 'c'

adf_growth = ADF(JC1[JC1_cols[1]])
adf_growth.trend = 'c'

adf_vix = ADF(JC1[JC1_cols[2]])
adf_vix.trend = 'c'

adf_BDI = ADF(JC1[JC1_cols[3]])
adf_BDI.trend = 'c'

adf_stat = [adf_iron.stat, adf_growth.stat, adf_vix.stat, adf_BDI.stat]
adf_p = [adf_iron.pvalue, adf_growth.pvalue, adf_vix.pvalue, adf_BDI.pvalue]

table2 = pd.DataFrame(
    index=['ADF-Statistics', 'p-Value', '1%', '5%', '10%'],