Remove globals from forcst.m
parent
424050f380
commit
84ab37fd7a
|
@ -127,7 +127,7 @@ switch task
|
|||
end
|
||||
|
||||
if M.exo_det_nbr == 0
|
||||
[yf,int_width] = forcst(oo.dr,y0,horizon,var_list);
|
||||
[yf,int_width] = forcst(oo.dr,y0,horizon,var_list,M,oo,options);
|
||||
else
|
||||
exo_det_length = size(oo.exo_det_simul,1)-M.maximum_lag;
|
||||
if horizon > exo_det_length
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function [yf,int_width]=forcst(dr,y0,horizon,var_list)
|
||||
% function [yf,int_width]=forecst(dr,y0,horizon,var_list)
|
||||
function [yf,int_width]=forcst(dr,y0,horizon,var_list,M_,oo_,options_)
|
||||
% function [yf,int_width]=forecst(dr,y0,horizon,var_list,M_,oo_,options_)
|
||||
% computes mean forecast for a given value of the parameters
|
||||
% computes also confidence band for the forecast
|
||||
%
|
||||
|
@ -8,7 +8,10 @@ function [yf,int_width]=forcst(dr,y0,horizon,var_list)
|
|||
% y0: initial values
|
||||
% horizon: nbr of periods to forecast
|
||||
% var_list: list of variables (character matrix)
|
||||
%
|
||||
% M_: Dynare model structure
|
||||
% options_: Dynare options structure
|
||||
% oo_: Dynare results structure
|
||||
|
||||
% OUTPUTS:
|
||||
% yf: mean forecast
|
||||
% int_width: distance between upper bound and
|
||||
|
@ -34,8 +37,6 @@ function [yf,int_width]=forcst(dr,y0,horizon,var_list)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
global M_ oo_ options_
|
||||
|
||||
oo_=make_ex_(M_,options_,oo_);
|
||||
yf = simult_(y0,dr,zeros(horizon,M_.exo_nbr),1);
|
||||
nstatic = M_.nstatic;
|
||||
|
@ -63,17 +64,20 @@ end
|
|||
ghx1 = dr.ghx(inv_order_var(ivar),:);
|
||||
ghu1 = dr.ghu(inv_order_var(ivar),:);
|
||||
|
||||
sigma_u = B*M_.Sigma_e*B';
|
||||
%initialize recursion
|
||||
sigma_u = B*M_.Sigma_e*B';
|
||||
sigma_u1 = ghu1*M_.Sigma_e*ghu1';
|
||||
sigma_y = 0;
|
||||
sigma_y = 0; %no uncertainty about the states
|
||||
|
||||
var_yf=NaN(horizon,nvar); %initialize
|
||||
for i=1:horizon
|
||||
%map uncertainty about states into uncertainty about observables
|
||||
sigma_y1 = ghx1*sigma_y*ghx1'+sigma_u1;
|
||||
var_yf(i,:) = diag(sigma_y1)';
|
||||
if i == horizon
|
||||
break
|
||||
end
|
||||
%update uncertainty about states
|
||||
sigma_u = A*sigma_u*A';
|
||||
sigma_y = sigma_y+sigma_u;
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue