Home > matlab > conditional_variance_decomposition_mc_analysis.m

conditional_variance_decomposition_mc_analysis

PURPOSE ^

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

SYNOPSIS ^

function oo_ =conditional_variance_decomposition_mc_analysis(NumberOfSimulations, type, dname, fname, Steps, exonames, exo, var_list, endogenous_variable_index, mh_conf_sig, oo_)

DESCRIPTION ^

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

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