全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 MATLAB等数学软件专版
13980 29
2010-07-01
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 我没太理解,而且出来的结果都不止该怎么解释,另外,这程序运行的也太慢了,有谁在用这个的时候,有什么问题,交流一下吧!
二维码

扫码加我 拉你入群

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

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

全部回复
2010-7-4 23:03:28
实在是看不懂啊
二维码

扫码加我 拉你入群

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

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

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

扫码加我 拉你入群

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

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

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;
二维码

扫码加我 拉你入群

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

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

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内存,哈哈哈
二维码

扫码加我 拉你入群

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

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

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

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

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群