Corrections related to the impulse response functions.
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@473 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
71df1c6aa1
commit
0393e5e187
16
matlab/irf.m
16
matlab/irf.m
|
@ -2,19 +2,16 @@ function y_=irf(dr, e1, long_, drop_, replic, iorder)
|
|||
global M_ oo_ options_
|
||||
|
||||
old_iter = options_.periods;
|
||||
options_.periods = long_;
|
||||
|
||||
options_.periods = long_+1;
|
||||
temps = repmat(dr.ys,1,M_.maximum_lag);
|
||||
|
||||
y_ = 0;
|
||||
|
||||
if iorder == 1
|
||||
options_.periods = long_;
|
||||
y1_ = repmat(dr.ys,1,options_.periods);
|
||||
y1_ = repmat(dr.ys,1,long_);
|
||||
ex2_ = zeros(options_.periods,M_.exo_nbr);
|
||||
ex2_(1,:) = e1';
|
||||
y2_ = simult_(repmat(dr.ys,1,M_.maximum_lag),dr,ex2_,iorder);
|
||||
y_ = y2_(:,M_.maximum_lag:end)-y1_;% <-- y2_(:,M_.maximum_lag+1:end)-y1_
|
||||
|
||||
y_ = y2_(:,M_.maximum_lag+1:end)-y1_;
|
||||
else
|
||||
% eliminate shocks with 0 variance
|
||||
i_exo_var = setdiff([1:M_.exo_nbr],find(diag(M_.Sigma_e) == 0 ));
|
||||
|
@ -22,7 +19,6 @@ function y_=irf(dr, e1, long_, drop_, replic, iorder)
|
|||
ex1_ = zeros(long_+drop_+M_.maximum_lag,M_.exo_nbr);
|
||||
ex2_ = ex1_;
|
||||
chol_S = chol(M_.Sigma_e(i_exo_var,i_exo_var));
|
||||
|
||||
for j = 1: replic
|
||||
randn('seed',j);
|
||||
ex1_(:,i_exo_var) = randn(long_+drop_+M_.maximum_lag,nxs)*chol_S;
|
||||
|
@ -36,6 +32,4 @@ function y_=irf(dr, e1, long_, drop_, replic, iorder)
|
|||
end
|
||||
options_.periods = old_iter;
|
||||
% 01/18/02 MJ corrected for many lags
|
||||
% 03/11/22 MJ input is now entire shock vector e1 (for orthogonalized IRFs)
|
||||
|
||||
|
||||
% 03/11/22 MJ input is now entire shock vector e1 (for orthogonalized IRFs)
|
|
@ -23,22 +23,21 @@ global M_ options_ it_
|
|||
[junk, k5] = sort(dr.order_var(o1:o2));
|
||||
[junk, k6] = sort(dr.order_var(o3:end));
|
||||
end
|
||||
|
||||
if iorder == 1
|
||||
|
||||
if iorder == 1
|
||||
for i = M_.maximum_lag+1: iter+M_.maximum_lag
|
||||
tempx1 = y_(dr.order_var,k1);
|
||||
tempx2 = tempx1-repmat(dr.ys(dr.order_var),1,M_.maximum_lag);
|
||||
tempx = tempx2(k2);
|
||||
if options_.simul_algo == 0
|
||||
y_(dr.order_var,i) = dr.ys(dr.order_var)+dr.ghx*tempx+dr.ghu* ...
|
||||
ex_(i+M_.maximum_lag-M_.maximum_lag,:)';
|
||||
ex_(i-M_.maximum_lag,:)';
|
||||
elseif options_.simul_algo == 1
|
||||
it_ = i;
|
||||
m = dr.ys(dr.order_var);
|
||||
[y_(:,i), check] = dynare_solve('ff_simul1',y_(:,i-1),tempx1(k3), ...
|
||||
m(o3:end),tempx(k4),o1,o2,o3,k6);
|
||||
end
|
||||
|
||||
k1 = k1+1;
|
||||
end
|
||||
elseif iorder == 2
|
||||
|
@ -46,7 +45,7 @@ global M_ options_ it_
|
|||
tempx1 = y_(dr.order_var,k1);
|
||||
tempx2 = tempx1-repmat(dr.ys(dr.order_var),1,M_.maximum_lag);
|
||||
tempx = tempx2(k2);
|
||||
tempu = ex_(i+M_.maximum_lag-M_.maximum_lag,:)';
|
||||
tempu = ex_(i-M_.maximum_lag,:)';
|
||||
tempuu = kron(tempu,tempu);
|
||||
if options_.simul_algo == 0
|
||||
tempxx = kron(tempx,tempx);
|
||||
|
|
|
@ -150,7 +150,6 @@ global it_
|
|||
end
|
||||
end
|
||||
number_of_plots_to_draw = size(irfs,1);
|
||||
number_of_plots_to_draw
|
||||
[nbplt,nr,nc,lr,lc,nstar] = pltorg(number_of_plots_to_draw);
|
||||
if nbplt == 0
|
||||
elseif nbplt == 1
|
||||
|
@ -298,4 +297,4 @@ global it_
|
|||
% 11/22/03 MJ replaced IRFs by orthogonalized IRFs
|
||||
% 08/30/04 SA The maximum number of plots is not constrained for the IRFs and
|
||||
% all the plots are saved in *.eps, *.pdf and *.fig files (added
|
||||
% 09/03/04 SA Tex output for IRFs added
|
||||
% 09/03/04 SA Tex output for IRFs added
|
Loading…
Reference in New Issue