2005-02-18 20:54:39 +01:00
|
|
|
function bounds = prior_bounds(bayestopt)
|
2008-01-10 15:53:41 +01:00
|
|
|
|
|
|
|
% function bounds = prior_bounds(bayestopt)
|
2008-01-10 16:06:35 +01:00
|
|
|
% computes practical bounds for prior density
|
2008-01-10 15:53:41 +01:00
|
|
|
%
|
|
|
|
% INPUTS
|
|
|
|
% bayestopt: structure characterizing priors (shape, mean, p1..p4)
|
|
|
|
%
|
|
|
|
% OUTPUTS
|
2008-01-10 16:06:35 +01:00
|
|
|
% bounds: matrix specifying bounds (row= parameter, column=upper&lower bound)
|
2008-01-10 15:53:41 +01:00
|
|
|
%
|
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
|
|
|
%
|
|
|
|
% part of DYNARE, copyright Dynare Team (2003-2008)
|
|
|
|
% Gnu Public License.
|
|
|
|
|
|
|
|
|
2005-02-18 20:54:39 +01:00
|
|
|
global options_
|
|
|
|
|
|
|
|
pshape = bayestopt.pshape;
|
|
|
|
pmean = bayestopt.pmean;
|
2006-11-05 14:46:26 +01:00
|
|
|
p1 = bayestopt.p1;
|
2005-02-18 20:54:39 +01:00
|
|
|
p2 = bayestopt.p2;
|
|
|
|
p3 = bayestopt.p3;
|
|
|
|
p4 = bayestopt.p4;
|
|
|
|
|
|
|
|
n = length(pmean);
|
|
|
|
bounds = zeros(n,2);
|
|
|
|
|
|
|
|
for i=1:n
|
2006-09-13 14:39:23 +02:00
|
|
|
switch pshape(i)
|
|
|
|
case 1
|
|
|
|
mu = (pmean(i)-p3(i))/(p4(i)-p3(i));
|
|
|
|
stdd = p2(i)/(p4(i)-p3(i));
|
|
|
|
A = (1-mu)*mu^2/stdd^2 - mu;
|
|
|
|
B = A*(1/mu - 1);
|
|
|
|
bounds(i,1) = qbeta(options_.prior_trunc,A,B)*(p4(i)-p3(i))+p3(i);
|
|
|
|
bounds(i,2) = qbeta(1-options_.prior_trunc,A,B)*(p4(i)-p3(i))+p3(i);
|
|
|
|
case 2
|
|
|
|
b = p2(i)^2/(pmean(i)-p3(i));
|
|
|
|
a = (pmean(i)-p3(i))/b;
|
|
|
|
bounds(i,1) = mj_qgamma(options_.prior_trunc,a)*b+p3(i);
|
|
|
|
bounds(i,2) = mj_qgamma(1-options_.prior_trunc,a)*b+p3(i);
|
|
|
|
case 3
|
|
|
|
bounds(i,1) = qnorm(options_.prior_trunc,pmean(i),p2(i));
|
|
|
|
bounds(i,2) = qnorm(1-options_.prior_trunc,pmean(i),p2(i));
|
|
|
|
case 4
|
|
|
|
nu = p2(i);
|
|
|
|
mu = pmean(i);
|
|
|
|
beta = ( gamma( (nu-1)/2 ) / mu / gamma( nu/2 ) )^2;
|
|
|
|
a=2/beta;
|
|
|
|
bounds(i,1) = 1/sqrt(mj_qgamma(1-options_.prior_trunc,p2(i)/2)*beta);
|
|
|
|
bounds(i,2) = 1/sqrt(mj_qgamma(options_.prior_trunc,p2(i)/2)*beta);
|
|
|
|
case 5
|
2006-11-05 14:46:26 +01:00
|
|
|
bounds(i,1) = p1(i);
|
|
|
|
bounds(i,2) = p2(i);
|
2006-09-13 14:39:23 +02:00
|
|
|
otherwise
|
|
|
|
bounds(i,1) = -Inf;
|
|
|
|
bounds(i,2) = Inf;
|
|
|
|
end
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|