Commit d8c19044 authored by michel's avatar michel
Browse files

4.1: sets natural boundaries when options_.prior_trunc == 0 (to be merged in 4.0)

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2585 ac1d8469-bf42-47a9-8791-bf33cf982152
parent af7bacdf
......@@ -35,29 +35,62 @@ p3 = bayestopt.p3;
p4 = bayestopt.p4;
p6 = bayestopt.p6;
p7 = bayestopt.p7;
prior_trunc = options_.prior_trunc;
bounds = zeros(length(p6),2);
for i=1:length(p6)
switch pshape(i)
case 1
bounds(i,1) = betainv(options_.prior_trunc,p6(i),p7(i))*(p4(i)-p3(i))+p3(i);
bounds(i,2) = betainv(1-options_.prior_trunc,p6(i),p7(i))*(p4(i)-p3(i))+p3(i);
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
bounds(i,1) = gaminv(options_.prior_trunc,p6(i),p7(i))+p3(i);
bounds(i,2) = gaminv(1-options_.prior_trunc,p6(i),p7(i))+p3(i);
if prior_trunc == 0
bounds(i,1) = p3(i);
bounds(i,2) = Inf;
else
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);
end
case 3
bounds(i,1) = norminv(options_.prior_trunc,p6(i),p7(i));
bounds(i,2) = norminv(1-options_.prior_trunc,p6(i),p7(i));
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
bounds(i,1) = 1/sqrt(gaminv(1-options_.prior_trunc, p7(i)/2, 2/p6(i)))+p3(i);
bounds(i,2) = 1/sqrt(gaminv(options_.prior_trunc, p7(i)/2, 2/p6(i)))+p3(i);
if prior_trunc == 0
bounds(i,1) = p3(i);
bounds(i,2) = Inf;
else
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);
end
case 5
bounds(i,1) = p6(i)+(p7(i)-p6(i))*options_.prior_trunc;
bounds(i,2) = p7(i)-(p7(i)-p6(i))*options_.prior_trunc;
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
bounds(i,1) = 1/gaminv(1-options_.prior_trunc, p7(i)/2, 2/p6(i))+p3(i);
bounds(i,2) = 1/gaminv(options_.prior_trunc, p7(i)/2, 2/p6(i))+p3(i);
if prior_trunc == 0
bounds(i,1) = p3(i);
bounds(i,2) = Inf;
else
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);
end
otherwise
error(sprintf('prior_bounds: unknown distribution shape (index %d, type %d)', i, pshape(i)));
end
......
Supports Markdown
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