楼主: autozhao
14166 29

Regime-Switching GARCH---Hints for MRSGARCH程序 [推广有奖]

  • 9关注
  • 11粉丝

已卖:262份资源

副教授

36%

还不是VIP/贵宾

-

威望
0
论坛币
562 个
通用积分
8.9693
学术水平
8 点
热心指数
14 点
信用等级
4 点
经验
25728 点
帖子
409
精华
0
在线时间
1200 小时
注册时间
2008-10-23
最后登录
2025-6-19

楼主
autozhao 发表于 2010-7-1 01:31:43 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
Forecasting Stock Market Volatility with Regime-Switching GARCH Models_Marcucci.pdf (384.44 KB) marcucci_datacode.zip (207.59 KB)
Forecasting Stock Market Volatility with Regime-Switching GARCH Models" by J. Marcucci 原文和程序,但是程序有错误,下面是作者Marcucci给的修改意见。
=================================================

Hints for  program
Instructions for MRS-GARCH programs for the paper  "Forecasting Stock Market Volatility with Regime-Switching GARCH Models" by J. Marcucci (Studies in Nonlinear Dynamics and Econometrics, 2005)

Get the code from the SNDE website (http://www.bepress.com/snde/vol9/iss4/art6/) at the bottom left of the webpage. Unfortunately the uploaded programs came out with some typos. Below you can find the instructions to slightly change the main program so that it can give you the results without any errors. Please, consider that I ran the programs with Matlab 6 and if you want to "exactly" replicate my results, some could be slightly different. It already happened to other people/students who tried to exactly replicate the results in my paper.
Things to do to have the programs run fine:

There are a couple of typos in the programs downloadable from the SNDE
website that should be fixed. For some unknown reasons a few lines came up
unnecessarily commented or didn't appear at all. Please, follow these instructions and everything should work just fine:
Replace in the main program the following lines after the fmincon call
[...]
% ADDED THE FOLLOWING 2 LINES FOR STD ERR WITH HESSIAN FROM
% OPTIMIZATION. they were disappeared and I don't know why
stder_HESS = sqrt(diag((HESSIAN)^(-1)));
tstat_HESS = parameters./stder_HESS;

[...]

... after se_rob_hess
[...]
%%%%%%%%%%%%%%%%%%%%%%%%%
% ADDED THE FOLLOWING 3 LINES FOR SE_rob_HESS
A2=(1/T)*HESSIAN;
SE_rob_HESS=sqrt((1/T)*diag((A2^(-1))*B*(A2^(-1)))); % hessian from OPTIMIZATION
tstat_HESS_rob = parameters./SE_rob_HESS; % hessian from calculation

[...]
... after tstats

[...]

tstats = parameters./stderrors;
% Printing everything % COMMENTED THE NEXT 5 LINES. THEY WOULD
WRONGLY SET THE GRAD, STDER AND TSTAT TO [] BEFORE STORING THEM!
%GRAD=[];
%stder_HESS=[];
%SE_rob_HESS=[];
%tstat_HESS=[];
%tstat_HESS_rob=[];
If you don't do that, you can get an error because before storing the values, GRAD and the other values are wrongly set to [].
With these corrections, everything should work. Also, you should change the matrix called Parameters in such a way that it can store vectors with different lengths otherwise you will get another error (the dimension mismatch error). It's sufficient to set the number of columns of Parameters to the maximum number of parameters. After fixing this everything should work. Please, email me if it doesn't.
====================================================
这是作者对源程序的修改意见,最后的 change the matrix called Parameters 我没太理解,而且出来的结果都不止该怎么解释,另外,这程序运行的也太慢了,有谁在用这个的时候,有什么问题,交流一下吧!
二维码

扫码加我 拉你入群

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

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

关键词:switching regime switch GARCH Witch GARCH

沙发
wzw03 发表于 2010-7-4 23:03:28
实在是看不懂啊

藤椅
autozhao 发表于 2010-7-5 01:37:56
2# wzw03
我就说这么有意义的帖子怎么没人理呢,呵呵,这下我把原文和程序传上来了,其实帖子里的连接都能下下来的,但原来的程序中有错误,所以作者给出了如本贴的修改意见。但是我在实际用的时候还是出现了问题。一个循环就跑了我六个小时,我都晕了!哈哈。所以希望有人交流下。

板凳
richardma 发表于 2010-7-5 10:35:48
For mrsgarchestfor_con_all.m (line 281)
        % Printing everything
        GRAD=[];
        stder_HESS=[];
        SE_rob_HESS=[];
        tstat_HESS=[];
        tstat_HESS_rob=[];
        fprintf(fid,'Param \t\t GRAD1(optim) \t\t Grad2(gradt) \t\t stdH \t\t stdh \t\t stdRH \t\t stdRh \t\t stderr \t\t tH \t\t th  \t\t tHR \t\t thR \t\t tstats \n');

% COMMENTED THE NEXT 5 LINES. THEY WOULD WRONGLY SET THE GRAD, STDER AND TSTAT TO [] BEFORE STORING THEM!
%GRAD=[];
%stder_HESS=[];
%SE_rob_HESS=[];
%tstat_HESS=[];
%tstat_HESS_rob=[];


Line 274
        SE_rob_hess=sqrt((1/T)*diag(inv(A)*B*inv(A))); % hessian from calculation
        clear likelihoods*;
        clear indivlike*;
        clear scores;

% ADDED THE FOLLOWING 3 LINES FOR SE_rob_HESS
A2=(1/T)*HESSIAN;
SE_rob_HESS=sqrt((1/T)*diag((A2^(-1))*B*(A2^(-1)))); % hessian from OPTIMIZATION
tstat_HESS_rob = parameters./SE_rob_HESS; % hessian from calculation


Line 249
        % asymptotic standard errors
        stder_hess = sqrt(diag((hess)^(-1))); % from calculated hessian
        tstat_hess = parameters./stder_hess;

% ADDED THE FOLLOWING 2 LINES FOR STD ERR WITH HESSIAN FROM
% OPTIMIZATION. they were disappeared and I don't know why
stder_HESS = sqrt(diag((HESSIAN)^(-1)));
tstat_HESS = parameters./stder_HESS;

报纸
autozhao 发表于 2010-7-5 12:27:50
4# richardma

谢谢你的回复啊,我也是按你描述的那样改的,但Marcucci最后还说“Also, you should change the matrix called Parameters ”
这个怎么改啊?作者的意思应该是改了上面的三个地方之后运行就会没问题了吧!

不知您运行的时候花了多少时间啊,我运行的时候没有全部都循环,我就是选择了errrotype是4的那个试运行的,可还是花了很多时间。因为没用C做,我直接在MATLAB上跑的,可这速度也太折磨人了。呵呵。决定有时间复习一下C语言,用C环境跑一下。

我用的是2009a,AMD单核的老家伙。有钱了,咱也弄他个4核CPU,8G内存,哈哈哈

地板
tulipsliu 在职认证  发表于 2010-7-5 12:34:55
即使多核也没用;
MATLAB非常快了,仅次于C语言的速度,这个是迷人的速度。我用EVIEWS做过一次5000次的蒙特卡洛仿真,那个速度,很吓人,45分钟才出结果;
MATLAB多路径,20天的10000次仿真,不超过一秒。

谢谢你的分享,这样深入的讨论MATLAB,该帮你顶起来,我下载你这个程序试试,我跑过后如有心得体会,会再回帖的。
劳动经济学

7
tulipsliu 在职认证  发表于 2010-7-5 12:36:40
你可以搜索国内的一个参考文献。
也是用 区制选择 来做经济周期与证券牛熊周期的,作者的观点是,中国资本市场的证券牛熊周期,和经济周期是不同步的。
这个是前沿的研究了。
劳动经济学

8
tulipsliu 在职认证  发表于 2010-7-5 12:43:10
弄错了
虽然也是 马氏域的区制转换模型,不过这个是用协整的吧。
呵呵。
劳动经济学

9
tulipsliu 在职认证  发表于 2010-7-5 13:16:30
兄弟,你的ZIP文件里的MATLAB文件是不是你已经把作者提示要修改的地方修改了?
我刚才错操作,打开主程序变成运行了,现在MATLAB还在喘气。

给你个建议。每次非线性优化都要显示迭代次数。你可以关闭这个: 'Display','off'
这个也是消耗时间的。
劳动经济学

10
autozhao 发表于 2010-7-5 13:45:42
9# tulipsliu
十分感谢tulipsliu哥们的热心和回复,你提供的文献过会我也看看,学习的道路还是很坎坷的,遇上几个同路人,倍感神清气爽啊。有什么心得再回来交流啊!

对了,我上传的程序是没改过的。

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

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