From 76c4bd04feb4ee4c5e7ddd98740c95ac2b39a20c Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Mon, 20 Mar 2017 17:30:41 +0100
Subject: [PATCH] Provide informative error message if non-stationary model is
 estimated using particle filter

Closes #1377

(cherry picked from commit efaa7e54136ffd48fb69e075ecacf9708a553d3b)
---
 matlab/initial_estimation_checks.m | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/matlab/initial_estimation_checks.m b/matlab/initial_estimation_checks.m
index 03f0eac05e..98bb6672d8 100644
--- a/matlab/initial_estimation_checks.m
+++ b/matlab/initial_estimation_checks.m
@@ -165,8 +165,15 @@ elseif imag(fval)
 end
 
 if info(1) > 0
+    if DynareOptions.order>1
+        [eigenvalues_] = check(Model,DynareOptions, DynareResults);
+        if any(abs(1-abs(eigenvalues_))<1e-10)
+            error('Your model has a unit root, but estimation at order>1 currently only supports stationary models')
+        end
+    else
     disp('Error in computing likelihood for initial parameter values')
     print_info(info, DynareOptions.noprint, DynareOptions)
+    end
 end
 
 if DynareOptions.prefilter==1
-- 
GitLab