From 0752d6a8e6e882e3a127bc74b9e21dd434ce9ea6 Mon Sep 17 00:00:00 2001 From: Marco Ratto <marco.ratto@jrc.ec.europa.eu> Date: Fri, 3 Feb 2017 09:15:26 +0100 Subject: [PATCH] Trap incompatible user define options in a more transparent way. Fixes #1016. --- matlab/dynare_sensitivity.m | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/matlab/dynare_sensitivity.m b/matlab/dynare_sensitivity.m index 0aad64e1c4..c0cffa94ac 100644 --- a/matlab/dynare_sensitivity.m +++ b/matlab/dynare_sensitivity.m @@ -31,6 +31,39 @@ fname_ = M_.fname; lgy_ = M_.endo_names; x0=[]; +% check user defined options +if isfield(options_gsa,'neighborhood_width') && options_gsa.neighborhood_width, + if isfield(options_gsa,'pprior') && options_gsa.pprior, + error('sensitivity:: neighborhood_width is incompatible with prior sampling') + end + if isfield(options_gsa,'ppost') && options_gsa.ppost, + error('sensitivity:: neighborhood_width is incompatible with posterior sampling') + end +end + +if isfield(options_gsa,'morris') && options_gsa.morris==1, + if isfield(options_gsa,'identification') && options_gsa.identification==0, +% options_gsa.redform=1; + end + if isfield(options_gsa,'ppost') && options_gsa.ppost, + error('sensitivity:: Morris is incompatible with posterior sampling') + elseif isfield(options_gsa,'pprior') && options_gsa.pprior==0, + if ~(isfield(options_gsa,'neighborhood_width') && options_gsa.neighborhood_width), + error('sensitivity:: Morris is incompatible with MC sampling with correlation matrix') + end + end + if isfield(options_gsa,'rmse') && options_gsa.rmse, + error('sensitivity:: Morris is incompatible with rmse analysis') + end + if (isfield(options_gsa,'alpha2_stab') && options_gsa.alpha2_stab<1) || ... + (isfield(options_gsa,'ksstat') && options_gsa.ksstat<1) || ... + (isfield(options_gsa,'pvalue_ks') && options_gsa.pvalue_ks) || ... + (isfield(options_gsa,'pvalue_corr') && options_gsa.pvalue_corr) + + error('sensitivity:: Morris is incompatible with Monte Carlo filtering') + end +end +% end check user defined options options_gsa = set_default_option(options_gsa,'datafile',[]); options_gsa = set_default_option(options_gsa,'rmse',0); options_gsa = set_default_option(options_gsa,'useautocorr',0); -- GitLab