Thử xem đồ thị Correlogram của chuỗi sai phân bậc 1: Included observations: 65 Autocorrelation Partial Correlation AC PAC Q-Stat Prob... Error t-Statistic Prob.. vì nằm trong giới hạn...
Trang 1SỬ DỤNG MÔ HÌNH ARIMA ĐỂ DỰ BÁO CHUỖI DỮ LIỆU THỜI GIAN
SỐ LIỆU DÙNG: Chỉ số VNIndex
1/14/2010 536.8800
1/15/2010 540.9500
1/18/2010 522.7800
1/19/2010 511.2400
1/20/2010 495.7200
1/21/2010 516.4400
1/22/2010 509.1900
1/25/2010 499.0800
1/26/2010 489.8400
1/27/2010 498.7300
1/28/2010 481.9700
1/29/2010 474.1000
2/01/2010 476.7500
2/02/2010 490.1200
2/03/2010 496.8600
2/04/2010 484.6700
2/05/2010 481.4900
2/08/2010 482.9300
2/09/2010 489.6200
2/10/2010 490.3200
2/11/2010 496.2500
2/12/2010 495.6700
2/15/2010 488.8600
2/16/2010 486.9700
2/17/2010 486.8600
2/18/2010 492.9900
2/19/2010 505.3400
2/22/2010 513.1900
2/23/2010 504.5200
2/24/2010 492.8900
2/25/2010 497.5000
2/26/2010 494.3100
3/01/2010 502.5700
3/02/2010 505.0400
3/03/2010 510.9300
3/04/2010 512.7200
3/05/2010 517.0000
3/08/2010 520.7500
3/09/2010 526.2800
3/10/2010 526.2800
3/11/2010 528.9000
3/12/2010 528.0100
3/15/2010 538.0100
3/16/2010 526.0600
3/17/2010 519.9000
3/18/2010 515.2400
3/19/2010 520.1400
3/22/2010 515.7100
3/23/2010 512.2100
3/24/2010 511.0500
3/25/2010 507.8500
Trang 23/26/2010 505.5100
3/29/2010 506.7000
3/30/2010 504.7100
3/31/2010 501.8500
4/01/2010 500.3100
4/02/2010 510.3800
4/05/2010 514.1700
4/06/2010 517.4800
4/07/2010 516.2100
4/08/2010 515.7200
4/09/2010 517.0600
4/12/2010 522.1200
4/13/2010 521.0400
4/14/2010 518.5700
4/15/2010 521.4900
* KIỂM ĐỊNH TÍNH DỪNG CỦA CHUỖI DỮ LIỆU THỜI GIAN:
BẰNG KIỂM ĐỊNH UNNIT ROOT TESTS
CHỌN: LEVEL
Null Hypothesis: VNINDEX has a unit root
Exogenous: Constant
Lag Length: 1 (Automatic based on SIC, MAXLAG=10)
t-Statistic Prob.*
Augmented Dickey-Fuller test statistic -2.763419 0.0693
Test critical values: 1% level -3.536587
*MacKinnon (1996) one-sided p-values
Augmented Dickey-Fuller Test Equation
Dependent Variable: D(VNINDEX)
Method: Least Squares
Date: 04/16/10 Time: 12:04
Sample (adjusted): 1/18/2010 4/15/2010
VÌ Prob* =0.0693>0.05 => chưa dừng
CHỌN SAI PHÂN BẬC 1
Null Hypothesis: D(VNINDEX) has a unit root
Exogenous: Constant
Trang 3Lag Length: 2 (Automatic based on SIC, MAXLAG=10)
t-Statistic Prob.*
Augmented Dickey-Fuller test statistic -6.628763 0.0000
Test critical values: 1% level -3.540198
*MacKinnon (1996) one-sided p-values
Augmented Dickey-Fuller Test Equation
Dependent Variable: D(VNINDEX,2)
Method: Least Squares
Date: 04/16/10 Time: 12:02
Sample (adjusted): 1/20/2010 4/15/2010
Vì prob*=0.000<0.05 => sai phân bậc 1 của chuỗi dừng.
Ta có sơ đồ Line- sympol:
470
480
490
500
510
520
530
540
550
VNINDEX
QUY TRÌNH CHỌN LỰA MÔ HÌNH ARIMA
Vào correlogram, chọn Level:
Date: 04/16/10 Time: 12:10
Trang 4Sample: 1/14/2010 4/30/2010
Included observations: 66
Autocorrelation Partial Correlation AC PAC Q-Stat Prob
|******| |******| 1 0.849 0.849 49.804 0.000
|***** | .*| | 2 0.681 -0.144 82.351 0.000
|**** | |* | 3 0.572 0.120 105.69 0.000
|**** | |* | 4 0.547 0.211 127.35 0.000
|**** | .*| | 5 0.493 -0.137 145.23 0.000
|*** | .*| | 6 0.403 -0.069 157.39 0.000
|** | | | 7 0.314 -0.002 164.89 0.000
|** | .*| | 8 0.223 -0.153 168.74 0.000
|* | .*| | 9 0.110 -0.183 169.69 0.000
| | .*| | 10 -0.005 -0.079 169.69 0.000
| | |** | 11 -0.024 0.231 169.73 0.000
| | |* | 12 0.010 0.089 169.74 0.000
| | | | 13 0.018 -0.018 169.77 0.000
| | | | 14 -0.022 0.034 169.81 0.000
*| | .*| | 15 -0.086 -0.126 170.46 0.000
*| | | | 16 -0.116 -0.053 171.66 0.000
*| | | | 17 -0.124 -0.045 173.07 0.000
*| | | | 18 -0.104 0.049 174.08 0.000
*| | | | 19 -0.093 -0.051 174.89 0.000
Như vậy, chuỗi VNINDEX chưa dừng, ta có thể lấy sai phân bậc một của chuỗi này
Thử xem đồ thị Correlogram của chuỗi sai phân bậc 1:
Included observations: 65
Autocorrelation Partial Correlation AC PAC Q-Stat Prob
| | | | 1 0.052 0.052 0.1816 0.670
*| | .*| | 2 -0.115 -0.118 1.0964 0.578
**| | **| | 3 -0.270 -0.262 6.2342 0.101
|** | |** | 4 0.276 0.312 11.690 0.020
| | .*| | 5 -0.012 -0.131 11.701 0.039
| | | | 6 0.056 0.068 11.930 0.064
|* | |** | 7 0.089 0.273 12.525 0.085
|* | | | 8 0.189 0.034 15.259 0.054
| | | | 9 -0.053 0.023 15.480 0.079
**| | .*| | 10 -0.234 -0.181 19.816 0.031
*| | **| | 11 -0.166 -0.206 22.038 0.024
|* | | | 12 0.079 -0.002 22.553 0.032
|* | .*| | 13 0.089 -0.081 23.220 0.039
| | |* | 14 0.053 0.077 23.457 0.053
| | | | 15 -0.056 0.023 23.732 0.070
*| | .*| | 16 -0.077 -0.085 24.253 0.084
*| | | | 17 -0.137 -0.007 25.966 0.075
| | | | 18 -0.031 0.007 26.057 0.098
| | | | 19 0.022 -0.003 26.102 0.127
Như vậy sau khi lấy sai phân bậc một chuỗi đã dừng :
d=1, AC tắt nhanh về 0 sau 1 độ trễ
q=1, PAC giảm nhanh về 0 sau 1 độ trễ:
Trang 5 p=1
có thể sử dụng mô hình ARIMA(1,1,1)
ƯỚC LƯỢNG VÀ KIỂM ĐỊNH VỚI MÔ HÌNH ARIMA
LS d(vnindex) c MA(1) AR(1)
Dependent Variable: D(VNINDEX)
Method: Least Squares
Date: 04/16/10 Time: 12:17
Sample (adjusted): 1/18/2010 4/15/2010
Included observations: 64 after adjustments
Convergence achieved after 12 iterations
MA Backcast: 1/15/2010
Variable Coefficient Std Error t-Statistic Prob
AR(1) -0.817981 0.115031 -7.110947 0.0000
R-squared 0.121473 Mean dependent var -0.304063
Adjusted R-squared 0.092668 S.D dependent var 7.508551
S.E of regression 7.152191 Akaike info criterion 6.818455
Sum squared resid 3120.384 Schwarz criterion 6.919653
Log likelihood -215.1906 Hannan-Quinn criter 6.858322
F-statistic 4.217190 Durbin-Watson stat 1.698170
Kiểm định Q_statistics:
Date: 04/16/10 Time: 12:18
Sample: 1/18/2010 4/15/2010
Included observations: 64
Q-statistic
probabilities adjusted
for 2 ARMA term(s)
Autocorrelation Partial Correlation AC PAC Q-Stat Prob
|* | |* | 1 0.139 0.139 1.2861
**| | **| | 2 -0.226 -0.250 4.7596
*| | .*| | 3 -0.196 -0.133 7.4167 0.006
|** | |** | 4 0.251 0.272 11.858 0.003
| | .*| | 5 0.006 -0.175 11.860 0.008
| | |* | 6 0.022 0.152 11.895 0.018
|* | |** | 7 0.145 0.227 13.447 0.020
|* | | | 8 0.186 0.036 16.063 0.013
*| | | | 9 -0.082 0.016 16.577 0.020
**| | .*| | 10 -0.225 -0.161 20.534 0.008
*| | **| | 11 -0.205 -0.273 23.877 0.005
|* | |* | 12 0.138 0.114 25.420 0.005
Nhìn vào hình trên ta thấy sai số là ngẫu nhiên.( vì nằm trong giới hạn)
Trang 6Kiểm định Histogram-Normality Test
0
2
4
6
8
10
12
14
Series: Residuals Sample 1/18/2010 4/15/2010 Observations 64
Mean 0.017054 Median -0.042554 Maximum 15.62478 Minimum -18.94623 Std Dev 7.037728 Skewness -0.303746 Kurtosis 3.014685 Jarque-Bera 0.984697 Probability 0.611189
Vì prob =0.611189 > 0.05
có phân phối chuẩn
Như vậy, sai số của mô hình ARIMA(1,1,1) là một chuỗi dừng và nó có phân phối chuẩn Sai số này là nhiễu trắng
THỰC HIỆN DỰ BÁO VÀ TÌM RMSE CỦA MÔ HÌNH ARIMA(1,1,1):
Vào forecast:
440
460
480
500
520
540
560
Forecast: VNINDEXF_111 Actual: VNINDEX Forecast sample: 1/14/2010 4/30/2010 Adjusted sample: 1/18/2010 4/16/2010 Included observations: 64
Root Mean Squared Error 6.982550 Mean Absolute Error 5.489680 Mean Abs Percent Error 1.088243 Theil Inequality Coefficient 0.006897 Bias Proportion 0.000006 Variance Proportion 0.002165 Covariance Proportion 0.997829
Ta thấy RMSE =6.982
Trang 7Mean Abs percent Error =1.08 < 10% => tốt
Theil inequality coeficient = 0.006 < 0.55 => tốt
SO SÁNH MÔ HÌNH ARIMA(1,1,2) VỚI ARIMA(1,1,1)
LS D(vnindex) c MA(1) MA(2) AR(1)
Dependent Variable: D(VNINDEX)
Method: Least Squares
Date: 04/16/10 Time: 12:34
Sample (adjusted): 1/18/2010 4/15/2010
Included observations: 64 after adjustments
Convergence achieved after 22 iterations
MA Backcast: 1/14/2010 1/15/2010
Variable Coefficient Std Error t-Statistic Prob
AR(1) -0.873398 0.065469 -13.34062 0.0000
R-squared 0.196284 Mean dependent var -0.304063
Adjusted R-squared 0.156099 S.D dependent var 7.508551
S.E of regression 6.897663 Akaike info criterion 6.760704
Sum squared resid 2854.665 Schwarz criterion 6.895634
Log likelihood -212.3425 Hannan-Quinn criter 6.813860
F-statistic 4.884424 Durbin-Watson stat 2.127172
Prob(F-statistic) 0.004190
Inverted AR Roots -.87
0
2
4
6
8
10
12
14
16
Series: Residuals Sample 1/18/2010 4/15/2010 Observations 64
Mean 0.011974 Median 0.151253 Maximum 16.46816 Minimum -16.58250 Std Dev 6.731419 Skewness -0.475120 Kurtosis 3.410376 Jarque-Bera 2.856975 Probability 0.239671
PROB =0.23>0.05 => TỐT
Trang 8Date: 04/16/10 Time: 12:36
Sample: 1/18/2010 4/15/2010
Included observations: 64
Q-statistic
probabilities adjusted
for 3 ARMA term(s)
Autocorrelation Partial Correlation AC PAC Q-Stat Prob
*| | .*| | 1 -0.075 -0.075 0.3818
**| | **| | 2 -0.241 -0.248 4.3416
*| | .*| | 3 -0.126 -0.179 5.4388
|** | |* | 4 0.245 0.166 9.6478 0.002
| | | | 5 0.005 -0.024 9.6495 0.008
*| | | | 6 -0.114 -0.047 10.596 0.014
|** | |** | 7 0.214 0.289 13.987 0.007
| | | | 8 0.061 0.038 14.266 0.014
| | |* | 9 0.010 0.121 14.273 0.027
**| | .*| | 10 -0.209 -0.087 17.687 0.013
*| | **| | 11 -0.151 -0.314 19.513 0.012
|* | | | 12 0.173 0.073 21.934 0.009
| | **| | 13 -0.035 -0.210 22.038 0.015
|* | |* | 14 0.105 0.111 22.965 0.018
*| | | | 15 -0.099 0.038 23.803 0.022
| | .*| | 16 0.016 -0.087 23.826 0.033
=> Sai số ngẫu nhiên
440
460
480
500
520
540
560
Forecast: VNINDEXF_1 Actual: VNINDEX Forecast sample: 1/14/2010 4/30/2010 Adjusted sample: 1/18/2010 4/16/2010 Included observations: 64
Root Mean Squared Error 6.678633 Mean Absolute Error 5.035281 Mean Abs Percent Error 0.999563 Theil Inequality Coefficient 0.006596 Bias Proportion 0.000003 Variance Proportion 0.012723 Covariance Proportion 0.987274
Ta thấy các điều kiện cần thiết của một mô hình ARIMA dự đoán thì ARIMA(1,1,2) đều thõa mãn.
=>Ta sẽ đi so sánh RMSE của 2 mô hình, mô hình nào có RMSE nhỏ hơn sẽ là mô hình thích hợp hơn trong trường hợp này (0.6982>0.667)
Ta còn có thể so sánh 2 đồ thị sau để thấy rõ điều đó:
Trang 9-20
-10
0
10
20
-20 -10 0 10 20 30
ARIMA(1,1,1)
-20
-10
0
10
20
-20 -10 0 10 20 30
Residual Actual Fitted
Đồ thị Fitted của ARIMA(1,12) chính xác so với Actual hơn của ARIMA(1,1,1)
Vậy ta chọn mô hình ARIMA(1,1,2) để dự doán.
Trang 10THỰC HIỆN DỰ BÁO XA HƠN:
Trang 113/29/2010 506.70 504.99 7.32
4/19/2010
4/20/2010
4/21/2010
4/22/2010
4/23/2010
4/26/2010
4/27/2010
4/28/2010
4/29/2010
4/30/2010
(Ghi chú:Chỉ số VNIndex ngày 16/4/2010 thực tế là 522.03, sai số dự đoán là: 0.5)
460
470
480
490
500
510
520
530
540
550
2010M01 2010M02 2010M03 2010M04
VNINDEXF_1
460
470
480
490
500
510
520
530
540
550
2010M01 2010M02 2010M03 2010M04
VNINDEX VNINDEXF_1
Trang 12Dependent Variable: D(VNINDEX)
Method: Least Squares
Date: 04/16/10 Time: 12:53
Sample (adjusted): 1/18/2010 4/16/2010
Included observations: 65 after adjustments
Convergence achieved after 22 iterations
MA Backcast: 1/14/2010 1/15/2010
Variable Coefficient Std Error t-Statistic Prob
AR(1) -0.873396 0.064913 -13.45477 0.0000
R-squared 0.197301 Mean dependent var -0.271175
Adjusted R-squared 0.157824 S.D dependent var 7.454376
S.E of regression 6.840891 Akaike info criterion 6.743277
Sum squared resid 2854.665 Schwarz criterion 6.877085
Log likelihood -215.1565 Hannan-Quinn criter 6.796073
F-statistic 4.997879 Durbin-Watson stat 2.134237