Problem calculating a FEVD
Show older comments
Hey guys
I'm kind of struggling with calculating the FEVDs of two shocks (GDP shock and monetary policy shock) to the two variables up to horizon h = 20.
Here is my code:
cholesky=chol(sigma,'lower')
cholesky_inv = inv(cholesky);
I=eye(2);
% First compute the 0th until 20th power of B%
coef=B(2:3,:);
coef_power=zeros(2,2,21);
for n=1:21
coef_power(:,:,n)=coef^(n-1);
end
% First compute MSE(h,y) en MSE(r,y)
MSE= zeros(2,2,21)
MSE(:,:,1)= coef*cholesky_inv * I * cholesky_inv'*coef'
for n=1:21
MSE(:,:,n)=coef_power(:,:,n)*cholesky_inv * I * cholesky_inv' * coef_power(:,:,n)'
end
MSE_hy= MSE(1,1,:);
MSE_ry= MSE(2,2,:);
% compute MSE(h,y/Ey,t = 0)
cholesky2=chol(sigma,'upper');
cholesky2_inv=inv(cholesky2);
MSE2= zeros(2,2,21)
MSE2(:,:,1)= coef*cholesky_inv * I * cholesky_inv'*coef'
for n=1:21
MSE2(:,:,n)=coef_power(:,:,n)*cholesky2_inv * I * cholesky2_inv' * coef_power(:,:,n)'
end
MSE2_hy= MSE2(1,1,:);
MSE2_ry= MSE2(2,2,:);
FEVD_y = MSE2_hy./MSE_hy
FEVD_r = MSE2_ry./MSE_ry
Can anyone help me out?
Cheers
Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!