solve bugs when there are lags of exogenous variables on more than one
period in deterministic models.time-shift
parent
eefa7bb70a
commit
127730d731
|
@ -51,6 +51,8 @@ else
|
|||
if ~isempty(ys0_)
|
||||
error('histval and endval cannot be used simultaneously')
|
||||
end
|
||||
oo_.endo_simul = [M_.endo_histval ...
|
||||
% the first NaNs take care of the case where there are lags > 1 on
|
||||
% exogenous variables
|
||||
oo_.endo_simul = [NaN(M_.endo_nbr,M_.maximum_lag-1) M_.endo_histval ...
|
||||
oo_.steady_state*ones(1,options_.periods+M_.maximum_lead)];
|
||||
end
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
function [residuals,JJacobian] = perfect_foresight_problem(y, dynamic_function, Y0, YT, ...
|
||||
exo_simul, params, steady_state, ...
|
||||
T, ny, i_cols, ...
|
||||
maximum_lag, T, ny, i_cols, ...
|
||||
i_cols_J1, i_cols_1, i_cols_T, ...
|
||||
i_cols_j,nnzJ)
|
||||
% function perfect_foresight_problem(x, model_dynamic, Y0, YT,exo_simul,
|
||||
% params, steady_state, periods, ny, i_cols,i_cols_J1, i_cols_1,
|
||||
% function [residuals,JJacobian] = perfect_foresight_problem(x, model_dynamic, Y0, YT,exo_simul,
|
||||
% params, steady_state, maximum_lag, periods, ny, i_cols,i_cols_J1, i_cols_1,
|
||||
% i_cols_T, i_cols_j, nnzA)
|
||||
% computes the residuals and th Jacobian matrix
|
||||
% for a perfect foresight problem over T periods.
|
||||
|
@ -19,7 +19,7 @@ function [residuals,JJacobian] = perfect_foresight_problem(y, dynamic_function,
|
|||
% SPECIAL REQUIREMENTS
|
||||
% None.
|
||||
|
||||
% Copyright (C) 1996-2014 Dynare Team
|
||||
% Copyright (C) 1996-2015 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -47,7 +47,7 @@ function [residuals,JJacobian] = perfect_foresight_problem(y, dynamic_function,
|
|||
i_rows = 1:ny;
|
||||
i_cols_J = i_cols;
|
||||
|
||||
for it = 2:(T+1)
|
||||
for it = maximum_lag+(1:T)
|
||||
if nargout == 1
|
||||
residuals(i_rows) = dynamic_function(YY(i_cols),exo_simul, params, ...
|
||||
steady_state,it);
|
||||
|
|
|
@ -56,7 +56,7 @@ if options_.debug
|
|||
end
|
||||
|
||||
initperiods = 1:M_.maximum_lag;
|
||||
lastperiods = (M_.maximum_endo_lag+options_.periods+1):(M_.maximum_endo_lag+options_.periods+M_.maximum_endo_lead);
|
||||
lastperiods = (M_.maximum_lag+options_.periods+1):(M_.maximum_lag+options_.periods+M_.maximum_lead);
|
||||
|
||||
|
||||
oo_ = simulation_core(options_, M_, oo_);
|
||||
|
@ -116,7 +116,7 @@ if ~oo_.deterministic_simulation.status && ~options_.no_homotopy
|
|||
if isequal(iteration,1)
|
||||
oo_.endo_simul(:,M_.maximum_lag+1:end-M_.maximum_lead) = endoinit(:,1:options_.periods);
|
||||
elseif path_with_nans || path_with_cplx
|
||||
oo_.endo_simul(:,M_.maximum_lag+1:end-M_.maximum_lead) = saved_endo_simul(:,1+M_.maximum_endo_lag:end-M_.maximum_endo_lead);
|
||||
oo_.endo_simul(:,M_.maximum_lag+1:end-M_.maximum_lead) = saved_endo_simul(:,1+M_.maximum_lag:end-M_.maximum_lead);
|
||||
end
|
||||
|
||||
saved_endo_simul = oo_.endo_simul;
|
||||
|
|
|
@ -82,7 +82,7 @@ else
|
|||
[y,info] = dynare_solve(@perfect_foresight_problem,z(:),options_, ...
|
||||
str2func([M_.fname '_dynamic']),y0,yT, ...
|
||||
oo_.exo_simul,M_.params,oo_.steady_state, ...
|
||||
options_.periods,M_.endo_nbr,i_cols, ...
|
||||
M_.maximum_lag,options_.periods,M_.endo_nbr,i_cols, ...
|
||||
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, ...
|
||||
M_.NNZDerivatives(1));
|
||||
if all(imag(y)<.1*options_.dynatol.f)
|
||||
|
@ -122,7 +122,7 @@ if nargout>1
|
|||
else
|
||||
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '_dynamic']), y0, yT, ...
|
||||
oo_.exo_simul,M_.params,oo_.steady_state, ...
|
||||
options_.periods,M_.endo_nbr,i_cols, ...
|
||||
M_.maximum_lag,options_.periods,M_.endo_nbr,i_cols, ...
|
||||
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, ...
|
||||
M_.NNZDerivatives(1));
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue