From 2c074d7cd272e10d69b8ec659db006bad44912e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Hermes=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Thu, 16 Jun 2016 11:16:23 +0200
Subject: [PATCH] Check that a prior is defined in prior CLI command

Behaviour consistent with the logic introduced in commit
64d01a806ed5d2aade3a3c038133cb1f688935bf.
---
 matlab/cli/prior.m | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/matlab/cli/prior.m b/matlab/cli/prior.m
index f25c4a9fa2..c5c25330e4 100644
--- a/matlab/cli/prior.m
+++ b/matlab/cli/prior.m
@@ -44,6 +44,24 @@ global options_ M_ estim_params_ bayestopt_ oo_
 
 donesomething = false;
 
+if ~isbayes(estim_params_)
+    warning('No prior detected!')
+    return
+end
+
+if (size(estim_params_.var_endo,1) || size(estim_params_.corrn,1))
+    % Prior over measurement errors are defined...
+   if ((isfield(options_,'varobs') && isempty(options_.varobs)) || ~isfield(options_,'varobs'))
+       % ... But the list of observed variabled is not yet defined.
+       warning('Prior detected on measurement erros, but no list of observed variables (varobs is missing)!')
+       return
+   end
+end
+
+% Fill or update bayestopt_ structure
+[xparam1,estim_params_,bayestopt_,lb,ub,M_] = set_prior(estim_params_,M_,options_);
+
+
 % Temporarly change qz_criterium option value
 changed_qz_criterium_flag  = 0;
 if isempty(options_.qz_criterium)
@@ -57,8 +75,6 @@ M_.dname = M_.fname;
 order = options_.order;
 options_.order = 1;
 
-[xparam1,estim_params_,bayestopt_,lb,ub,M_] = set_prior(estim_params_,M_,options_);
-
 if ismember('plot', varargin)
     plot_priors(bayestopt_,M_,estim_params_,options_)
     donesomething = true;
-- 
GitLab