From 622f8316255e91d0e2bdefe134bfcfeb06ee5ed0 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Tue, 26 Jul 2022 14:43:31 +0200
Subject: [PATCH] Inversion filter: disable unavailable smoother outputs

Related to https://git.dynare.org/Dynare/dynare/-/issues/1861
---
 matlab/dynare_estimation_init.m | 15 +++++++++++++++
 tests/occbin/filter/NKM.mod     |  4 ++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m
index cde28a7007..3b3fba2a24 100644
--- a/matlab/dynare_estimation_init.m
+++ b/matlab/dynare_estimation_init.m
@@ -699,4 +699,19 @@ if options_.occbin.likelihood.status && options_.occbin.likelihood.inversion_fil
             error('IVF-filter: an observable is mapped to a zero variance shock.')
         end
     end
+end
+
+if options_.occbin.smoother.status && options_.occbin.smoother.inversion_filter
+    if ~isempty(options_.nk)
+        fprintf('dynare_estimation_init: the inversion filter does not support filter_step_ahead. Disabling the option.\n')        
+        options_.nk=[];
+    end
+    if options_.filter_covariance
+        fprintf('dynare_estimation_init: the inversion filter does not support filter_covariance. Disabling the option.\n')        
+        options_.filter_covariance=false;
+    end
+    if options_.smoothed_state_uncertainty
+        fprintf('dynare_estimation_init: the inversion filter does not support smoothed_state_uncertainty. Disabling the option.\n')        
+        options_.smoothed_state_uncertainty=false;
+    end
 end
\ No newline at end of file
diff --git a/tests/occbin/filter/NKM.mod b/tests/occbin/filter/NKM.mod
index c8b17848ec..cd871d250a 100644
--- a/tests/occbin/filter/NKM.mod
+++ b/tests/occbin/filter/NKM.mod
@@ -317,7 +317,7 @@ varobs yg inom pi;
             datafile=dataobsfile2, mode_file=NKM_mh_mode_saved,
             mode_compute=0, nobs=120, first_obs=1,
             mh_replic=0, plot_priors=0, smoother,
-            nodisplay,consider_all_endogenous,heteroskedastic_filter);
+            nodisplay,consider_all_endogenous,heteroskedastic_filter,filter_step_ahead=[1],smoothed_state_uncertainty);
     
     oo0=oo_;
     // use inversion filter (note that IF provides smoother together with likelihood)
@@ -327,7 +327,7 @@ varobs yg inom pi;
             datafile=dataobsfile2, mode_file=NKM_mh_mode_saved,
             mode_compute=0, nobs=120, first_obs=1,
             mh_replic=0, plot_priors=0, smoother,
-            nodisplay, consider_all_endogenous,heteroskedastic_filter);
+            nodisplay, consider_all_endogenous,heteroskedastic_filter,filter_step_ahead=[1],smoothed_state_uncertainty);
             
     // show initial condition effect of IF
     figure,
-- 
GitLab