楼主: bang4kimo
11443 42

[问答] VAR-GARCH 有共整合現象,該怎麼辦(RATS) [推广有奖]

11
bang4kimo 发表于 2012-2-28 20:31:44
看了之後仍有些問題請叫妳??

open data 12345_plas.xls
data(format=xls,org=columns) 1 1990 EX PLAS
set lex = log(ex)
set lplas = log(plas)
set dlex = lex-lex{1}
set dlplas = lplas-lplas{1}

*Using VARLagSelect
@varlagselect(lags=6,crit=aic)
#lex lplas                       

@varlagselect(lags=6,crit=bic)
#lex lplas     
請問這裡應該是要打dlex dplas嗎?因為var是報酬不是股價,為什麼要取log
我@varlagselect不能使用,用打的也是一樣,出現下面的字
## CP18. VARLAGSELECT is not the Name of a PROCEDURE. (Did you forget to SOURCE?)
>>>>@varlagselect(<<<<



*Use @JohMLE to test the cointegrating rank
*RC restricts a constant to the CV.
@johmle(lags=2,det=rc,cv=cvector)   
我還是不懂@johmle(lags=2,det=rc,cv=cvector)的意思??為什麼要用這個??
# lex lplas
*-32.943952 -4.664164 138.156062   這個係數是什麼意思??
這個是在算共整合的數目嗎??


*Setting the Cointegrating Vectors
set ect = lex+(-4.664164/-32.943952)*lplas+(138.156062/-32.943952)  
為什麼ECT是這個方程式,ect不是殘差嗎??為什麼要用lex阿~用ex不行嗎??
system(model=ectmodel)
variables dlex dlplas
det dlex{1} dlplas{1} ect{1}
end(system)
estimate

garch(p=1,q=1,model=ectmodel,mv=CC,variances=varma,pmethod=simplex,piters=10) / dlex dlplas

###Result

VAR Lag Selection
Lags   AICC
   0  -7915.392
   1 -27573.420
   2 -27690.568*
   3 -27686.446
   4 -27684.223
   5 -27680.034
   6 -27676.404


VAR Lag Selection
Lags SBC/BIC
   0  -7904.210
   1 -27539.884
   2 -27634.694*
   3 -27608.252
   4 -27583.724
   5 -27557.248
   6 -27531.346


Likelihood Based Analysis of Cointegration
Variables:  LEX LPLAS
Estimated from 3 to 1990
Data Points 1988 Lags 2 with Constant restricted to Cointegrating Vector

Unrestricted eigenvalues and -T log(1-lambda)
   Rank     EigVal   Lambda-max  Trace  Trace-95%    LogL
         0                                        13875.4709
         1    0.0082    16.3881 21.0371   20.1600 13883.6650
         2    0.0023     4.6490  4.6490       9.1400 13885.9895

Cointegrating Vector for Largest Eigenvalue
      LEX         LPLAS       Constant
-32.943952 -4.664164 138.156062


VAR/System - Estimation by Least Squares
Usable Observations                      1988

Dependent Variable DLEX
Mean of Dependent Variable       -0.000056503
Std Error of Dependent Variable   0.003859426
Standard Error of Estimate        0.003772583
Sum of Squared Residuals         0.0282512779
Durbin-Watson Statistic                2.0112

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  DLEX{1}                      -0.197217952  0.022550732     -8.74552  0.00000000
2.  DLPLAS{1}                  -0.012928663  0.005830038     -2.21760  0.02669531
3.  ECT{1}                        -0.010949180  0.002787445     -3.92803  0.00008857

Dependent Variable DLPLAS
Mean of Dependent Variable       0.0002526575
Std Error of Dependent Variable  0.0149844276
Standard Error of Estimate       0.0148682946
Sum of Squared Residuals         0.4388163770
Durbin-Watson Statistic                2.0013

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  DLEX{1}                      -0.286770831  0.088875693     -3.22665  0.00127287
2.  DLPLAS{1}                   0.078548137  0.022977022      3.41855  0.00064227
3.  ECT{1}                         0.021328734  0.010985724      1.94150  0.05233954

綠色的表,我看不懂是跑什麼??

MV-GARCH, CC with VARMA Variances - Estimation by BFGS
Convergence in    50 Iterations. Final criterion was  0.0000002 <=  0.0000100
Usable Observations                      1988
Log Likelihood                     14772.1370

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  DLEX{1}                            0.1119       0.0262      4.27376  0.00001922
2.  DLPLAS{1}                     6.3905e-003  2.7082e-003      2.35968  0.01829052
3.  ECT{1}                       -2.7697e-003  1.1520e-003     -2.40418  0.01620858
4.  DLEX{1}                           -0.2148       0.0615     -3.49070  0.00048175
5.  DLPLAS{1}                          0.0726       0.0246      2.95159  0.00316138
6.  ECT{1}                             0.0194  9.2769e-003      2.09551  0.03612601
7.  C(1)                          2.8101e-007  9.9215e-008      2.83240  0.00462007
8.  C(2)                          1.5275e-006  5.9145e-007      2.58257  0.00980679
9.  A(1,1)                             0.3345       0.0325     10.28299  0.00000000
10. A(1,2)                             0.0162  3.8395e-003      4.21287  0.00002521
11. A(2,1)                            -0.0336       0.0378     -0.88964  0.37366150
12. A(2,2)                             0.0451       0.0118      3.81509  0.00013613
13. B(1,1)                             0.7402       0.0158     46.83072  0.00000000
14. B(1,2)                       -6.1707e-003       0.0136     -0.45328  0.65034634
15. B(2,1)                             0.0896       0.0462      1.93839  0.05257527
16. B(2,2)                             0.9523       0.0127     74.84755  0.00000000
17. R(2,1)                            -0.2958       0.0198    -14.91109  0.00000000


var的最適落後項應該要在共整合檢定之後嗎??我不懂先做var的意義在哪裡??
如果最適的落後像是2,那麼是不是vecm-garch要是vaecm(2)-garch
我的vacm裡除了Z,之外的變數要是報酬

真的很謝謝妳,希望妳看得懂我的問題,我計量好像不太好,
如果看不懂的話,可以麻煩妳直接解釋程式的步驟~真的很感激你!!

12
bang4kimo 发表于 2012-2-29 01:09:41
阿~我看了計量的書大概了解了,上面的問題就算了
我從新問過我還是不懂的
*Use @JohMLE to test the cointegrating rank
*RC restricts a constant to the CV.
@johmle(lags=2,det=rc,cv=cvector)   
我還是不懂@johmle(lags=2,det=rc,cv=cvector)
因為上面有選最適落項,是兩項,所以這裡才用lags
det=rc 這個我看不懂??是在說共整合向量要不要有常數項嗎??
cv是是共整合的向量吧!
就是這個表算的
Cointegrating Vector for Largest Eigenvalue
      LEX         LPLAS       Constant
-32.943952 -4.664164 138.156062
但為何這個向量沒有ECT的??


ect我看不懂為什麼要這樣算
不是應該是上期的殘差嗎?
要用減的嗎?為時麼有加也有除呢??
set ect = lex+(-4.664164/-32.943952)*lplas+(138.156062/-32.943952) 

妳上次說和EVIEWS算的一樣?請問是指什麼地方一樣啊??
我也想要知道要怎麼驗算??
真的謝謝您!!!

13
epoh 发表于 2012-2-29 21:32:10
bang4kimo 发表于 2012-2-29 01:09
阿~我看了計量的書大概了解了,上面的問題就算了
我從新問過我還是不懂的
*Use @JohMLE to test the coi ...
哈哈!你的底子不错,一看就会
Q1:@johmle(lags=2,det=rc,cv=cvector) 
   det = rc是在说共整合向量要不要有常数项吗?
   cv 是是共整合的向量吧?(cointegrating vectors)
ANS : 对,就是EViews 6 User's Guide II
      page 366/688
      Cointegration Test Specification
      case 2. The level data have no deterministic trends and
                  the cointegrating equations have intercepts

Q2:winrats:
    Cointegrating Vector for Largest Eigenvalue
      LEX               LPLAS         Constant
     -32.943952   -4.664164   138.156062

   e-views:
     LEX                  LPLAS                  C
    -33.05168        -4.674294         138.5770

                                 
   Normalized cointegrating coefficients (standard error in parentheses)                                
     LEX                 LPLAS                  C               
    1.000000         0.141424        -4.192738               
                           (0.02803)         (0.14511)
                  
   所以你看到的底下公式就是Normalized cointegrating coefficients
   set ect = lex+(-4.664164/-32.943952)*lplas+(138.156062/-32.943952) 

另请仔细看page ug-243,formula(30),(31),(32)
自然容易理解
7.8 Cointegration and Error Correction Models

    beta : cointegrating vectors (cv)
    alpha: adjustment parameters in the VEC model

附上e-views workfile供参考比较
ex_plas.wf1   
    ex_plas.rar (46.59 KB) 本附件包括:
  • ex_plas.wf1

14
bang4kimo 发表于 2012-5-11 21:31:56
我想要請教一下,請問在做共整合時的最適落後期數是用股價取log,也就是log(股價)的最適落後期
那在做VAR時,VAR裡放報酬,也是就dlog(股價),VAR的最適落後期數是要用dlog(股價)嗎??
做共整合的最適落後期數選擇和var的最適落後期數選擇,是不是不同??選出來的落後項也有可能不同

謝謝您!!!這個問題我想好久了,一般paper都沒有詳細的寫~謝謝您!!

15
epoh 发表于 2012-5-12 20:41:02
bang4kimo 发表于 2012-5-11 21:31
我想要請教一下,請問在做共整合時的最適落後期數是用股價取log,也就是log(股價)的最適落後期
那在做VAR時 ...
VAR的最适落后期数是要用dlog(股价)吗? 对.

共整合的最适落后期数选择是用lex lplas
选出的是 lag 2
很自然的vecm model lag 是1
@johmle(lags=2,det=rc,cv=cvector)
# lex lplas
*-32.943952 -4.664164 138.156062
SYSTEM(MODEL=ecttmodel)
VARIABLES dlex dlplas
DET dlex{1} dlplas{1}
ect ecteq
END(SYSTEM)
ESTIMATE

16
bang4kimo 发表于 2012-5-12 21:17:01
epoh 发表于 2012-5-12 20:41
VAR的最适落后期数是要用dlog(股价)吗? 对.

做共整合的最适落后期数选择是用lex lplas
第一個問題??
為什麼做共整合的最适落后期数选择是用lex lplas
选出的是 lag 2
很自然的vecm model lag 是1

為什麼共整合(股價)選出的是2做vecm的lag卻是1???
這是因為還有在選vecm(裡面是報酬)的最適落後項嗎??

第二個問題
如果做共整合最適落後項是2,用lag=2去做共整合~發現沒有共整合現象
那在做var 時(裡面都是放報酬),選擇最適落後項是5,
請問我上面的描述的做法是是對的嗎??

謝謝妳

17
epoh 发表于 2012-5-12 21:32:15
bang4kimo 发表于 2012-5-12 21:17
第一個問題??
為什麼做共整合的最适落后期数选择是用lex lplas
选出的是 lag 2
这个问题跟传统的VAR,VECM相同
建议你看本计量的书或
EViews 6 User’s Guide II
Chapter 34. Vector Autoregression and Error Correction Models

18
bang4kimo 发表于 2012-5-12 23:09:02
我研究一下~
我計量的書都沒有講得很仔細,都是說要選最適落後項?
後來就沒有說了~
我在翻翻~

19
bang4kimo 发表于 2012-5-13 14:26:56
我研究了一下,
在rats 6
Lag Intervals
You should specify the lags of the test VAR as pairs of intervals. Note that the lags are specified
as lags of the first differenced terms used in the auxiliary regression, not in terms of the
levels. For example, if you type “1 2” in the edit field, the test VAR regresses on
, , and any other exogenous variables that you have specified. Note that in
terms of the level series the largest lag is 3. To run a cointegration test with one lag in the
level series, type “0 0” in the edit field.

所以level是N lags 時,跑 var和 vecm落後階數都是N-1legs是吧?!

然後我用E-VIEWS和RATS 跑共整合的係數值對不起來
下面是E-VIEWS
Date: 05/13/12   Time: 14:07                               
Sample: 1/15/2004 12/30/2011                               
Included observations: 1952                               
Trend assumption: No deterministic trend (restricted constant)                               
Series: LOG_US_ LOG_PLAS_                                
Lags interval (in first differences): 1 to 7                               
                               
Unrestricted Cointegration Rank Test (Trace)                               
                               
Hypothesized                Trace        0.05       
No. of CE(s)        Eigenvalue        Statistic        Critical Value        Prob.**
                               
None *         0.008545         20.99231         20.26184         0.0396
At most 1         0.002171         4.241583         9.164546         0.3773
                               
Trace test indicates 1 cointegrating eqn(s) at the 0.05 level                               
* denotes rejection of the hypothesis at the 0.05 level                               
**MacKinnon-Haug-Michelis (1999) p-values                               
                               
Unrestricted Cointegration Rank Test (Maximum Eigenvalue)                               
                               
Hypothesized                Max-Eigen        0.05       
No. of CE(s)        Eigenvalue        Statistic        Critical Value        Prob.**
                               
None *         0.008545         16.75072         15.89210         0.0366
At most 1         0.002171         4.241583         9.164546         0.3773
                               
Max-eigenvalue test indicates 1 cointegrating eqn(s) at the 0.05 level                               
* denotes rejection of the hypothesis at the 0.05 level                               
**MacKinnon-Haug-Michelis (1999) p-values                               
                               
Unrestricted Cointegrating Coefficients (normalized by b'*S11*b=I):                                
                               
LOG_US_        LOG_PLAS_        C               
-78.95827        -10.01153         141.1289               
-2.438996         8.135158        -14.75207               
                               
                               
Unrestricted Adjustment Coefficients (alpha):                                
                               
D(LOG_US_)         0.000119        -2.23E-05               
D(LOG_PLAS_)        -0.000350        -0.000248               
                               
                               
1 Cointegrating Equation(s):                 Log likelihood         17223.19       
                               
Normalized cointegrating coefficients (standard error in parentheses)                               
LOG_US_        LOG_PLAS_        C               
1.000000         0.126795        -1.787386               
                 (0.02647)         (0.05952)               
                               
Adjustment coefficients (standard error in parentheses)                               
D(LOG_US_)        -0.009386                       
                        (0.00245)                       
D(LOG_PLAS_)         0.027648                       
                        (0.01170)                       
                               


下面是RATS

open data finalprice_r.xlsx
data(format=xlsx,org=columns) 1 1961 TINDEX US JAP ELEC FIN PLAS MACH GLASS Chemicals Stell

set LTINDEX = log(TINDEX)
set LUS = log(US)
set LJAP = log(JAP)
set LELEC = log(ELEC)
set LFIN = log(FIN)
set LPLAS = log(PLAS)
set LMACH = log(MACH)
set LGLASS = log(GLASS)
set LChemicals = log(Chemicals)
set LStell = log(Stell)
set DLTINDEX = LTINDEX-LTINDEX{1}
set DLUS = LUS-LUS{1}
set DLJAP = LJAP-LJAP{1}
set DLELEC = LELEC-LELEC{1}
set DLFIN = LFIN-LFIN{1}
set DLPLAS = LPLAS-LPLAS{1}
set DLMACH = LMACH-LMACH{1}
set DLGLASS = LGLASS-LGLASS{1}
set DLChemicals = LChemicals-LChemicals{1}
set DLStell = LStell-LStell{1}

*Using VARLagSelect
@varlagselect(lags=24,crit=aic)
#LUS LPLAS

*Using VARLagSelect
@varlagselect(lags=24,crit=bic)
#LUS LPLAS

*Use @JohMLE to test the cointegrating rank
*RC restricts a constant to the CV.
@johmle(lags=7,det=rc,cv=cvector)
#LUS LPLAS

Likelihood Based Analysis of Cointegration
Variables:  LUS LPLAS
Estimated from 8 to 1961
Data Points 1954 Lags 7 with Constant restricted to Cointegrating Vector

Unrestricted eigenvalues and -T log(1-lambda)
   Rank     EigVal   Lambda-max  Trace  Trace-95%    LogL
         0                                        13967.8037
         1    0.0090    17.6557 22.3083   20.1600 13976.6315
         2    0.0024     4.6526  4.6526    9.1400 13978.9578

Cointegrating Vector for Largest Eigenvalue
LUS             LPLAS            Constant
-34.060339  -4.381156     140.495053


為什麼差這麼多??我哪裡有做錯

finalprice_r.xls
下载链接: https://bbs.pinggu.org/a-1110008.html

191.5 KB

股價_共整寺(log,txt).rar

26.26 KB

本附件包括:

  • 股價_共整寺(log,txt).wf1

20
epoh 发表于 2012-5-13 19:10:54
bang4kimo 发表于 2012-5-13 14:26
我研究了一下,
在rats 6
Lag Intervals
这个问题我在10楼已答复过
现传e-views文件供你参考比较
(上传不了)

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-27 09:07