2011-09-17 14:09:48 +02:00
|
|
|
function bounds = prior_bounds(bayestopt,options)
|
2011-09-14 23:40:23 +02:00
|
|
|
|
|
|
|
%@info:
|
|
|
|
%! @deftypefn {Function File} {@var{bounds} =} prior_bounds (@var{bayesopt},@var{option})
|
|
|
|
%! @anchor{prior_bounds}
|
|
|
|
%! @sp 1
|
2012-09-14 18:00:12 +02:00
|
|
|
%! Returns bounds for the prior densities. For each estimated parameter the lower and upper bounds
|
2011-09-14 23:40:23 +02:00
|
|
|
%! are such that the defined intervals contains a probability mass equal to 1-2*@var{option}.prior_trunc. The
|
|
|
|
%! default value for @var{option}.prior_trunc is 1e-10 (set in @ref{global_initialization}).
|
|
|
|
%! @sp 2
|
|
|
|
%! @strong{Inputs}
|
|
|
|
%! @sp 1
|
|
|
|
%! @table @ @var
|
|
|
|
%! @item bayestopt
|
|
|
|
%! Matlab's structure describing the prior distribution (initialized by @code{dynare}).
|
|
|
|
%! @item option
|
|
|
|
%! Matlab's structure describing the options (initialized by @code{dynare}).
|
|
|
|
%! @end table
|
|
|
|
%! @sp 2
|
|
|
|
%! @strong{Outputs}
|
|
|
|
%! @sp 1
|
|
|
|
%! @table @ @var
|
|
|
|
%! @item bounds
|
|
|
|
%! p*2 matrix of doubles, where p is the number of estimated parameters. The first and second columns report
|
|
|
|
%! respectively the lower and upper bounds.
|
|
|
|
%! @end table
|
|
|
|
%! @sp 2
|
|
|
|
%! @strong{This function is called by:}
|
|
|
|
%! @sp 1
|
|
|
|
%! @ref{get_prior_info}, @ref{dynare_estimation_1}, @ref{dynare_estimation_init}
|
|
|
|
%! @sp 2
|
|
|
|
%! @strong{This function calls:}
|
|
|
|
%! @sp 1
|
|
|
|
%! None.
|
|
|
|
%! @end deftypefn
|
|
|
|
%@eod:
|
|
|
|
|
|
|
|
|
2008-01-10 15:53:41 +01:00
|
|
|
% function bounds = prior_bounds(bayestopt)
|
2009-02-17 18:19:47 +01:00
|
|
|
% computes bounds for prior density.
|
2008-01-10 15:53:41 +01:00
|
|
|
%
|
|
|
|
% INPUTS
|
2009-02-17 18:19:47 +01:00
|
|
|
% bayestopt [structure] characterizing priors (shape, mean, p1..p4)
|
2008-01-10 15:53:41 +01:00
|
|
|
%
|
|
|
|
% OUTPUTS
|
2012-09-14 18:00:12 +02:00
|
|
|
% bounds [double] matrix specifying prior bounds (row= parameter, column=lower&upper bound)
|
2008-01-10 15:53:41 +01:00
|
|
|
%
|
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
|
|
|
|
2013-06-12 16:42:09 +02:00
|
|
|
% Copyright (C) 2003-2012 Dynare Team
|
2008-08-01 14:40:33 +02:00
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
|
|
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
2008-01-10 15:53:41 +01:00
|
|
|
|
2005-02-18 20:54:39 +01:00
|
|
|
pshape = bayestopt.pshape;
|
|
|
|
p3 = bayestopt.p3;
|
|
|
|
p4 = bayestopt.p4;
|
2009-04-06 16:38:37 +02:00
|
|
|
p6 = bayestopt.p6;
|
|
|
|
p7 = bayestopt.p7;
|
2011-09-14 23:40:23 +02:00
|
|
|
prior_trunc = options.prior_trunc;
|
2005-02-18 20:54:39 +01:00
|
|
|
|
2009-04-06 16:38:37 +02:00
|
|
|
bounds = zeros(length(p6),2);
|
2005-02-18 20:54:39 +01:00
|
|
|
|
2009-04-06 16:38:37 +02:00
|
|
|
for i=1:length(p6)
|
2009-12-16 18:17:34 +01:00
|
|
|
switch pshape(i)
|
|
|
|
case 1
|
|
|
|
if prior_trunc == 0
|
|
|
|
bounds(i,1) = p3(i);
|
|
|
|
bounds(i,2) = p4(i);
|
|
|
|
else
|
|
|
|
bounds(i,1) = betainv(prior_trunc,p6(i),p7(i))*(p4(i)-p3(i))+p3(i);
|
|
|
|
bounds(i,2) = betainv(1-prior_trunc,p6(i),p7(i))* ...
|
|
|
|
(p4(i)-p3(i))+p3(i);
|
|
|
|
end
|
|
|
|
case 2
|
|
|
|
if prior_trunc == 0
|
|
|
|
bounds(i,1) = p3(i);
|
|
|
|
bounds(i,2) = Inf;
|
|
|
|
else
|
2011-02-04 11:55:54 +01:00
|
|
|
try
|
|
|
|
bounds(i,1) = gaminv(prior_trunc,p6(i),p7(i))+p3(i);
|
|
|
|
bounds(i,2) = gaminv(1-prior_trunc,p6(i),p7(i))+p3(i);
|
|
|
|
catch
|
|
|
|
% Workaround for ticket #161
|
|
|
|
if exist('OCTAVE_VERSION')
|
|
|
|
error(['Due to a bug in Octave, you must choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape'])
|
|
|
|
else
|
|
|
|
rethrow(lasterror)
|
|
|
|
end
|
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
case 3
|
|
|
|
if prior_trunc == 0
|
|
|
|
bounds(i,1) = -Inf;
|
|
|
|
bounds(i,2) = Inf;
|
|
|
|
else
|
|
|
|
bounds(i,1) = norminv(prior_trunc,p6(i),p7(i));
|
|
|
|
bounds(i,2) = norminv(1-prior_trunc,p6(i),p7(i));
|
|
|
|
end
|
|
|
|
case 4
|
|
|
|
if prior_trunc == 0
|
|
|
|
bounds(i,1) = p3(i);
|
|
|
|
bounds(i,2) = Inf;
|
|
|
|
else
|
2011-02-04 11:55:54 +01:00
|
|
|
try
|
|
|
|
bounds(i,1) = 1/sqrt(gaminv(1-prior_trunc, p7(i)/2, 2/p6(i)))+p3(i);
|
|
|
|
bounds(i,2) = 1/sqrt(gaminv(prior_trunc, p7(i)/2, ...
|
|
|
|
2/p6(i)))+p3(i);
|
|
|
|
catch
|
|
|
|
% Workaround for ticket #161
|
|
|
|
if exist('OCTAVE_VERSION')
|
|
|
|
error(['Due to a bug in Octave, you must choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape'])
|
|
|
|
else
|
|
|
|
rethrow(lasterror)
|
|
|
|
end
|
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
case 5
|
|
|
|
if prior_trunc == 0
|
|
|
|
bounds(i,1) = p6(i);
|
|
|
|
bounds(i,2) = p7(i);
|
|
|
|
else
|
|
|
|
bounds(i,1) = p6(i)+(p7(i)-p6(i))*prior_trunc;
|
|
|
|
bounds(i,2) = p7(i)-(p7(i)-p6(i))*prior_trunc;
|
|
|
|
end
|
|
|
|
case 6
|
|
|
|
if prior_trunc == 0
|
|
|
|
bounds(i,1) = p3(i);
|
|
|
|
bounds(i,2) = Inf;
|
|
|
|
else
|
2011-02-04 11:55:54 +01:00
|
|
|
try
|
|
|
|
bounds(i,1) = 1/gaminv(1-prior_trunc, p7(i)/2, 2/p6(i))+p3(i);
|
|
|
|
bounds(i,2) = 1/gaminv(prior_trunc, p7(i)/2, 2/p6(i))+ p3(i);
|
|
|
|
catch
|
|
|
|
% Workaround for ticket #161
|
|
|
|
if exist('OCTAVE_VERSION')
|
|
|
|
error(['Due to a bug in Octave, you must choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape'])
|
|
|
|
else
|
|
|
|
rethrow(lasterror)
|
|
|
|
end
|
|
|
|
end
|
2009-12-16 18:17:34 +01:00
|
|
|
end
|
|
|
|
otherwise
|
|
|
|
error(sprintf('prior_bounds: unknown distribution shape (index %d, type %d)', i, pshape(i)));
|
|
|
|
end
|
2009-02-17 18:19:47 +01:00
|
|
|
end
|