


@info:
! @deftypefn {Function File} {@var{bounds} =} prior_bounds (@var{bayesopt},@var{option})
! @anchor{prior_bounds}
! @sp 1
! Returns bounds for the prior densities. For each estimated parameter the upper and lower bounds
! 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:

0001 function bounds = prior_bounds(bayestopt,options) 0002 0003 %@info: 0004 %! @deftypefn {Function File} {@var{bounds} =} prior_bounds (@var{bayesopt},@var{option}) 0005 %! @anchor{prior_bounds} 0006 %! @sp 1 0007 %! Returns bounds for the prior densities. For each estimated parameter the upper and lower bounds 0008 %! are such that the defined intervals contains a probability mass equal to 1-2*@var{option}.prior_trunc. The 0009 %! default value for @var{option}.prior_trunc is 1e-10 (set in @ref{global_initialization}). 0010 %! @sp 2 0011 %! @strong{Inputs} 0012 %! @sp 1 0013 %! @table @ @var 0014 %! @item bayestopt 0015 %! Matlab's structure describing the prior distribution (initialized by @code{dynare}). 0016 %! @item option 0017 %! Matlab's structure describing the options (initialized by @code{dynare}). 0018 %! @end table 0019 %! @sp 2 0020 %! @strong{Outputs} 0021 %! @sp 1 0022 %! @table @ @var 0023 %! @item bounds 0024 %! p*2 matrix of doubles, where p is the number of estimated parameters. The first and second columns report 0025 %! respectively the lower and upper bounds. 0026 %! @end table 0027 %! @sp 2 0028 %! @strong{This function is called by:} 0029 %! @sp 1 0030 %! @ref{get_prior_info}, @ref{dynare_estimation_1}, @ref{dynare_estimation_init} 0031 %! @sp 2 0032 %! @strong{This function calls:} 0033 %! @sp 1 0034 %! None. 0035 %! @end deftypefn 0036 %@eod: 0037 0038 0039 % function bounds = prior_bounds(bayestopt) 0040 % computes bounds for prior density. 0041 % 0042 % INPUTS 0043 % bayestopt [structure] characterizing priors (shape, mean, p1..p4) 0044 % 0045 % OUTPUTS 0046 % bounds [double] matrix specifying prior bounds (row= parameter, column=upper&lower bound) 0047 % 0048 % SPECIAL REQUIREMENTS 0049 % none 0050 0051 % Copyright (C) 2003-2011 Dynare Team 0052 % 0053 % This file is part of Dynare. 0054 % 0055 % Dynare is free software: you can redistribute it and/or modify 0056 % it under the terms of the GNU General Public License as published by 0057 % the Free Software Foundation, either version 3 of the License, or 0058 % (at your option) any later version. 0059 % 0060 % Dynare is distributed in the hope that it will be useful, 0061 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0062 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0063 % GNU General Public License for more details. 0064 % 0065 % You should have received a copy of the GNU General Public License 0066 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0067 0068 pshape = bayestopt.pshape; 0069 p3 = bayestopt.p3; 0070 p4 = bayestopt.p4; 0071 p6 = bayestopt.p6; 0072 p7 = bayestopt.p7; 0073 prior_trunc = options.prior_trunc; 0074 0075 bounds = zeros(length(p6),2); 0076 0077 for i=1:length(p6) 0078 switch pshape(i) 0079 case 1 0080 if prior_trunc == 0 0081 bounds(i,1) = p3(i); 0082 bounds(i,2) = p4(i); 0083 else 0084 bounds(i,1) = betainv(prior_trunc,p6(i),p7(i))*(p4(i)-p3(i))+p3(i); 0085 bounds(i,2) = betainv(1-prior_trunc,p6(i),p7(i))* ... 0086 (p4(i)-p3(i))+p3(i); 0087 end 0088 case 2 0089 if prior_trunc == 0 0090 bounds(i,1) = p3(i); 0091 bounds(i,2) = Inf; 0092 else 0093 try 0094 bounds(i,1) = gaminv(prior_trunc,p6(i),p7(i))+p3(i); 0095 bounds(i,2) = gaminv(1-prior_trunc,p6(i),p7(i))+p3(i); 0096 catch 0097 % Workaround for ticket #161 0098 if exist('OCTAVE_VERSION') 0099 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']) 0100 else 0101 rethrow(lasterror) 0102 end 0103 end 0104 end 0105 case 3 0106 if prior_trunc == 0 0107 bounds(i,1) = -Inf; 0108 bounds(i,2) = Inf; 0109 else 0110 bounds(i,1) = norminv(prior_trunc,p6(i),p7(i)); 0111 bounds(i,2) = norminv(1-prior_trunc,p6(i),p7(i)); 0112 end 0113 case 4 0114 if prior_trunc == 0 0115 bounds(i,1) = p3(i); 0116 bounds(i,2) = Inf; 0117 else 0118 try 0119 bounds(i,1) = 1/sqrt(gaminv(1-prior_trunc, p7(i)/2, 2/p6(i)))+p3(i); 0120 bounds(i,2) = 1/sqrt(gaminv(prior_trunc, p7(i)/2, ... 0121 2/p6(i)))+p3(i); 0122 catch 0123 % Workaround for ticket #161 0124 if exist('OCTAVE_VERSION') 0125 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']) 0126 else 0127 rethrow(lasterror) 0128 end 0129 end 0130 end 0131 case 5 0132 if prior_trunc == 0 0133 bounds(i,1) = p6(i); 0134 bounds(i,2) = p7(i); 0135 else 0136 bounds(i,1) = p6(i)+(p7(i)-p6(i))*prior_trunc; 0137 bounds(i,2) = p7(i)-(p7(i)-p6(i))*prior_trunc; 0138 end 0139 case 6 0140 if prior_trunc == 0 0141 bounds(i,1) = p3(i); 0142 bounds(i,2) = Inf; 0143 else 0144 try 0145 bounds(i,1) = 1/gaminv(1-prior_trunc, p7(i)/2, 2/p6(i))+p3(i); 0146 bounds(i,2) = 1/gaminv(prior_trunc, p7(i)/2, 2/p6(i))+ p3(i); 0147 catch 0148 % Workaround for ticket #161 0149 if exist('OCTAVE_VERSION') 0150 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']) 0151 else 0152 rethrow(lasterror) 0153 end 0154 end 0155 end 0156 otherwise 0157 error(sprintf('prior_bounds: unknown distribution shape (index %d, type %d)', i, pshape(i))); 0158 end 0159 end