From 49610d4db4f7209bbefdeb39dad8553e99d72a2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien.villemot@ens.fr>
Date: Mon, 11 Oct 2010 12:24:16 +0200
Subject: [PATCH] Fix bug in the output of stoch_simul: in the presence of
 non-stationary variables, and when selecting only a subset of variables for
 the output, the "NaN"s in the "mean" column where wrongly placed (cherry
 picked from commit 9d67555fc10c606021dbd30460a3adeb6c7330a3)

---
 matlab/disp_th_moments.m    | 4 +---
 matlab/th_autocovariances.m | 5 ++---
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/matlab/disp_th_moments.m b/matlab/disp_th_moments.m
index 64ca5de32c..b40c41f9bf 100644
--- a/matlab/disp_th_moments.m
+++ b/matlab/disp_th_moments.m
@@ -37,9 +37,7 @@ end
 [oo_.gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_,options_);
 m = dr.ys(ivar);
 non_stationary_vars = setdiff(1:length(ivar),stationary_vars);
-ivar1 = intersect(non_stationary_vars,ivar);
-m(ivar1) = NaN;
-
+m(non_stationary_vars) = NaN;
 
 i1 = find(abs(diag(oo_.gamma_y{1})) > 1e-12);
 s2 = diag(oo_.gamma_y{1});
diff --git a/matlab/th_autocovariances.m b/matlab/th_autocovariances.m
index 4da9ca22a8..fa18783c8f 100644
--- a/matlab/th_autocovariances.m
+++ b/matlab/th_autocovariances.m
@@ -19,13 +19,12 @@ function [Gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_,options_,node
 %                                      Gamma_y{nar+2}   [double]  Variance decomposition.  
 %                                      Gamma_y{nar+3}   [double]  Expectation of the endogenous variables associated with a second 
 %                                                                 order approximation.    
-%   stationary_vars   [integer]      Vector of indices of stationary
-%                                           variables in declaration order
+%   stationary_vars   [integer]      Vector of indices of stationary variables (as a subset of 1:length(ivar))
 %
 % SPECIAL REQUIREMENTS
 %   
 
-% Copyright (C) 2001-2009 Dynare Team
+% Copyright (C) 2001-2010 Dynare Team
 %
 % This file is part of Dynare.
 %
-- 
GitLab