楼主: bang4kimo
11479 42

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

  • 2关注
  • 5粉丝

已卖:1份资源

本科生

70%

还不是VIP/贵宾

-

威望
0
论坛币
90 个
通用积分
0.0600
学术水平
1 点
热心指数
0 点
信用等级
0 点
经验
957 点
帖子
103
精华
0
在线时间
81 小时
注册时间
2012-2-14
最后登录
2012-5-25

楼主
bang4kimo 发表于 2012-2-25 23:36:07 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
我用RAT 8.0我想跑雙變量的 VAR -GARCH
我檢定我的VAR裡有共整合現象
那我應該要如何修正我的程式碼
讓她可以跑共整合呢??
我看的論文裡面有VAR~得全部都是沒有整合現象??
所以我不知道應該如何在我的方程式裡改成有共整何


system(model=var1)
variables ex elec
lags 1
det constant
end(system)
garch(p=1,q=1,model=var1,mv=CC,variances=varma,pmethod=simplex,piters=10)


請問這樣我下面這樣是對的嗎?
system(model=ectmodel)
variables EX ELEC
lags 1
det constant
end(system)
garch(p=1,q=1,model=ectmodel,mv=CC,variances=varma,pmethod=simplex,piters=10)

但我跑出來的結果都一樣,怎麼會??
謝謝你~~
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:GARCH Rats ARCH ARC RCH 修正 system 如何

本帖被以下文库推荐

沙发
epoh 发表于 2012-2-26 10:29:02
依题意,可能是要做vecm-garch??

藤椅
bang4kimo 发表于 2012-2-26 11:25:50
我在user guide找不到程式碼??
請問rats 能跑嗎?要怎麼輸入程式碼呢
system(model=var1)
variables ex elec
lags 1
det constant
end(system)
garch(p=1,q=1,model=var1,mv=CC,variances=varma,pmethod=simplex,piters=10)




我這樣輸入不行
請問該怎麼跑~


板凳
epoh 发表于 2012-2-26 22:10:00
bang4kimo 发表于 2012-2-26 11:25
我在user guide找不到程式碼??
請問rats 能跑嗎?要怎麼輸入程式碼呢
system(model=var1)
先不谈GARCH的部分
想必你对VAR & VECM有一定的了解
首先你必须先列两者方程的不同
自然你就知道
VECM需要先自订DEX,DELEC,ECT
SET DEX = .....
SET DELEC = .....
SET ECT  =  .....
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
灰色圈圈1212 + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

报纸
bang4kimo 发表于 2012-2-27 00:15:12
阿~我打錯了~
我網路上找到有人這樣打
說是可以跑VECM GARCH
我照打了~但還是不行
原因是ect{1}
我不知道我應該要如何定義ect{1}??
我的檔案裡 ex 和plas 已經是取過差分的報酬了
是穩定了~但是ex 和plas原始的價格序列存在一個共整合(我用eviews跑出來的)
要怎麼樣定義ect?? 我不太懂程式
跑vecm-garch 是要ect 還是要ect{1}???

謝謝妳!!!
*
* Define a three lag VAR with the gap being a cointegrating vector
*
system(model=vecmmodel)
variables plas
lags 1 to 3
det constant ect{1}
end(system)
*
* Estimate by GARCH-BEKK
*
garch(model=vecmmodel,mv=bekk,hmatrices=h,rvector=r,$
  pmethod=simplex,piters=5,method=bfgs,iters=400)  1983:1:10 1992:7:31
*
* Compute correlations from GARCH model
*
set rou1 = h(t)(1,2)/sqrt(h(t)(1,1)*h(t)(2,2))
statistics rou1
*
* NRED1 and NRED2 are probably supposed to be standardized residuals, but they aren't
* being computed correctly. This computes standardized residuals into stdresids(1) and
* stdresids(2)
*
dec vect[series] stdresids(2)
do i=1,2
   set stdresids(i) = ([vector] stdr=inv(%decomp(h(t)))*r(t)),stdr(i)
end do i


地板
bang4kimo 发表于 2012-2-27 05:11:03
我試了一下,但我不知道這樣到底是對還是錯??
拜託幫我看一下~~

假設VAR我的方程式是
EX=C+PLAS(1)+EX(1)+e
PLAS=C+PLAS(1)+EX(1)+e
如果我的VAR有共整合
變成下面的'VECM
Y=lemada+Z(1)+X(1)+Y(1)

EX=lemada*(PLAS-beta*EX)+PLAS(1)+EX(1)+e
PLAS=lemada*(EX-beta*PLAS)+PLAS(1)+EX(1)+e
VECM方程式是這樣子嗎??

如果我在打RATS程式時ECT=PLAS-EX
在程式裡跑的時候是不是都是這個 ECT=PLAS-EX??
我的程式有沒有錯啊??
有要需要知道EX 和 PLAS的共整合有幾個才能設計ECT嗎??
               

data(format=xlsx,org=columns) 1 1990 EX TINDEX ELEC FIN PLAS MACH GLASS Chemicals
SET ECT  =PLAS-EX
system(model=vecmmodel)
variables EX PLAS
lags 1
det constant ect{1}
end(system)
garch(p=1,q=1,model=vecmmodel,mv=CC,variances=varma,pmethod=simplex,piters=10)


MV-GARCH, CC with VARMA Variances - Estimation by BFGS
Convergence in    57 Iterations. Final criterion was  0.0000093 <=  0.0000100
Usable Observations                      1989
Log Likelihood                     18095.9870

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  EX{1}                              0.1037       0.0273      3.79429  0.00014807
2.  PLAS{1}                            0.0107  2.9864e-003      3.58951  0.00033130
3.  Constant                      1.6497e-005  1.9304e-005      0.85460  0.39277495
4.  ECT{1}                       -4.7177e-003  2.7238e-003     -1.73204  0.08326580
5.  EX{1}                             -0.1141       0.0645     -1.76946  0.07681669
6.  PLAS{1}                           -0.0188       0.0216     -0.87241  0.38298203
7.  Constant                      2.0168e-004  1.2133e-004      1.66228  0.09645715
8.  ECT{1}                             0.0929       0.0201      4.61029  0.00000402
9.  C(1)                          5.8509e-008  1.7328e-008      3.37654  0.00073405
10. C(2)                          2.7290e-007  1.0803e-007      2.52615  0.01153200
11. A(1,1)                             0.3373       0.0293     11.52776  0.00000000
12. A(1,2)                             0.0154  3.6944e-003      4.17702  0.00002953
13. A(2,1)                            -0.0259       0.0345     -0.75061  0.45288471
14. A(2,2)                             0.0436       0.0108      4.04576  0.00005215
15. B(1,1)                             0.7392       0.0146     50.70248  0.00000000
16. B(1,2)                       -2.1944e-003       0.0128     -0.17168  0.86369033
17. B(2,1)                             0.0812       0.0447      1.81702  0.06921475
18. B(2,2)                             0.9542       0.0119     80.36003  0.00000000
19. R(2,1)                            -0.2997       0.0191    -15.70715  0.00000000




7
epoh 发表于 2012-2-27 11:58:11
bang4kimo 发表于 2012-2-27 05:11
我試了一下,但我不知道這樣到底是對還是錯??
拜託幫我看一下~~
假设exp,plasp是原始价格序列
则level分别为
   set plas=100*log(plasp)
   set ex=100*log(exp)  
则first difference(一阶差分),分别是dex,dplas
(等于你的ex,plas)
   set dplas=plas-plas{1}
   set dex=ex-ex{1}  
error correction term
里的变量应该是level非first difference
可参考
EViews 6 User’s Guide II
Chapter 34. Vector Autoregression and Error Correction Models
page 380/688    formula(34.46)

若再有问题
请提供ex 和plas原始的价格序列
我帮你看看

8
bang4kimo 发表于 2012-2-27 13:41:16
阿~對~忘記要原始序列了~
我附上檔案了

假設VAR我的方程式是
EX=C+PLAS(1)+EX(1)+e
PLAS=C+PLAS(1)+EX(1)+e
如果我的VAR有共整合
變成下面的'VECM
Y=lemada*Z(1)+X(1)+Y(1)

VECM方程式是下面樣子嗎??
EX=lemada*(PLAS-beta*EX)(1)+PLAS(1)+EX(1)+e
PLAS=lemada*(EX-beta*PLAS)(1)+PLAS(1)+EX(1)+e

如果我在打RATS程式時 ECT=PLAS-EX
vecm會都是這樣跑嗎?
EX=lemada*(PLAS-beta*EX)(1)+PLAS(1)+EX(1)+e
PLAS=lemada*(PLAS-beta*EX)(1)+PLAS(1)+EX(1)+e
在程式裡跑的時候是不是都是這個 PLAS-beta*EX?
我的程式有沒有錯啊??
有要需要知道EX 和 PLAS的共整合有幾個才能設計ECT嗎??

我不知道我問的,妳看不看得懂
整個程式也不知道我有沒有錯,
可否幫我寫一個??
謝謝您!!

9
bang4kimo 发表于 2012-2-27 14:46:58
我覺得應該是要這樣改


Example 7.7 Error Correction Model
The following (example file ECT.RPF) analyzes a set of three interest rate variables,
first testing for cointegration, then imposing it.
rats does only a limited form of cointegration analysis. For a more complete treatment,
the program cats is available from Estima as an add-on. cats provides more
sophisticated tests for cointegrating rank, model diagnostics and tests on the structures
of both the cointegrating vectors and their loadings (and much more).
cal(m) 1975:1
open data haverate.rat
data(format=rats) 1975:1 2001:6 ftbs3 ftb12 fcm7
Test for unit roots in the original variables
@dfunit(lags=6) ftbs3
@dfunit(lags=6) ftb12
@dfunit(lags=6) fcm7
Use @JohMLE to test the cointegrating rank and estimate the cointegrating vector
corresponding to the largest eigenvalue. Note that it is far from obvious (a priori)
that the cointegrating rank will be one. It might very well be zero, or, if there were
a single stochastic trend linking the yields, then the cointegrating rank would be
two.
Because the series don’t have a trend, the appropriate choice for the deterministic
component is DET=RC, which doesn’t include a constant in the individual
equations (where it would cause the series to drift because of the unit roots), but
restricts it to the cointegrating vector. The components of the cointegrating vector
produced by JohMLE with this choice will have four components: the three variables
+ the constant. If we had done the default DET=CONSTANT, it would only
be a 3-vector. We would also include DET CONSTANT in the SYSTEM definition.

@johmle(lags=6,det=rc,cv=cvector)
# ftbs3 ftb12 fcm7
equation(coeffs=cvector) ecteq *
# ftbs3 ftb12 fcm7 constant
紅色的我不懂計量意義?
也不知道要如何改我的ECT??


Set up the model with the error correction term
system(model=ectmodel)
variables ftbs3 ftb12 fcm7
lags 1 to 6
ect ecteq
end(system)



10
epoh 发表于 2012-2-28 11:14:15
bang4kimo 发表于 2012-2-27 14:46
我覺得應該是要這樣改
底下建立vecm model与在e-views结果相同.

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

*Use @JohMLE to test the cointegrating rank
*RC restricts a constant to the CV.
@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)
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


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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-4 02:52