From 4db598e91fec3f04839847ee0c76e25f6f3dbe11 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx,de>
Date: Thu, 30 Jan 2014 10:07:41 +0100
Subject: [PATCH] Filter out inconsistent specification of prefiltering when
 observation equation is not mean zero (cherry picked from commit
 d82252e805c007a99de353e49d1a3fa2f961d748)

---
 matlab/dynare_estimation_init.m | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m
index bddfbaa0c..a1b61eb3f 100644
--- a/matlab/dynare_estimation_init.m
+++ b/matlab/dynare_estimation_init.m
@@ -93,12 +93,6 @@ elseif isempty(options_.qz_criterium)
     options_.qz_criterium = 1+1e-6;
 end
 
-% If the data are prefiltered then there must not be constants in the
-% measurement equation of the DSGE model or in the DSGE-VAR model.
-if options_.prefilter == 1
-    options_.noconstant = 1;
-end
-
 % Set options related to filtered variables.
 if ~isequal(options_.filtered_vars,0) && isempty(options_.filter_step_ahead)
     options_.filter_step_ahead = 1;
@@ -478,7 +472,7 @@ dataset_ = initialize_dataset(options_.datafile,options_.varobs,options_.first_o
 
 options_.nobs = dataset_.info.ntobs;
 
-% setting noconstant option
+% setting steadystate_check_flag option
 if options_.diffuse_filter
     steadystate_check_flag = 0;
 else
@@ -498,4 +492,13 @@ if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)
     options_.noconstant = 1;
 else
     options_.noconstant = 0;
-end
\ No newline at end of file
+    % If the data are prefiltered then there must not be constants in the
+    % measurement equation of the DSGE model or in the DSGE-VAR model.
+    if options_.prefilter == 1
+        fprintf('\nestimation_init: You have specified the option "prefilter" to demean your data,\n')
+        fprintf('estimation_init: but your observation equations are not mean zero. Either change your observation\n')
+        fprintf('estimation_init: equation or drop the prefiltering.\n')
+        error('The option "prefilter" is inconsistent with the non-zero mean measurement equations in the model.')
+    end
+end
+
-- 
GitLab