Home > matlab > gsa > priorcdf.m

priorcdf

PURPOSE ^

This procedure transforms x vectors into cumulative values

SYNOPSIS ^

function [xcum] = priorcdf(para, pshape, p6, p7, p3, p4)

DESCRIPTION ^

 This procedure transforms x vectors into cumulative values 
 pshape: 0 is point mass, both para and p2 are ignored
         1 is BETA(mean,stdd)
         2 is GAMMA(mean,stdd)
         3 is NORMAL(mean,stdd)
         4 is INVGAMMA(s^2,nu)
         5 is UNIFORM [p1,p2]
 Adapted by M. Ratto from MJ priordens.m

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [xcum] = priorcdf(para, pshape, p6, p7, p3, p4)
0002 % This procedure transforms x vectors into cumulative values
0003 % pshape: 0 is point mass, both para and p2 are ignored
0004 %         1 is BETA(mean,stdd)
0005 %         2 is GAMMA(mean,stdd)
0006 %         3 is NORMAL(mean,stdd)
0007 %         4 is INVGAMMA(s^2,nu)
0008 %         5 is UNIFORM [p1,p2]
0009 % Adapted by M. Ratto from MJ priordens.m
0010 
0011 % Copyright (C) 2012 Dynare Team
0012 %
0013 % This file is part of Dynare.
0014 %
0015 % Dynare is free software: you can redistribute it and/or modify
0016 % it under the terms of the GNU General Public License as published by
0017 % the Free Software Foundation, either version 3 of the License, or
0018 % (at your option) any later version.
0019 %
0020 % Dynare is distributed in the hope that it will be useful,
0021 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0022 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0023 % GNU General Public License for more details.
0024 %
0025 % You should have received a copy of the GNU General Public License
0026 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0027 
0028 nprio     = length(pshape);
0029 
0030 i = 1;
0031 while i <=  nprio;
0032     a = 0;    
0033     b = 0;
0034     if pshape(i) == 1;     % (generalized) BETA Prior
0035 %         mu = (p1(i)-p3(i))/(p4(i)-p3(i));
0036 %         stdd = p2(i)/(p4(i)-p3(i));
0037 %         a = (1-mu)*mu^2/stdd^2 - mu;
0038 %         b = a*(1/mu - 1);
0039         %lnprior = lnprior + lpdfgbeta(para(i),a,b,p3(i),p4(i))   ;
0040         para(:,i) = (para(:,i)-p3(i))./(p4(i)-p3(i));
0041 %         xcum(:,i) = betacdf(para(:,i),a,b)   ;
0042     xcum(:,i) = betainc(para(:,i),p6(i),p7(i));
0043   elseif pshape(i) == 2; % GAMMA PRIOR
0044 %          b = p2(i)^2/(p1(i)-p3(i));
0045 %         a = (p1(i)-p3(i))/b;
0046         %lnprior = lnprior + lpdfgam(para(i)-p3(i),a,b);
0047 %         xcum(:,i) = gamcdf(para(:,i)-p3(i),a,b);
0048     xcum(:,i) = gamcdf(para(:,i)-p3(i),p6(i),p7(i));
0049     elseif pshape(i) == 3; % GAUSSIAN PRIOR
0050      %lnprior = lnprior + lpdfnorm(para(i),p1(i),p2(i));
0051 %      xcum(:,i) = normcdf(para(:,i),p1(i),p2(i));
0052      xcum(:,i) = 0.5 * erfc(-(para(:,i)-p6(i))/p7(i) ./ sqrt(2));
0053     elseif pshape(i) == 4; % INVGAMMA1 PRIOR
0054          %lnprior = lnprior + lpdfig1(para(i),p1(i),p2(i));
0055 %           xcum(:,i) = gamcdf(1/para(:,i).^2,p2(i)/2,2/p1(i));
0056       xcum(:,i) = gamcdf(1./(para(:,i)-p3(i)).^2,p7(i)/2,2/p6(i));
0057     elseif pshape(i) == 5; % UNIFORM PRIOR
0058          %lnprior = lnprior + log(1/(p2(i)-p1(i)));
0059           xcum(:,i) = (para(:,i)-p3(i))./(p4(i)-p3(i));
0060      elseif pshape(i) == 6; % INVGAMMA2 PRIOR
0061 %         lnprior = lnprior + lpdfig2(para(i),p1(i),p2(i));
0062 %           xcum(:,i) = gamcdf(1/para(:,i),p2(i)/2,2/p1(i));
0063       xcum(:,i) = gamcdf(1./(para(:,i)-p3(i)),p7(i)/2,2/p6(i));
0064     end;
0065     i = i+1;
0066 end;
0067

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005