Compatibility fix for MATLAB R2014a when estimating with empty estim_params

The tests kalman_filter_smoother/fs2000_smoother_only.mod and
kalman_filter_smoother/fs2000_smoother_only_ns.mod would fail under MATLAB
R2014a.

They both run the estimation command without having declared an estim_params
block.

Their execution would fail in check_bounds_and_definiteness_estimation, at the
point where we check if initial values are below the lower bound.

The problem is that xparam1 would be of size 0×1, while bounds.lb would be
empty (0×0), and the comparison fails on older MATLABs.

The fix consists in ensuring that xparam1 remains of size 0×0 in that case.
time-shift
Sébastien Villemot 2021-01-27 15:41:24 +01:00
parent 0f19774b55
commit 0402c56ee7
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
3 changed files with 22 additions and 7 deletions

View File

@ -115,7 +115,7 @@ function [fval,info,exit_flag,DLIK,Hess,SteadyState,trend_coeff,Model,DynareOpti
%! @end deftypefn
%@eod:
% Copyright (C) 2004-2020 Dynare Team
% Copyright (C) 2004-2021 Dynare Team
%
% This file is part of Dynare.
%
@ -148,7 +148,12 @@ end
Hess = [];
% Ensure that xparam1 is a column vector.
xparam1 = xparam1(:);
% (Don't do the transformation if xparam1 is empty, otherwise it would become a
% 0×1 matrix, which create issues with older MATLABs when comparing with [] in
% check_bounds_and_definiteness_estimation)
if ~isempty(xparam1)
xparam1 = xparam1(:);
end
if DynareOptions.estimation_dll
[fval,exit_flag,SteadyState,trend_coeff,info,params,H,Q] ...

View File

@ -37,7 +37,7 @@ function [fval,info,exit_flag,grad,hess,SteadyState,trend_coeff,PHI_tilde,SIGMA_
% SPECIAL REQUIREMENTS
% None.
% Copyright (C) 2006-2018 Dynare Team
% Copyright (C) 2006-2021 Dynare Team
%
% This file is part of Dynare.
%
@ -69,7 +69,12 @@ prior = [];
trend_coeff=[];
% Ensure that xparam1 is a column vector.
xparam1 = xparam1(:);
% (Don't do the transformation if xparam1 is empty, otherwise it would become a
% 0×1 matrix, which create issues with older MATLABs when comparing with [] in
% check_bounds_and_definiteness_estimation)
if ~isempty(xparam1)
xparam1 = xparam1(:);
end
% Initialization of of the index for parameter dsge_prior_weight in Model.params.
if isempty(dsge_prior_weight_idx)
@ -317,4 +322,4 @@ if (nargout==11)
prior.ArtificialSampleSize = fix(dsge_prior_weight*NumberOfObservations);
prior.DF = prior.ArtificialSampleSize - NumberOfParameters - NumberOfObservedVariables;
prior.iGXX_star = iGXX;
end
end

View File

@ -26,7 +26,7 @@ function [fval,info,exit_flag,DLIK,Hess,ys,trend_coeff,Model,DynareOptions,Bayes
% - BayesInfo [struct] See INPUTS section.
% - DynareResults [struct] Updated DynareResults structure described in INPUTS section.
% Copyright (C) 2010-2019 Dynare Team
% Copyright (C) 2010-2021 Dynare Team
%
% This file is part of Dynare.
%
@ -52,7 +52,12 @@ DLIK = [];
Hess = [];
% Ensure that xparam1 is a column vector.
xparam1 = xparam1(:);
% (Don't do the transformation if xparam1 is empty, otherwise it would become a
% 0×1 matrix, which create issues with older MATLABs when comparing with [] in
% check_bounds_and_definiteness_estimation)
if ~isempty(xparam1)
xparam1 = xparam1(:);
end
% Issue an error if loglinear option is used.
if DynareOptions.loglinear