correction exo_det
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@447 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
b14188d039
commit
bc45372bbb
|
@ -1,13 +1,16 @@
|
||||||
% Copyright (C) 2001 Michel Juillard
|
% Copyright (C) 2001 Michel Juillard
|
||||||
%
|
%
|
||||||
function make_ex_
|
function make_ex_
|
||||||
global M_ options_ oo_ ex0_
|
global M_ options_ oo_ ex0_ ex_det0_
|
||||||
|
|
||||||
options_ = set_default_option(options_,'periods',0);
|
options_ = set_default_option(options_,'periods',0);
|
||||||
|
|
||||||
if isempty(oo_.exo_steady_state)
|
if isempty(oo_.exo_steady_state)
|
||||||
oo_.exo_steady_state = zeros(M_.exo_nbr,1);
|
oo_.exo_steady_state = zeros(M_.exo_nbr,1);
|
||||||
end
|
end
|
||||||
|
if M_.exo_det_nbr > 1 & isempty(oo_.exo_det_steadystate)
|
||||||
|
oo_.exo_det_steadystate = zeros(M_.exo_det_nbr,1);
|
||||||
|
end
|
||||||
if isempty(oo_.exo_simul)
|
if isempty(oo_.exo_simul)
|
||||||
if isempty(ex0_)
|
if isempty(ex0_)
|
||||||
oo_.exo_simul = [ones(M_.maximum_lag+options_.periods+M_.maximum_lead,1)*oo_.exo_steady_state'];
|
oo_.exo_simul = [ones(M_.maximum_lag+options_.periods+M_.maximum_lead,1)*oo_.exo_steady_state'];
|
||||||
|
@ -30,5 +33,29 @@ function make_ex_
|
||||||
1),1)*oo_.exo_steady_state'];
|
1),1)*oo_.exo_steady_state'];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if M_.exo_det_nbr > 0
|
||||||
|
if isempty(oo_.exo_det_simul)
|
||||||
|
if isempty(ex_det0_)
|
||||||
|
oo_.exo_det_simul = [ones(ykmin_+options_.periods+ykmax_,1)*M_.exo_det_steadystate'];
|
||||||
|
else
|
||||||
|
oo_.exo_det_simul = [ones(ykmin_,1)*ex_det0_';ones(options_.periods+ykmax_,1)*M_.exo_det_steadystate'];
|
||||||
|
end
|
||||||
|
elseif size(oo_.exo_det_simul,2) < length(M_.exo_det_steadystate)
|
||||||
|
k = size(oo_.exo_det_simul,2)+1:length(M_.exo_det_steadystate);
|
||||||
|
if isempty(ex_det0_)
|
||||||
|
oo_.exo_det_simul = [oo_.exo_det_simul ones(ykmin_+size(oo_.exo_det_simul,1)+ykmax_,1)*M_.exo_det_steadystate(k)'];
|
||||||
|
else
|
||||||
|
oo_.exo_det_simul = [oo_.exo_det_simul [ones(ykmin_,1)*ex_det0_(k)'; ones(size(oo_.exo_det_simul,1)-ykmin_+ykmax_, ...
|
||||||
|
1)*M_.exo_det_steadystate(k)']];
|
||||||
|
end
|
||||||
|
elseif size(oo_.exo_det_simul,1) < ykmin_+ykmax_+options_.periods
|
||||||
|
if isempty(ex_det0_)
|
||||||
|
oo_.exo_det_simul = [oo_.exo_det_simul; ones(ykmin_+options_.periods+ykmax_-size(oo_.exo_det_simul,1),1)*M_.exo_det_steadystate'];
|
||||||
|
else
|
||||||
|
oo_.exo_det_simul = [ones(ykmin_,1)*ex_det0_'; oo_.exo_det_simul; ones(options_.periods+ykmax_-size(oo_.exo_det_simul, ...
|
||||||
|
1),1)*M_.exo_det_steadystate'];
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,60 +1,66 @@
|
||||||
% Copyright (C) 2001 Michel Juillard
|
% Copyright (C) 2001 Michel Juillard
|
||||||
%
|
%
|
||||||
function dr=resol(ys,algo,linear,iorder)
|
function [dr,info]=resol(ys,check_flag)
|
||||||
|
|
||||||
global M_ options_ oo_
|
global M_ options_ oo_
|
||||||
global it_ means_ stderrs_
|
% info: same as dr1
|
||||||
|
global it_
|
||||||
|
% plus:
|
||||||
|
% 11 .... same as dr1 for dr_algo = 2
|
||||||
|
% 20: can't find steady state info(2) contains sum of sqare residuals
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if linear == 1
|
options_ = set_default_option(options_,'olr',0);
|
||||||
iorder =1;
|
info = 0;
|
||||||
end
|
|
||||||
|
|
||||||
xlen = M_.maximum_lead + M_.maximum_lag + 1;
|
|
||||||
klen = M_.maximum_lag + M_.maximum_lead + 1;
|
|
||||||
iyv = M_.lead_lag_incidence';
|
|
||||||
iyv = iyv(:);
|
|
||||||
iyr0 = find(iyv) ;
|
|
||||||
it_ = M_.maximum_lag + 1 ;
|
it_ = M_.maximum_lag + 1 ;
|
||||||
|
|
||||||
if M_.exo_nbr == 0
|
if M_.exo_nbr == 0
|
||||||
oo_.exo_steady_state = [] ;
|
oo_.exo_steady_state = [] ;
|
||||||
end
|
end
|
||||||
|
|
||||||
if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
|
|
||||||
error ('RESOL: Error in model specification: some variables don"t appear as current') ;
|
|
||||||
end
|
|
||||||
|
|
||||||
%if xlen > 1
|
|
||||||
% error (['RESOL: stochastic exogenous variables must appear only at the' ...
|
|
||||||
% ' current period. Use additional endogenous variables']) ;
|
|
||||||
%end
|
|
||||||
|
|
||||||
|
|
||||||
% check if ys is steady state
|
% check if ys is steady state
|
||||||
tempex = oo_.exo_simul;
|
tempex = oo_.exo_simul;
|
||||||
oo_.exo_simul = repmat(oo_.exo_steady_state',options_.periods + M_.maximum_lag + M_.maximum_lead,1);
|
oo_.exo_simul = repmat(oo_.exo_steady_state',M_.maximum_lag+M_.maximum_lead+1,1);
|
||||||
fh = str2func([M_.fname '_static']);
|
if M_.exo_det_nbr > 0
|
||||||
if max(abs(feval(fh,ys,oo_.exo_simul))) > options_.dynatol
|
tempexdet = oo_.exo_det_simul;
|
||||||
|
oo_.exo_det_simul = ones(M_.maximum_lag+1,1)*oo_.exo_steady_statedet_';
|
||||||
|
end
|
||||||
|
fh = str2func([M_.fname '_fff']);
|
||||||
|
if max(abs(feval(fh,ys))) > dynatol_ & options_.olr == 0
|
||||||
if exist([M_.fname '_steadystate'])
|
if exist([M_.fname '_steadystate'])
|
||||||
[dr.ys,check] = feval([M_.fname '_steadystate'],ys,oo_.exo_simul);
|
[dr.ys,check1] = feval([M_.fname '_steadystate'],ys);
|
||||||
else
|
else
|
||||||
[dr.ys, check] = dynare_solve([M_.fname '_static'],ys,oo_.exo_simul);
|
[dr.ys,check1] = dynare_solve([M_.fname '_fff'],ys);
|
||||||
end
|
end
|
||||||
if check
|
if check1
|
||||||
error('RESOL: convergence problem in DYNARE_SOLVE')
|
info(1) = 20;
|
||||||
|
resid = feval(fh,ys);
|
||||||
|
info(2) = resid'*resid; % penalty...
|
||||||
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
dr.ys = ys;
|
dr.ys = ys;
|
||||||
end
|
end
|
||||||
|
|
||||||
dr.fbias = zeros(M_.endo_nbr,1);
|
dr.fbias = zeros(M_.endo_nbr,1);
|
||||||
dr = dr1(iorder,dr,0);
|
[dr,info] = dr1(dr,check_flag);
|
||||||
|
|
||||||
if algo == 1 & iorder > 1
|
if info(1)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if options_.dr_algo == 1 & options_.order > 1
|
||||||
dr.ys = dynare_solve('dr2',ys,dr);
|
dr.ys = dynare_solve('dr2',ys,dr);
|
||||||
dr.fbias = 2*feval([M_.fname '_static'],dr.ys,oo_.exo_simul);
|
dr.fbias = 2*feval([M_.fname '_fff'],dr.ys);
|
||||||
dr = dr1(iorder,dr,0);
|
[dr, info1] = dr1(dr,check_flag);
|
||||||
|
if info1(1)
|
||||||
|
info(1) = info(1)+10;
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if M_.exo_det_nbr > 0
|
||||||
|
oo_.exo_det_simul = tempexdet;
|
||||||
end
|
end
|
||||||
oo_.exo_simul = tempex;
|
oo_.exo_simul = tempex;
|
||||||
tempex = [];
|
tempex = [];
|
||||||
|
@ -62,7 +68,4 @@ tempex = [];
|
||||||
% 01/01/2003 MJ added dr_algo == 1
|
% 01/01/2003 MJ added dr_algo == 1
|
||||||
% 08/24/2001 MJ uses Schmitt-Grohe and Uribe (2001) constant correction
|
% 08/24/2001 MJ uses Schmitt-Grohe and Uribe (2001) constant correction
|
||||||
% in dr.ghs2
|
% in dr.ghs2
|
||||||
% 05/26/2003 MJ added temporary values for oo_.exo_simul
|
% 05/26/2003 MJ added temporary values for oo_.exo_simul
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue