From e8fd1f53db0256406a57196b483f473cb1b19dda Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Thu, 21 Oct 2021 09:44:49 +0200 Subject: [PATCH 1/2] evaluate_planner_objective.m: suppress output [skip CI] --- matlab/evaluate_planner_objective.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/evaluate_planner_objective.m b/matlab/evaluate_planner_objective.m index f59562ccd..cef2ebfc3 100644 --- a/matlab/evaluate_planner_objective.m +++ b/matlab/evaluate_planner_objective.m @@ -174,7 +174,7 @@ if options_.ramsey_policy Ey = oo_.mean; Eyhat = Ey - ys(dr.order_var(nstatic+(1:nspred))); - Eyhatyhat = oo_.var(:) + Eyhatyhat = oo_.var(:); Euu = M_.Sigma_e(:); EU = U + Uy*gy*Eyhat + 0.5*((Uyygygy + Uy*gyy)*Eyhatyhat + (Uyygugu + Uy*guu)*Euu + Uy*gss); From 048e059b683b47524c4c16fc48e7013f9b8fb4a4 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Thu, 21 Oct 2021 11:42:43 +0200 Subject: [PATCH 2/2] evaluate_planner_objective.m: add warning if NaN are encountered --- matlab/evaluate_planner_objective.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/matlab/evaluate_planner_objective.m b/matlab/evaluate_planner_objective.m index cef2ebfc3..6f4fb8959 100644 --- a/matlab/evaluate_planner_objective.m +++ b/matlab/evaluate_planner_objective.m @@ -168,6 +168,13 @@ if options_.ramsey_policy options_.noprint = 0; end + if any(isnan(oo_.mean)) || any(isnan(oo_.mean)) + fprintf('evaluate_planner_objective: encountered NaN moments in the endogenous variables often associated\n') + fprintf('evaluate_planner_objective: with either non-stationary variables or singularity due e.g. including\n') + fprintf('evaluate_planner_objective: the planner objective function (or additive parts of it) in the model.\n') + fprintf('evaluate_planner_objective: I will replace the NaN with a large number, but tread carefully,\n') + fprintf('evaluate_planner_objective: check your model, and watch out for strange results.\n') + end oo_.mean(isnan(oo_.mean)) = options_.huge_number; oo_.var(isnan(oo_.var)) = options_.huge_number;