Verified Commit 2ba9a8e1 authored by Johannes Pfeifer 's avatar Johannes Pfeifer Committed by Stéphane Adjemian
Browse files

Prevent inconsistent specification in estim_params-block

Also documents the behavior
parent 1880a34d
......@@ -5189,6 +5189,12 @@ Note that @var{INITIAL_VALUE}, @var{LOWER_BOUND}, @var{UPPER_BOUND},
can be empty, in which Dynare will select a default value depending on
the context and the prior shape.
 
In case of the uniform distribution, it can be specified either by providing an
upper and a lower bound using @var{PRIOR_3RD_PARAMETER} and @var{PRIOR_4TH_PARAMETER}
or via mean and standard deviation using @var{PRIOR_MEAN}, @var{PRIOR_STANDARD_ERROR}.
The other two will automatically be filled out. Note that providing both sets
of hyperparameters will yield an error message.
As one uses options more towards the end of the list, all previous
options must be filled: for example, if you want to specify
@var{SCALE_PARAMETER}, you must specify @var{PRIOR_3RD_PARAMETER} and
......
......@@ -226,13 +226,24 @@ end
% uniform distribution
k = find(bayestopt_.pshape == 5);
problem_parameters='';
for i=1:length(k)
[bayestopt_.p1(k(i)),bayestopt_.p2(k(i)),bayestopt_.p6(k(i)),bayestopt_.p7(k(i))] = ...
[bayestopt_.p1(k(i)),bayestopt_.p2(k(i)),bayestopt_.p6(k(i)),bayestopt_.p7(k(i)),error_indicator] = ...
uniform_specification(bayestopt_.p1(k(i)),bayestopt_.p2(k(i)),bayestopt_.p3(k(i)),bayestopt_.p4(k(i)));
if error_indicator
if isempty(problem_parameters)
problem_parameters=[bayestopt_.name{k(i)}];
else
problem_parameters=[problem_parameters ', ' bayestopt_.name{k(i)}];
end
end
bayestopt_.p3(k(i)) = bayestopt_.p6(k(i)) ;
bayestopt_.p4(k(i)) = bayestopt_.p7(k(i)) ;
bayestopt_.p5(k(i)) = NaN ;
end
if ~isempty(problem_parameters)
error(['uniform_specification: You defined lower and upper bounds for parameter ', problem_parameters, '. In this case, you need to leave mean and standard deviation empty.'])
end
% inverse gamma distribution (type 2)
k = find(bayestopt_.pshape == 6);
......
function [m,s,p6,p7] = uniform_specification(m,s,p3,p4)
function [m,s,p6,p7,error_indicator] = uniform_specification(m,s,p3,p4)
% Specification of the uniform density function parameters
%
% INPUTS
......@@ -10,8 +10,9 @@ function [m,s,p6,p7] = uniform_specification(m,s,p3,p4)
% OUTPUTS
% m: mean
% s: standard deviation
% p1: lower bound
% p2: upper bound
% p6: lower bound
% p7: upper bound
% error_indicator: whether inconsistent prior specification was used
%
% SPECIAL REQUIREMENTS
% none
......@@ -32,13 +33,17 @@ function [m,s,p6,p7] = uniform_specification(m,s,p3,p4)
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
error_indicator=0;
if ~(isnan(p3) || isnan(p4))
p6 = p3;
p7 = p4;
if ~isnan(m) || ~isnan(s)
error_indicator=1;
end
m = (p3+p4)/2;
s = (p4-p3)/(sqrt(12));
else
p6 = m-s*sqrt(3);
p7 = m+s*sqrt(3);
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment