Fixed GSA for Weibull prior.

time-shift
Stéphane Adjemian (Charybdis) 2015-12-11 12:08:49 +01:00
parent 5834ed4446
commit d1020e6170
2 changed files with 14 additions and 8 deletions

View File

@ -1,8 +1,5 @@
function pdraw = prior_draw_gsa(init,rdraw) function pdraw = prior_draw_gsa(init,rdraw)
% Draws from the prior distributions % Draws from the prior distributions for use with Sensitivity Toolbox for DYNARE
% Adapted by M. Ratto from prior_draw (of DYNARE, copyright M. Juillard),
% for use with Sensitivity Toolbox for DYNARE
%
% %
% INPUTS % INPUTS
% o init [integer] scalar equal to 1 (first call) or 0. % o init [integer] scalar equal to 1 (first call) or 0.
@ -25,7 +22,7 @@ function pdraw = prior_draw_gsa(init,rdraw)
% Reference: % Reference:
% M. Ratto, Global Sensitivity Analysis for Macroeconomic models, MIMEO, 2006. % M. Ratto, Global Sensitivity Analysis for Macroeconomic models, MIMEO, 2006.
% Copyright (C) 2012 Dynare Team % Copyright (C) 2012-2015 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -90,6 +87,9 @@ if init
% TO BE CHECKED % TO BE CHECKED
lbcum(i) = gamcdf(1/(bounds.ub(i)-p3(i)),p7(i)/2,2/p6(i)); lbcum(i) = gamcdf(1/(bounds.ub(i)-p3(i)),p7(i)/2,2/p6(i));
ubcum(i) = gamcdf(1/(bounds.lb(i)-p3(i)),p7(i)/2,2/p6(i)); ubcum(i) = gamcdf(1/(bounds.lb(i)-p3(i)),p7(i)/2,2/p6(i));
case 8
lbcum(i) = weibcdf(bounds.lb(i)-p3(i),p6(i),p7(i));
ubcum(i) = weibcdf(bounds.ub(i)-p3(i),p6(i),p7(i));
otherwise otherwise
% Nothing to do here. % Nothing to do here.
end end
@ -115,6 +115,8 @@ for i = 1:npar
case 6% INV-GAMMA2 distribution case 6% INV-GAMMA2 distribution
% TO BE CHECKED % TO BE CHECKED
pdraw(:,i) = 1./gaminv(rdraw(:,i),p7(i)/2,2/p6(i))+p3(i); pdraw(:,i) = 1./gaminv(rdraw(:,i),p7(i)/2,2/p6(i))+p3(i);
case 8
pdraw(:,i) = wblinv(rdraw(:,i),p6(i),p7(i))+p3(i);
otherwise otherwise
% Nothing to do here. % Nothing to do here.
end end

View File

@ -4,11 +4,13 @@ function [xcum] = priorcdf(para, pshape, p6, p7, p3, p4)
% 1 is BETA(mean,stdd) % 1 is BETA(mean,stdd)
% 2 is GAMMA(mean,stdd) % 2 is GAMMA(mean,stdd)
% 3 is NORMAL(mean,stdd) % 3 is NORMAL(mean,stdd)
% 4 is INVGAMMA(s^2,nu) % 4 is INVGAMMA(s^2,nu) type I
% 5 is UNIFORM [p1,p2] % 5 is UNIFORM [p1,p2]
% 6 is INNGAMMA(s^2,nu) type II
% 8 is WEIBULL(s, k)
% Adapted by M. Ratto from MJ priordens.m % Adapted by M. Ratto from MJ priordens.m
% Copyright (C) 2012 Dynare Team % Copyright (C) 2012-2015 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -61,7 +63,9 @@ while i <= nprio;
% lnprior = lnprior + lpdfig2(para(i),p1(i),p2(i)); % lnprior = lnprior + lpdfig2(para(i),p1(i),p2(i));
% xcum(:,i) = gamcdf(1/para(:,i),p2(i)/2,2/p1(i)); % xcum(:,i) = gamcdf(1/para(:,i),p2(i)/2,2/p1(i));
xcum(:,i) = gamcdf(1./(para(:,i)-p3(i)),p7(i)/2,2/p6(i)); xcum(:,i) = gamcdf(1./(para(:,i)-p3(i)),p7(i)/2,2/p6(i));
end; elseif pshape(i)==8
xcum(:,i) = wblcdf(para(:,i)-p3(i),p6(i),p7(i));
end;
i = i+1; i = i+1;
end; end;