From 2e79b42adbf51387d6d0b2a103bbb92106d2d15c Mon Sep 17 00:00:00 2001
From: Michel Juillard <michel.juillard@ens.fr>
Date: Fri, 2 Apr 2010 11:01:14 +0200
Subject: [PATCH] fix smoother bug for smoother functions that don't return PK
 or decomp

---
 matlab/dynare_estimation_1.m | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m
index de8ac28b77..ab909f444c 100644
--- a/matlab/dynare_estimation_1.m
+++ b/matlab/dynare_estimation_1.m
@@ -342,9 +342,16 @@ if options_.mode_compute == 0
         oo_.Smoother.variance = P;
         i_endo_nbr = 1:M_.endo_nbr;
         if options_.nk ~= 0
-            oo_.FilteredVariablesKStepAhead = aK(options_.filter_step_ahead,i_endo_nbr,:);
-            oo_.FilteredVariablesKStepAheadVariances = PK(options_.filter_step_ahead,i_endo_nbr,i_endo_nbr,:);
-            oo_.FilteredVariablesShockDecomposition = decomp(options_.filter_step_ahead,i_endo_nbr,:,:);
+            oo_.FilteredVariablesKStepAhead = ...
+                aK(options_.filter_step_ahead,i_endo_nbr,:);
+            if ~isempty(PK)
+                oo_.FilteredVariablesKStepAheadVariances = ...
+                    PK(options_.filter_step_ahead,i_endo_nbr,i_endo_nbr,:);
+            end
+            if ~isempty(decomp)
+                oo_.FilteredVariablesShockDecomposition = ...
+                    decomp(options_.filter_step_ahead,i_endo_nbr,:,:);
+            end
         end
         for i=1:M_.endo_nbr
             eval(['oo_.SmoothedVariables.' deblank(M_.endo_names(dr.order_var(i),:)) ' = atT(i,:)'';']);
@@ -1091,9 +1098,15 @@ if (~((any(bayestopt_.pshape > 0) & options_.mh_replic) | (any(bayestopt_.pshape
                                              i_endo_nbr,:);
         if isfield(options_,'kalman_algo')
             if options_.kalman_algo > 2
-                oo_.FilteredVariablesKStepAheadVariances = PK(options_.filter_step_ahead,i_endo_nbr,i_endo_nbr,:);
-                oo_.FilteredVariablesShockDecomposition = ...
-                    decomp(options_.filter_step_ahead,i_endo_nbr,:,:);
+                if ~isempty(PK)
+                    oo_.FilteredVariablesKStepAheadVariances = ...
+                        PK(options_.filter_step_ahead,i_endo_nbr,i_endo_nbr,:);
+                end
+                if ~isempty(decomp)
+                    oo_.FilteredVariablesShockDecomposition = ...
+                        decomp(options_.filter_step_ahead,i_endo_nbr,:,: ...
+                               );
+                end
             end
         end
     end
-- 
GitLab