diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m
index b7865f5661e9a4cdd99e9f1775c2676eff44eb72..e712e7e273b4756e6e3a9e3df661ad3d5252bbef 100644
--- a/matlab/dynare_estimation_init.m
+++ b/matlab/dynare_estimation_init.m
@@ -148,7 +148,7 @@ if ~isempty(estim_params_)
     [xparam1,estim_params_,bayestopt_,lb,ub,M_] = set_prior(estim_params_,M_,options_);
 end
 
-if ~all(bayestopt_.pshape~=0) || ~all(bayestopt_.pshape==0)
+if any(bayestopt_.pshape==0) && any(bayestopt_.pshape~=0)
     error('Estimation must be either fully ML or fully Bayesian. Maybe you forgot to specify a prior distribution.')
 end
 % Check if a _prior_restrictions.m file exists