I have problem with [Response,Lower,Upper] = irf(Mdl,Nu​mObs=50,Co​nfidence=0​.9);

2 次查看(过去 30 天)
The problem is that i want a number of observation of 50, but ifr(_) has default value of 20 Observation
I tried different solution without success
  1 个评论
FRANCESCOMARIA
FRANCESCOMARIA 2023-5-29
clear
clc
rmpath(genpath('/Users/francescosimeone/Desktop/applied macroeconomics/project/VAR-Toolbox-main/v3dot0/'))
returns = readmatrix('database_mpshocks_infoshocks.xlsx', 'Range', 'B:H', 'NumHeaderLines', 1);
Y= returns(:, [1, 3]);
Mdl = varm(2,3);
Mdl.SeriesNames = {'Transformed real GDP','Transformed real 3-mo T-bill rate'};
EstMdl = estimate(Mdl,Y);
[YIRF,h] = armairf(EstMdl.AR,{},'InnovCov',EstMdl.Covariance);
defGDPImp = ret2price(YIRF(:,2,1));
figure;
numobs = size(defGDPImp,1);
plot(0:numobs - 1,defGDPImp);
title('Impact of Shock to Interest Rate on Deflated GDP')
ylabel('Deflated GDP');
xlabel('Time');
rng(1); % For reproducibility
%[Response,Lower,Upper] = irf(EstMdl);
[Response, Lower, Upper] = irf(EstMdl, 'Confidence', 0.68);
irfshock2resp3 = Response(:,1,2);
IRFCIShock2Resp3 = [Lower(:,1,2) Upper(:,1,2)];
figure;
h1 = plot(0:19,irfshock2resp3);
hold on
h2 = plot(0:19,IRFCIShock2Resp3,"r--");
legend([h1 h2(1)],["IRF" "68% Confidence Interval"])
xlabel("Time Index");
ylabel("Response");
title("IRF of IB When Y Is Shocked");
grid on
hold off

请先登录,再进行评论。

回答(1 个)

Animesh
Animesh 2023-6-5
To change the number of observations in the IRFs, you can pass an additional argument to the irf function indicating the number of steps you want to forecast. By default, irf computes 20 steps, but you can set it to 50 by doing the following:
[Response, Lower, Upper] = irf(EstMdl, 'NumPeriods', 50, 'Confidence', 0.68);
You may refer to the following documentation for more information:

类别

Help CenterFile Exchange 中查找有关 Curve Fitting Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by