commit
a83570e1f4
|
@ -192,9 +192,9 @@ if ~oo_.deterministic_simulation.status && ~options_.no_homotopy
|
||||||
warning(warning_old_state);
|
warning(warning_old_state);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
%If simulated paths are complex, take real part and recompute the residuals to check whether this is actually a solution
|
||||||
if ~isreal(oo_.endo_simul(:)) % cannot happen with bytecode or the perfect_foresight_problem DLL
|
if ~isreal(oo_.endo_simul(:)) % cannot happen with bytecode or the perfect_foresight_problem DLL
|
||||||
ny = size(oo_.endo_simul, 1)
|
ny = size(oo_.endo_simul, 1);
|
||||||
if M_.maximum_lag > 0
|
if M_.maximum_lag > 0
|
||||||
y0 = real(oo_.endo_simul(:, M_.maximum_lag));
|
y0 = real(oo_.endo_simul(:, M_.maximum_lag));
|
||||||
else
|
else
|
||||||
|
@ -205,9 +205,20 @@ if ~isreal(oo_.endo_simul(:)) % cannot happen with bytecode or the perfect_fores
|
||||||
else
|
else
|
||||||
yT = NaN(ny, 1);
|
yT = NaN(ny, 1);
|
||||||
end
|
end
|
||||||
yy = real(oo_.endo_simul(:,M_.maximum_lag+(1:periods)));
|
if M_.maximum_lag~=0 && M_.maximum_lead~=0
|
||||||
|
yy = real(oo_.endo_simul(:,M_.maximum_lag+(1:periods)));
|
||||||
residuals = perfect_foresight_problem(yy(:), y0, yT, oo_.exo_simul, M_.params, oo_.steady_state, periods, M_, options_);
|
residuals = perfect_foresight_problem(yy(:), y0, yT, oo_.exo_simul, M_.params, oo_.steady_state, periods, M_, options_);
|
||||||
|
else
|
||||||
|
%The perfect_foresight_problem MEX only works on models with lags and leads
|
||||||
|
i_cols = find(M_.lead_lag_incidence');
|
||||||
|
residuals=NaN(ny,periods);
|
||||||
|
yy=real(oo_.endo_simul);
|
||||||
|
for it = (M_.maximum_lag+1):(M_.maximum_lag+periods)
|
||||||
|
residuals(:,it) = feval([M_.fname '.dynamic'],yy(i_cols), oo_.exo_simul, M_.params, oo_.steady_state, it);
|
||||||
|
i_cols = i_cols + ny;
|
||||||
|
end
|
||||||
|
residuals=residuals(:);
|
||||||
|
end
|
||||||
|
|
||||||
if max(abs(residuals))< options_.dynatol.f
|
if max(abs(residuals))< options_.dynatol.f
|
||||||
oo_.deterministic_simulation.status = true;
|
oo_.deterministic_simulation.status = true;
|
||||||
|
|
Loading…
Reference in New Issue