翻云覆雨逐艳曲代码 方差分解——matlab-金融计量学家
发布时间: 2017-07-19 浏览: 350
代码 方差分解——matlab-金融计量学家
封面图片源自网络:
接着前面两期分析,今天介绍期限结构和收益率的方差分解代码:
function var_plot= var_term( Phi_DRAW拔冗出席,OMIGA_ff_DRAW画客网 ,HH)
%%%% HH means the step length for forecast %%%%%%%%%%
%%%%%% get the forecast variance decomposition %%%%%%%
%%% SIGMA_u=P*P'%%%%
%%% OMIG=inv(P)*U %%%%
%%% Y=MU+SUM_(THITA_i*OMIG_i) %%%%%%%%%%
A_1=Phi_DRAW';
SIGMA_u=OMIGA_ff_DRAW;%%% the convriance matrix for error term %%%
L=HH;
%%% FOR THE VAR(1) process the MA representation :
%%% Y=MU+SUM_(PHI_i*U_i) %%%%%%%%%%
PHI = zeros(6柯棣华 ,6,L);
PHI(:,:,1)=A_1;
for i=2:L
PHI(:藤井美菜 ,:,i)=PHI(:,:,i-1)*A_1;
end
P= cholcov(SIGMA_u); %%上三角,要变成下三角
P=P';
H=HH; %%% SET the step forcest %%%
MSEJ= zeros(6,6唐子义 ,6);
for i=1:6
MSEJ(:翻云覆雨逐艳曲 ,:,i)=P(:,i)*P(:,i)';
end
sum_mse = zeros(6末日食金者 ,6);
for i=1:6
for j=1:H-1
MSEJ(:,:,i)=MSEJ(:,:神偷艳贼,i)+PHI(:,:,j)*P(:,i)*P(:,i)'* PHI(:,:,j)';
end
MSE_single(:,i)=diag(MSEJ(:,:奥洛沃坎迪 ,i)); %% 每一个变量对提前H期的MSE的贡献
end %%是对角线上的元素
sum_mse = sum(MSE_single艋舺怎么读,2);
var_de=zeros(6,6);
for i = 1:6
var_de(:,i)=MSE_single(:,i)./ sum_mse ;
end
var_plot = var_de(1:3,4:6);
disp(['the ' num2str(H) 'step' ' ' 'Horizon']);
一下内容可忽略:
function var_plot= var_term( Phi_DRAW,OMIGA_ff_DRAW,HH)
%%%% HH means the step length for forecast %%%%%%%%%%
%%%%%% get the forecast variance decomposition %%%%%%%
%%% SIGMA_u=P*P'%%%%
%%% OMIG=inv(P)*U %%%%
%%% Y=MU+SUM_(THITA_i*OMIG_i) %%%%%%%%%%
A_1=Phi_DRAW';
SIGMA_u=OMIGA_ff_DRAW;%%% the convriance matrix for error term %%%
L=HH;
%%% FOR THE VAR(1) process the MA representation :
%%% Y=MU+SUM_(PHI_i*U_i) %%%%%%%%%%
PHI = zeros(6,6,L);
PHI(:,:,1)=A_1;
for i=2:L
PHI(:,:ca969,i)=PHI(:,:,i-1)*A_1;
end
P= cholcov(SIGMA_u); %%上三角,要变成下三角
P=P';
H=HH; %%% SET the step forcest %%%
MSEJ= zeros(6,6,6);
for i=1:6
MSEJ(:,:,i)=P(:,i)*P(:,i)';
end
sum_mse = zeros(6,6);
for i=1:6
for j=1:H-1
MSEJ(:,:,i)=MSEJ(:,:碧岭生态村,魏哲鸣 i)+PHI(:,:,j)*P(:屈服心裳 ,i)*P(:,i)'* PHI(:,:,j)';
end
MSE_single(:此情可念 ,i)=diag(MSEJ(:,:,i)); %% 每一个变量对提前H期的MSE的贡献
end %%是对角线上的元素
sum_mse = sum(MSE_single,2);
var_de=zeros(6,6);
for i = 1:6
var_de(:,i)=MSE_single(:,i)./ sum_mse ;
end
var_plot = var_de(1:3,4:6);
disp(['the ' num2str(H) 'step' ' ' 'Horizon']);
封面图片源自网络:
接着前面两期分析,今天介绍期限结构和收益率的方差分解代码:
function var_plot= var_term( Phi_DRAW拔冗出席,OMIGA_ff_DRAW画客网 ,HH)
%%%% HH means the step length for forecast %%%%%%%%%%
%%%%%% get the forecast variance decomposition %%%%%%%
%%% SIGMA_u=P*P'%%%%
%%% OMIG=inv(P)*U %%%%
%%% Y=MU+SUM_(THITA_i*OMIG_i) %%%%%%%%%%
A_1=Phi_DRAW';
SIGMA_u=OMIGA_ff_DRAW;%%% the convriance matrix for error term %%%
L=HH;
%%% FOR THE VAR(1) process the MA representation :
%%% Y=MU+SUM_(PHI_i*U_i) %%%%%%%%%%
PHI = zeros(6柯棣华 ,6,L);
PHI(:,:,1)=A_1;
for i=2:L
PHI(:藤井美菜 ,:,i)=PHI(:,:,i-1)*A_1;
end
P= cholcov(SIGMA_u); %%上三角,要变成下三角
P=P';
H=HH; %%% SET the step forcest %%%
MSEJ= zeros(6,6唐子义 ,6);
for i=1:6
MSEJ(:翻云覆雨逐艳曲 ,:,i)=P(:,i)*P(:,i)';
end
sum_mse = zeros(6末日食金者 ,6);
for i=1:6
for j=1:H-1
MSEJ(:,:,i)=MSEJ(:,:神偷艳贼,i)+PHI(:,:,j)*P(:,i)*P(:,i)'* PHI(:,:,j)';
end
MSE_single(:,i)=diag(MSEJ(:,:奥洛沃坎迪 ,i)); %% 每一个变量对提前H期的MSE的贡献
end %%是对角线上的元素
sum_mse = sum(MSE_single艋舺怎么读,2);
var_de=zeros(6,6);
for i = 1:6
var_de(:,i)=MSE_single(:,i)./ sum_mse ;
end
var_plot = var_de(1:3,4:6);
disp(['the ' num2str(H) 'step' ' ' 'Horizon']);
一下内容可忽略:
function var_plot= var_term( Phi_DRAW,OMIGA_ff_DRAW,HH)
%%%% HH means the step length for forecast %%%%%%%%%%
%%%%%% get the forecast variance decomposition %%%%%%%
%%% SIGMA_u=P*P'%%%%
%%% OMIG=inv(P)*U %%%%
%%% Y=MU+SUM_(THITA_i*OMIG_i) %%%%%%%%%%
A_1=Phi_DRAW';
SIGMA_u=OMIGA_ff_DRAW;%%% the convriance matrix for error term %%%
L=HH;
%%% FOR THE VAR(1) process the MA representation :
%%% Y=MU+SUM_(PHI_i*U_i) %%%%%%%%%%
PHI = zeros(6,6,L);
PHI(:,:,1)=A_1;
for i=2:L
PHI(:,:ca969,i)=PHI(:,:,i-1)*A_1;
end
P= cholcov(SIGMA_u); %%上三角,要变成下三角
P=P';
H=HH; %%% SET the step forcest %%%
MSEJ= zeros(6,6,6);
for i=1:6
MSEJ(:,:,i)=P(:,i)*P(:,i)';
end
sum_mse = zeros(6,6);
for i=1:6
for j=1:H-1
MSEJ(:,:,i)=MSEJ(:,:碧岭生态村,魏哲鸣 i)+PHI(:,:,j)*P(:屈服心裳 ,i)*P(:,i)'* PHI(:,:,j)';
end
MSE_single(:此情可念 ,i)=diag(MSEJ(:,:,i)); %% 每一个变量对提前H期的MSE的贡献
end %%是对角线上的元素
sum_mse = sum(MSE_single,2);
var_de=zeros(6,6);
for i = 1:6
var_de(:,i)=MSE_single(:,i)./ sum_mse ;
end
var_plot = var_de(1:3,4:6);
disp(['the ' num2str(H) 'step' ' ' 'Horizon']);
- 文章归档
-
- 2020年11月 (60)
- 2020年10月 (312)
- 2020年9月 (304)
- 2020年8月 (315)
- 2020年7月 (314)
- 2020年6月 (292)
- 2020年5月 (316)
- 2020年4月 (303)
- 2020年3月 (312)
- 2020年2月 (282)
- 2020年1月 (312)
- 2019年12月 (312)
- 2019年11月 (196)
- 2019年10月 (240)
- 2019年9月 (292)
- 2019年8月 (221)
- 2019年7月 (90)
- 2019年6月 (98)
- 2019年5月 (102)
- 2019年4月 (1607)
- 2019年3月 (2200)
- 2019年2月 (359)
- 2019年1月 (382)
- 2018年12月 (213)
- 2018年11月 (299)
- 2018年10月 (300)
- 2018年9月 (302)
- 2018年8月 (302)
- 2018年7月 (312)
- 2018年6月 (301)
- 2018年5月 (313)
- 2018年4月 (305)
- 2018年3月 (315)
- 2018年2月 (287)
- 2018年1月 (303)
- 2017年12月 (312)
- 2017年11月 (297)
- 2017年10月 (306)
- 2017年9月 (311)
- 2017年8月 (309)
- 2017年7月 (164)
- 2017年6月 (86)
- 2017年5月 (105)
- 2017年4月 (105)
- 2017年3月 (101)
- 2017年2月 (93)
- 2017年1月 (88)
- 2016年12月 (92)
- 2016年11月 (92)
- 2016年10月 (94)
- 2016年9月 (93)
- 2016年8月 (86)
- 2016年7月 (92)
- 2016年6月 (87)
- 2016年5月 (91)
- 2016年4月 (101)
- 2016年3月 (102)
- 2016年2月 (92)
- 2016年1月 (93)
- 2015年12月 (95)
- 2015年11月 (90)
- 2015年10月 (97)
- 2015年9月 (100)
- 2015年8月 (91)
- 2015年7月 (95)
- 2015年6月 (86)
- 2015年5月 (98)
- 2015年4月 (96)
- 2015年3月 (94)
- 2015年2月 (85)
- 2015年1月 (94)
- 2014年12月 (87)
- 2014年11月 (79)
- 2014年10月 (104)
- 2014年9月 (90)
- 2014年8月 (83)
- 2014年7月 (99)
- 2014年6月 (87)
- 2014年5月 (94)
- 2014年4月 (74)