From a5d3836e7c1ebbb468580f7c94e0acfd2fc9b452 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Wed, 23 Aug 2023 09:32:24 +0200
Subject: [PATCH] endogenous prior: fix logic of missing observations check

Message should only be displayed if there are missing observations

(cherry picked from commit a85a00bfcfa665a5d22195060726dd11e93302da)
---
 matlab/dynare_estimation_init.m | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m
index cccaada16c..1322e8ce5b 100644
--- a/matlab/dynare_estimation_init.m
+++ b/matlab/dynare_estimation_init.m
@@ -556,15 +556,17 @@ end
 if ~isempty(dataset_)
     options_.nobs = dataset_.nobs;
     if options_.endogenous_prior 
-        if dataset_info.missing.no_more_missing_observations<dataset_.nobs-10
-            fprintf('\ndynare_estimation_init: There are missing observations in the data.\n')
-            fprintf('dynare_estimation_init: I am computing the moments for the endogenous prior only\n')
-            fprintf('dynare_estimation_init: on the observations after the last missing one, i.e. %u.\n',dataset_info.missing.no_more_missing_observations)
-        else
-            fprintf('\ndynare_estimation_init: There are too many missing observations in the data.\n')        
-            fprintf('dynare_estimation_init: The endogenous_prior-option needs a consistent sample of \n')
-            fprintf('dynare_estimation_init: at least 10 full observations at the end.\n')
-            error('The endogenous_prior-option does not support your missing data.')
+        if ~isnan(dataset_info.missing.number_of_observations) && ~(dataset_info.missing.number_of_observations==0) %missing observations present
+            if dataset_info.missing.no_more_missing_observations<dataset_.nobs-10
+                fprintf('\ndynare_estimation_init: There are missing observations in the data.\n')
+                fprintf('dynare_estimation_init: I am computing the moments for the endogenous prior only\n')
+                fprintf('dynare_estimation_init: on the observations after the last missing one, i.e. %u.\n',dataset_info.missing.no_more_missing_observations)
+            else
+                fprintf('\ndynare_estimation_init: There are too many missing observations in the data.\n')
+                fprintf('dynare_estimation_init: The endogenous_prior-option needs a consistent sample of \n')
+                fprintf('dynare_estimation_init: at least 10 full observations at the end.\n')
+                error('The endogenous_prior-option does not support your missing data.')
+            end
         end
     end
 end
-- 
GitLab