From 071ab1e14fb063025e891165a1afdd1f4ea50842 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Sat, 21 Mar 2020 12:06:24 +0100
Subject: [PATCH] imcforecast.m: fix faulty logic of warning

Steady state and time shift were missing
---
 matlab/imcforecast.m | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/matlab/imcforecast.m b/matlab/imcforecast.m
index e1fafcfa9b..0cf282b7b7 100644
--- a/matlab/imcforecast.m
+++ b/matlab/imcforecast.m
@@ -249,7 +249,7 @@ for b=1:options_cond_fcst.replic %conditional forecast using cL set to constrain
     [FORCS1(:,:,b), FORCS1_shocks(:,:,b)] = mcforecast3(cL,options_cond_fcst.periods,constrained_paths,shocks,FORCS1(:,:,b),T,R,mv, mu);
     FORCS1(:,:,b)=FORCS1(:,:,b)+trend; %add trend
 end
-if max(max(max(abs(bsxfun(@minus,FORCS1(constrained_vars,1:cL,:),constrained_paths)))))>1e-4
+if max(max(max(abs(bsxfun(@minus,FORCS1(constrained_vars,1+1:1+cL,:),trend(constrained_vars,1:cL)+constrained_paths)))))>1e-4
     fprintf('\nconditional_forecasts: controlling of variables was not successful.\n')
     fprintf('This can be due to numerical imprecision (e.g. explosive simulations)\n')
     fprintf('or because the instrument(s) do not allow controlling the variable(s).\n')
-- 
GitLab