Skip to content
Snippets Groups Projects
Commit eb443f74 authored by michel's avatar michel
Browse files

4.0: merged (by hand) changeset r2585 from trunk (sets natural prior...

4.0: merged (by hand) changeset r2585 from trunk (sets natural prior boundaries when optiosn_.prior_trunc == 0)

git-svn-id: https://www.dynare.org/svn/dynare/branches/4.0@2586 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 5435bfcd
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ function bounds = prior_bounds(bayestopt) ...@@ -11,7 +11,7 @@ function bounds = prior_bounds(bayestopt)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2008 Dynare Team % Copyright (C) 2003-2009 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -36,6 +36,8 @@ p1 = bayestopt.p1; ...@@ -36,6 +36,8 @@ p1 = bayestopt.p1;
p2 = bayestopt.p2; p2 = bayestopt.p2;
p3 = bayestopt.p3; p3 = bayestopt.p3;
p4 = bayestopt.p4; p4 = bayestopt.p4;
prior_trunc = options_.prior_trunc;
n = length(pmean); n = length(pmean);
bounds = zeros(n,2); bounds = zeros(n,2);
...@@ -43,29 +45,61 @@ bounds = zeros(n,2); ...@@ -43,29 +45,61 @@ bounds = zeros(n,2);
for i=1:n for i=1:n
switch pshape(i) switch pshape(i)
case 1 case 1
mu = (pmean(i)-p3(i))/(p4(i)-p3(i)); if prior_trunc == 0
stdd = p2(i)/(p4(i)-p3(i)); bounds(i,1) = p3(i);
A = (1-mu)*mu^2/stdd^2 - mu; bounds(i,2) = p4(i);
B = A*(1/mu - 1); else
bounds(i,1) = betainv(options_.prior_trunc,A,B)*(p4(i)-p3(i))+p3(i); mu = (pmean(i)-p3(i))/(p4(i)-p3(i));
bounds(i,2) = betainv(1-options_.prior_trunc,A,B)*(p4(i)-p3(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) = betainv(options_.prior_trunc,A,B)*(p4(i)-p3(i))+p3(i);
bounds(i,2) = betainv(1-options_.prior_trunc,A,B)*(p4(i)- ...
p3(i))+p3(i);
end
case 2 case 2
b = p2(i)^2/(pmean(i)-p3(i)); if prior_trunc == 0
a = (pmean(i)-p3(i))/b; bounds(i,1) = p3(i);
bounds(i,1) = gaminv(options_.prior_trunc,a,b)+p3(i); bounds(i,2) = Inf;
bounds(i,2) = gaminv(1-options_.prior_trunc,a,b)+p3(i); else
b = p2(i)^2/(pmean(i)-p3(i));
a = (pmean(i)-p3(i))/b;
bounds(i,1) = gaminv(options_.prior_trunc,a,b)+p3(i);
bounds(i,2) = gaminv(1-options_.prior_trunc,a,b)+p3(i);
end
case 3 case 3
bounds(i,1) = norminv(options_.prior_trunc,pmean(i),p2(i)); if prior_trunc == 0
bounds(i,2) = norminv(1-options_.prior_trunc,pmean(i),p2(i)); bounds(i,1) = -Inf;
bounds(i,2) = Inf;
else
bounds(i,1) = norminv(options_.prior_trunc,pmean(i),p2(i));
bounds(i,2) = norminv(1-options_.prior_trunc,pmean(i),p2(i));
end
case 4 case 4
bounds(i,1) = 1/sqrt(gaminv(1-options_.prior_trunc, p2(i)/2, 2/p1(i))); if prior_trunc == 0
bounds(i,2) = 1/sqrt(gaminv(options_.prior_trunc, p2(i)/2, 2/p1(i))); bounds(i,1) = 0;
bounds(i,2) = Inf;
else
bounds(i,1) = 1/sqrt(gaminv(1-options_.prior_trunc, p2(i)/2, 2/p1(i)));
bounds(i,2) = 1/sqrt(gaminv(options_.prior_trunc, p2(i)/2, ...
2/p1(i)));
end
case 5 case 5
bounds(i,1) = p1(i); if prior_trunc == 0
bounds(i,2) = p2(i); bounds(i,1) = p1(i);
bounds(i,2) = p2(i);
else
bounds(i,1) = p1(i)+(p2(i)-p1(i))*prior_trunc;
bounds(i,2) = p2(i)-(p2(i)-p1(i))*prior_trunc;
end
case 6 case 6
bounds(i,1) = 1/gaminv(1-options_.prior_trunc, p2(i)/2, 2/p1(i)); if prior_trunc == 0
bounds(i,2) = 1/gaminv(options_.prior_trunc, p2(i)/2, 2/p1(i)); bounds(1) = 0;
bounds(2) = Inf;
else
bounds(i,1) = 1/gaminv(1-options_.prior_trunc, p2(i)/2, 2/p1(i));
bounds(i,2) = 1/gaminv(options_.prior_trunc, p2(i)/2, 2/p1(i));
end
otherwise otherwise
error(sprintf('prior_bounds: unknown distribution shape (index %d, type %d)', i, pshape(i))); error(sprintf('prior_bounds: unknown distribution shape (index %d, type %d)', i, pshape(i)));
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment