Merge branch 'master' into rewrite-nonlinear-filters
commit
94776660ff
|
@ -51,6 +51,8 @@ else
|
||||||
if ~isempty(ys0_)
|
if ~isempty(ys0_)
|
||||||
error('histval and endval cannot be used simultaneously')
|
error('histval and endval cannot be used simultaneously')
|
||||||
end
|
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)];
|
oo_.steady_state*ones(1,options_.periods+M_.maximum_lead)];
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
function [residuals,JJacobian] = perfect_foresight_problem(y, dynamic_function, Y0, YT, ...
|
function [residuals,JJacobian] = perfect_foresight_problem(y, dynamic_function, Y0, YT, ...
|
||||||
exo_simul, params, steady_state, ...
|
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_J1, i_cols_1, i_cols_T, ...
|
||||||
i_cols_j,nnzJ)
|
i_cols_j,nnzJ)
|
||||||
% function perfect_foresight_problem(x, model_dynamic, Y0, YT,exo_simul,
|
% function [residuals,JJacobian] = perfect_foresight_problem(x, model_dynamic, Y0, YT,exo_simul,
|
||||||
% params, steady_state, periods, ny, i_cols,i_cols_J1, i_cols_1,
|
% params, steady_state, maximum_lag, periods, ny, i_cols,i_cols_J1, i_cols_1,
|
||||||
% i_cols_T, i_cols_j, nnzA)
|
% i_cols_T, i_cols_j, nnzA)
|
||||||
% computes the residuals and th Jacobian matrix
|
% computes the residuals and th Jacobian matrix
|
||||||
% for a perfect foresight problem over T periods.
|
% for a perfect foresight problem over T periods.
|
||||||
|
@ -19,7 +19,7 @@ function [residuals,JJacobian] = perfect_foresight_problem(y, dynamic_function,
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% None.
|
% None.
|
||||||
|
|
||||||
% Copyright (C) 1996-2014 Dynare Team
|
% Copyright (C) 1996-2015 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -47,7 +47,7 @@ function [residuals,JJacobian] = perfect_foresight_problem(y, dynamic_function,
|
||||||
i_rows = 1:ny;
|
i_rows = 1:ny;
|
||||||
i_cols_J = i_cols;
|
i_cols_J = i_cols;
|
||||||
|
|
||||||
for it = 2:(T+1)
|
for it = maximum_lag+(1:T)
|
||||||
if nargout == 1
|
if nargout == 1
|
||||||
residuals(i_rows) = dynamic_function(YY(i_cols),exo_simul, params, ...
|
residuals(i_rows) = dynamic_function(YY(i_cols),exo_simul, params, ...
|
||||||
steady_state,it);
|
steady_state,it);
|
||||||
|
|
|
@ -56,7 +56,7 @@ if options_.debug
|
||||||
end
|
end
|
||||||
|
|
||||||
initperiods = 1:M_.maximum_lag;
|
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_);
|
oo_ = simulation_core(options_, M_, oo_);
|
||||||
|
@ -116,7 +116,7 @@ if ~oo_.deterministic_simulation.status && ~options_.no_homotopy
|
||||||
if isequal(iteration,1)
|
if isequal(iteration,1)
|
||||||
oo_.endo_simul(:,M_.maximum_lag+1:end-M_.maximum_lead) = endoinit(:,1:options_.periods);
|
oo_.endo_simul(:,M_.maximum_lag+1:end-M_.maximum_lead) = endoinit(:,1:options_.periods);
|
||||||
elseif path_with_nans || path_with_cplx
|
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
|
end
|
||||||
|
|
||||||
saved_endo_simul = oo_.endo_simul;
|
saved_endo_simul = oo_.endo_simul;
|
||||||
|
|
|
@ -82,7 +82,7 @@ else
|
||||||
[y,info] = dynare_solve(@perfect_foresight_problem,z(:),options_, ...
|
[y,info] = dynare_solve(@perfect_foresight_problem,z(:),options_, ...
|
||||||
str2func([M_.fname '_dynamic']),y0,yT, ...
|
str2func([M_.fname '_dynamic']),y0,yT, ...
|
||||||
oo_.exo_simul,M_.params,oo_.steady_state, ...
|
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, ...
|
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, ...
|
||||||
M_.NNZDerivatives(1));
|
M_.NNZDerivatives(1));
|
||||||
if all(imag(y)<.1*options_.dynatol.f)
|
if all(imag(y)<.1*options_.dynatol.f)
|
||||||
|
@ -122,7 +122,7 @@ if nargout>1
|
||||||
else
|
else
|
||||||
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '_dynamic']), y0, yT, ...
|
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '_dynamic']), y0, yT, ...
|
||||||
oo_.exo_simul,M_.params,oo_.steady_state, ...
|
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, ...
|
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, ...
|
||||||
M_.NNZDerivatives(1));
|
M_.NNZDerivatives(1));
|
||||||
end
|
end
|
||||||
|
|
|
@ -125,7 +125,7 @@ for iter = 1:options_.simul.maxit
|
||||||
dr = max(abs(d1));
|
dr = max(abs(d1));
|
||||||
if dr<azero
|
if dr<azero
|
||||||
vperiods(iter) = it;
|
vperiods(iter) = it;
|
||||||
periods = it-maximum_lag;
|
periods = it-maximum_lag+1;
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue