2015-04-06 68 views
1

如果我不希望我所有的觀察結果都用R計算ADF測試,我該如何計算ADF? 我的時間系列包含3000個觀察值。現在我想計算200次第一次觀察的ADF測試。我嘗試以下:ur.df(x, lags=5, selectlags="AIC", type="drift", subset=1:200)從包urcalibrary(urca),但我得到以下錯誤消息:使用R工作室的子集

Error in summary(ur.df(Vstoxx, lags = 5, selectlags = "AIC", type = "drift", : 
    Fehler bei der Auswertung des Argumentes 'object' bei der Methodenauswahl 
for function 'summary': Error in ur.df(Vstoxx, lags = 5, selectlags = "AIC", type = "drift", subset = 1:200) : 
    unused argument (subset = 1:200) 

其中德國部分轉化爲:在該方法中選擇參數「對象」的評價過程中的錯誤。 這裏是一個小數據樣本:

x 
1 14.4700 
2 14.5100 
3 14.4200 
4 13.8000 
5 13.5700 
6 12.9200 
7 13.6800 
8 14.0500 
9 13.6400 
10 13.5700 
11 13.2000 
12 13.1700 
13 13.6300 
14 14.1700 
15 13.9600 
16 14.1100 
17 13.6300 
18 13.3200 
19 12.4600 
20 12.8100 
21 12.7200 
22 12.3600 
23 12.2500 
24 12.3800 
25 11.6000 
26 11.9900 
27 11.9200 
28 12.1900 
29 12.0400 
30 11.9900 
31 12.5200 
32 12.3500 
33 13.6600 
34 13.5700 
35 13.0100 
36 13.2400 
37 13.4900 
38 13.9900 
39 13.1900 
40 12.2100 
41 12.8900 
42 12.3500 
43 12.8600 
44 12.5700 
45 11.9300 
46 11.7200 
47 12.0000 
48 12.5300 
49 13.4700 
50 12.9600 
51 13.3500 
52 12.4900 
53 14.5700 

非常感謝

+0

請問您是否包含喲你的'庫'/'需要'語句?另外,提供數據集樣本更有可能得到答案......使用「dput」或「head」。謝謝。 –

+0

感謝您的輸入。我編輯了我的原始文章並添加了一個小數據樣本。 –

回答

0

不是添加subset=參數,你可以簡單地使用索引,以子集x(見下面的示例所示)

x <- c(14.4700, 14.5100, 14.4200, 13.8000, 13.5700, 12.9200, 13.6800, 
     14.0500, 13.6400, 13.5700, 13.2000, 13.1700, 13.6300, 14.1700, 13.9600, 
     14.1100, 13.6300, 13.3200, 12.4600, 12.8100, 12.7200, 12.3600, 12.2500, 12.3800, 
     11.6000, 11.9900, 11.9200, 12.1900, 12.0400, 11.9900, 12.5200, 12.3500, 13.6600, 
     13.5700, 13.0100, 13.2400, 13.4900, 13.9900, 13.1900, 12.2100, 12.8900, 12.3500, 
     12.8600, 12.5700, 11.9300, 11.7200, 12.0000, 12.5300, 13.4700, 12.9600, 13.3500, 
     12.4900, 14.5700) 

library(urca) 

# We'll use only the 50 first elements in x 
ur.df(x[1:50], lags=5, selectlags="AIC", type="drift") 

輸出:

############################################################### 
# Augmented Dickey-Fuller Test Unit Root/Cointegration Test # 
############################################################### 

The value of the test statistic is: -2.1741 2.3635 
+0

非常感謝,那正是我一直在尋找的! –

+0

好吧,不客氣! :) –

+0

儘管OP的x的印刷方式,它看起來像一個數據框,這個例子是一個向量,所以'x [1:50]'當x是一個數據框時會給出很多不同的結果 – rawr