- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 386043 个
- 通用积分
- 526.9898
- 学术水平
- 127 点
- 热心指数
- 140 点
- 信用等级
- 103 点
- 经验
- 46986 点
- 帖子
- 1773
- 精华
- 0
- 在线时间
- 2509 小时
- 注册时间
- 2007-11-5
- 最后登录
- 2024-8-16
|
- %% This program is writed by Danniel tulip lew
- % Danny have this program`s copyright @2010
- %% The first step:Loading data to whcih will be used to analysis
- CleanUp;
- load mygarchdata
- markpound = SSret;
- figure
- plot(markpound)
- title('市场序列')
- adfval = adftest(SSret);
- disp('The test value of Augmented Dickey-Fuller test for unit root');
- disp('------------------------------------------------------------');
- disp(adfval)
- kpssval = kpsstest(SSret);
- disp('The test value of kpsstes');
- disp('---------------------------');
- disp(kpssval)
- [h,pValue,stat,cValue] = archtest(SSret,1:5,0.01);
- disp('Engle test for residual heteroscedasticity');
- disp('---------------------------------------------');
- disp(h)
- disp('----------------------------------------------');
- disp(pValue);
- %% Bulding GARCH Model and fit the parameters
- spec = garchset('VarianceModel','GJR','R',1,'M',1,'P',1,'Q',1);
- spec = garchset(spec,'Display','off','Distribution','T');
- [coeff,errros,LLF,~,~] = garchfit(spec,markpound);
- [eFit,sFit] = garchinfer(coeff,markpound);
- spec11=garchset;
- spec11=garchset(spec11,'Display','off');
- [coeff1,erros1,LLF1,eFit1,sFit1]=garchfit(spec11,markpound);
- %% Monte carlo simulation and visulise the simulation result using
- horizon = 30;
- nPaths = 10000;
- strm = RandStream('mt19937ar','Seed',5489);
- RandStream.setDefaultStream(strm);
- [eSim,sSim,ySim] = garchsim(coeff,horizon,nPaths,[],[],[],eFit,sFit,markpound);
- Y=ret2tick(ySim);
- [eSim1,sSim1,ySim1]=garchsim(coeff1,horizon,nPaths,[],[],[],eFit1,sFit1,markpound);
- Y1=ret2tick(ySim1);
- % plot result
- figure
- subplot(2,1,1),plot(Y)
- subplot(2,1,2),plot(Y1)
- %% Garch simulation and garch predict
- NumPeriods=30;
- fprintf('Garchpred result: Sigma and Mena\n');
- [SigmaForecast,MeanForecast,sigmaTotal,meanRMSE] = ...
- garchpred(coeff,markpound,NumPeriods);
- disp('Sigma')
- disp(SigmaForecast)
- disp('Mean')
- disp(MeanForecast)
-
- %% Standardized residuel
- figure
- autocorr(markpound);
- % Compare Sigmas
- figure
- plot(SigmaForecast,'.-b')
- hold('on')
- grid('on')
- plot(sqrt(mean(sSim.^2,2)),'.r')
- title('Forecast of STD of Residuals')
- legend('forecast results','simulation results')
- xlabel('Forecast Period')
- ylabel('Standard Deviation')
- % Compare Returns
- figure
- plot(MeanForecast,'.-b')
- hold('on')
- grid('on')
- plot(mean(ySim,2),'.r')
- title('Forecast of Returns')
- legend('forecast results','simulation results',4)
- xlabel('Forecast Period')
- ylabel('Return')
- % Compare Standard Errors
- figure
- plot(meanRMSE,'.-b')
- hold('on')
- grid('on')
- plot(std(ySim'),'.r')
- title('Standard Error of Forecast of Returns')
- legend('forecast results','simulation results')
- xlabel('Forecast Period')
- ylabel('Standard Deviation')
- %% Hypothesis test: | lrationtest |
- % A likelihood ratio test is another way to compare the model which is
- % beest
- [H,pValue]=lratiotest(LLF,LLF1,1);
- fprintf('Result of the GARCH model compare using "lrationtest"\n');
- if H==0
- disp('The GARCH(1,1) model is suported at the 5% significant level')
- else
- disp('The GJR(1,1) model is suported at the 5% significant level')
- end
- %-----------------------------EOF------------------------------------------
复制代码
|
-
总评分: 经验 + 100
论坛币 + 10
学术水平 + 1
热心指数 + 1
信用等级 + 1
查看全部评分
|