From d1020e61709f2be0038e598b5e4a02401dbb9fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 11 Dec 2015 12:08:49 +0100 Subject: [PATCH] Fixed GSA for Weibull prior. --- matlab/gsa/prior_draw_gsa.m | 12 +++++++----- matlab/gsa/priorcdf.m | 10 +++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/matlab/gsa/prior_draw_gsa.m b/matlab/gsa/prior_draw_gsa.m index cbde56e5d..1e6672050 100644 --- a/matlab/gsa/prior_draw_gsa.m +++ b/matlab/gsa/prior_draw_gsa.m @@ -1,8 +1,5 @@ function pdraw = prior_draw_gsa(init,rdraw) -% Draws from the prior distributions -% Adapted by M. Ratto from prior_draw (of DYNARE, copyright M. Juillard), -% for use with Sensitivity Toolbox for DYNARE -% +% Draws from the prior distributions for use with Sensitivity Toolbox for DYNARE % % INPUTS % o init [integer] scalar equal to 1 (first call) or 0. @@ -25,7 +22,7 @@ function pdraw = prior_draw_gsa(init,rdraw) % Reference: % 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. % @@ -90,6 +87,9 @@ if init % TO BE CHECKED 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)); + 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 % Nothing to do here. end @@ -115,6 +115,8 @@ for i = 1:npar case 6% INV-GAMMA2 distribution % TO BE CHECKED 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 % Nothing to do here. end diff --git a/matlab/gsa/priorcdf.m b/matlab/gsa/priorcdf.m index 5527b6b49..2a72a6f74 100644 --- a/matlab/gsa/priorcdf.m +++ b/matlab/gsa/priorcdf.m @@ -4,11 +4,13 @@ function [xcum] = priorcdf(para, pshape, p6, p7, p3, p4) % 1 is BETA(mean,stdd) % 2 is GAMMA(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] +% 6 is INNGAMMA(s^2,nu) type II +% 8 is WEIBULL(s, k) % 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. % @@ -61,7 +63,9 @@ while i <= nprio; % 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)-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; end;