%% 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------------------------------------------

蒙特卡洛模拟与matlab,用MATLAB进行蒙特卡洛模拟?相关推荐

  1. 风电光伏的场景生成与消减-matlab代码 可利用蒙特卡洛模拟或者拉丁超立方生成光伏和风电出力场景

    风电光伏的场景生成与消减-matlab代码 可利用蒙特卡洛模拟或者拉丁超立方生成光伏和风电出力场景,并采用快速前推法或同步回代消除法进行削减,可以对生成场景数和削减数据进行修改,下图展示的为1000个 ...

  2. matlab mcmc工具箱,马尔科夫链蒙特卡洛模拟(MCMC)matlab工具箱

    马尔科夫链蒙特卡洛模拟(MCMC)matlab工具箱 matlab 2021-2-10 下载地址 https://www.codedown123.com/64660.html 马尔科夫链蒙特卡洛模拟( ...

  3. MATLAB代码:基于蒙特卡洛算法的电动汽车充电负荷预测 关键词:蒙特卡洛 电动汽车 充电负荷预测

    MATLAB代码:基于蒙特卡洛算法的电动汽车充电负荷预测 关键词:蒙特卡洛 电动汽车 充电负荷预测 仿真平台:MATLAB 主要内容:代码主要做的是电动汽车的充电负荷模拟预测,具体为:从影响电动汽车充 ...

  4. MATLAB代码:基于蒙特卡洛抽样的电动汽车充电负荷计算

    MATLAB代码:基于蒙特卡洛抽样的电动汽车充电负荷计算 关键词:电动汽车 蒙特卡洛模拟 抽样 充放电负荷 参考文档:<主动配电网多源协同运行优化研究_乔珊>第3.2节,完全复现 仿真平台 ...

  5. matlab 高斯函数_光学与matlab:高斯光的模拟

    光学与matlab:高斯光的模拟 高斯光束,自然何为高斯光束?百度了一下,如下所示,"通常情形,激光谐振腔发出的基模辐射场,其横截面的振幅分布遵守高斯函数,故称高斯光束."如果您对 ...

  6. FIR窗函数和IIR模拟、数字滤波器的MATLAB实现

    导语 本文采用MATLAB R2014b对x.mat信号进行了时域频域的分析,同时创建窗函数.IIR模拟巴特沃兹.IIR数字滤波器对x.mat信号进行滤波处理. 原始信号的时频域分析 我是把x.mat ...

  7. fib matlab,基于MATLAB的FIB制备三维原子探针样品过程的模拟方法与流程

    本发明属于FIB加工领域,尤其是涉及一种基于MATLAB的使用聚焦离子束(FIB)进行三维原子探针(APT)样品加工过程的模拟方法. 背景技术: APT可以定量的给出材料中不同元素原子在三维空间中的分 ...

  8. matlab中eacf函数,基于MATLAB的切比雪夫I型模拟低通滤波器设计

    基于MATLAB的切比雪夫I型模拟低通滤波器设计课程设计名称:数字信号处理课程设计专业班级 : 电信0604 学生姓 名 : 学号 : 20064300430 指导教师 : 课程设计时间:2009.6 ...

  9. BW型、CB I型、CB II型和椭圆模拟低通滤波器设计的Matlab仿真

    [题目要求] 设计满足下列指标的模拟低通滤波器. fp=1kHz, fs=3kHz, Ap<=1dB, As>=50dB. [分析]Matlab信号处理工具提供了常用的设计模拟低通滤波器的 ...

  10. matlab实例静电场,浅析Matlab模拟静电场三维图与恒定电流场模拟静电场

    浅析Matlab模拟静电场三维图与恒定电流场模拟静电场 浅析Matlab模拟静电场三维图 与恒定电流场模拟静电场 摘要:本文利用恒定电流场模拟静电场,通过寻找等势点的方法描绘出点电荷对的电力线和电势面 ...

最新文章

  1. 用父节点表示法表示一棵树
  2. cad中简单流程图制作_想要又快又好的画出世界级的流程图,这样牛掰的方法一定要知道...
  3. 创新设计模式:工厂模式
  4. HDU1328 ZOJ1240 IBM Minus One【水题】
  5. centos6 系统安装 system-config-kickstart 工具
  6. MixGo V1.0 发布,混合型高性能 Go 框架
  7. 【车间调度】基于matlab粒子群算法求解车间调度问题【含Matlab源码 013期】
  8. web前端常用开发工具排行:8款html开发工具推荐下载
  9. 四分之一波长传输线应用举例
  10. 对话腾讯金融云胡利明:金融机构数字化,迈进了“深水区”
  11. 网站木马检测_网站建立检测劫持,网站建立检测劫持如何操作,详细步骤
  12. html页面大于号,css中大于号()是什么意思?
  13. Chrome 解决 CRX HEADER INVALID 问题
  14. 华为 A800-9000 服务器 离线安装MindX DL 可视化环境+监控
  15. java中最基本的数据类型,java中的基本数据类型
  16. OCA/OCP(Oracle Certified Associate/Profesional)
  17. 一文搞懂│XSS攻击、SQL注入、CSRF攻击、DDOS攻击、DNS劫持
  18. 【基于RT-Thread+RA6M4的智能鱼缸系统设计之鱼我所欲也】
  19. gRPC是什么,怎么用
  20. windows文件隐藏

热门文章

  1. 【javaEE】网络编程套接字
  2. 让 GitHub 上这几个小游戏帮你找回童真
  3. itext操作word,设置页眉页脚,html转word
  4. 嵌入式开发笔记-STM32CudeIDE平台入门
  5. 什么是“可维护性”?
  6. flutter 可拖拽吸边的悬浮按钮,悬浮布局;
  7. Linux-CentOS安装phpStudy
  8. 通过编程求解炉石传说酒馆战旗最佳血量和攻击力分配方式
  9. item_search_img - 按图搜索淘宝商品(拍立淘)
  10. Spark 读取mysql表统计