Home > matlab > variance_decomposition_mc_analysis.m

variance_decomposition_mc_analysis

PURPOSE ^

This function analyses the (posterior or prior) distribution of the

SYNOPSIS ^

function oo_ = variance_decomposition_mc_analysis(NumberOfSimulations,type,dname,fname,exonames,exo,vartan,var,mh_conf_sig,oo_)

DESCRIPTION ^

 This function analyses the (posterior or prior) distribution of the
 endogenous variance decomposition.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function oo_ = variance_decomposition_mc_analysis(NumberOfSimulations,type,dname,fname,exonames,exo,vartan,var,mh_conf_sig,oo_)
0002 % This function analyses the (posterior or prior) distribution of the
0003 % endogenous variance decomposition.
0004 
0005 % Copyright (C) 2008-2009 Dynare Team
0006 %
0007 % This file is part of Dynare.
0008 %
0009 % Dynare is free software: you can redistribute it and/or modify
0010 % it under the terms of the GNU General Public License as published by
0011 % the Free Software Foundation, either version 3 of the License, or
0012 % (at your option) any later version.
0013 %
0014 % Dynare is distributed in the hope that it will be useful,
0015 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 % GNU General Public License for more details.
0018 %
0019 % You should have received a copy of the GNU General Public License
0020 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0021 
0022 if strcmpi(type,'posterior')
0023     TYPE = 'Posterior';
0024     PATH = [dname '/metropolis/'];
0025 else
0026     TYPE = 'Prior';
0027     PATH = [dname '/prior/moments/'];
0028 end
0029 
0030 indx = check_name(vartan,var);
0031 if isempty(indx)
0032     disp([ type '_analysis:: ' var ' is not a stationary endogenous variable!'])
0033     return
0034 end
0035 jndx = check_name(exonames,exo);
0036 if isempty(jndx)
0037     disp([ type '_analysis:: ' exo ' is not a declared exogenous variable!'])
0038     return
0039 end
0040 
0041 name = [ var '.' exo ];
0042 if isfield(oo_, [ TYPE 'TheoreticalMoments'])
0043     eval(['temporary_structure = oo_.' TYPE 'TheoreticalMoments;'])
0044     if isfield(temporary_structure,'dsge')
0045         eval(['temporary_structure = oo_.' TYPE 'TheoreticalMoments.dsge;'])
0046         if isfield(temporary_structure,'VarianceDecomposition')
0047             eval(['temporary_structure = oo_.' TYPE 'TheoreticalMoments.dsge.VarianceDecomposition.mean;'])
0048             if isfield(temporary_structure,name)
0049                 % Nothing to do.
0050                 return
0051             end
0052         end
0053     end
0054 end
0055 
0056 ListOfFiles = dir([ PATH  fname '_' TYPE 'VarianceDecomposition*.mat']);
0057 i1 = 1; tmp = zeros(NumberOfSimulations,1);
0058 indice = (indx-1)*rows(exonames)+jndx;
0059 for file = 1:length(ListOfFiles)
0060     load([ PATH ListOfFiles(file).name ]);
0061     i2 = i1 + rows(Decomposition_array) - 1;
0062     tmp(i1:i2) = Decomposition_array(:,indice);
0063     i1 = i2+1;
0064 end
0065 
0066 t1 = min(tmp); t2 = max(tmp);
0067 t3 = t2-t1;% How to normalize ? t1 and t2 may be zero...
0068 if t3<1.0e-12
0069     if t1<1.0e-12
0070         t1 = 0;
0071     end
0072     if abs(t1-1)<1.0e-12
0073         t1 = 1;
0074     end 
0075     p_mean = t1;
0076     p_median = t1;
0077     p_var = 0;
0078     hpd_interval = NaN(2,1);
0079     p_deciles = NaN(9,1);
0080     density = NaN;
0081 else
0082     [p_mean, p_median, p_var, hpd_interval, p_deciles, density] = ...
0083         posterior_moments(tmp,1,mh_conf_sig);
0084 end
0085 eval(['oo_.' TYPE 'TheoreticalMoments.dsge.VarianceDecomposition.mean.' name ' = p_mean;']);
0086 eval(['oo_.' TYPE 'TheoreticalMoments.dsge.VarianceDecomposition.median.' name ' = p_median;']);
0087 eval(['oo_.' TYPE 'TheoreticalMoments.dsge.VarianceDecomposition.variance.' name ' = p_var;']);
0088 eval(['oo_.' TYPE 'TheoreticalMoments.dsge.VarianceDecomposition.hpdinf.' name ' = hpd_interval(1);']);
0089 eval(['oo_.' TYPE 'TheoreticalMoments.dsge.VarianceDecomposition.hpdsup.' name ' = hpd_interval(2);']);
0090 eval(['oo_.' TYPE 'TheoreticalMoments.dsge.VarianceDecomposition.deciles.' name ' = p_deciles;']);
0091 eval(['oo_.' TYPE 'TheoreticalMoments.dsge.VarianceDecomposition.density.' name ' = density;']);

Generated on Wed 23-May-2012 02:40:54 by m2html © 2005