Home > matlab > ms-sbvar > plot_ms_probabilities.m

plot_ms_probabilities

PURPOSE ^

function plot_ms_probabilities(computed_probabilities, options_)

SYNOPSIS ^

function plot_ms_probabilities(computed_probabilities, options_)

DESCRIPTION ^

 function plot_ms_probabilities(computed_probabilities, options_)
 Plots the regime probablities for each graph

 INPUTS
    computed_probabilities:      Txnstates 

 OUTPUTS
    none

 SPECIAL REQUIREMENTS
    none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function plot_ms_probabilities(computed_probabilities, options_)
0002 % function plot_ms_probabilities(computed_probabilities, options_)
0003 % Plots the regime probablities for each graph
0004 %
0005 % INPUTS
0006 %    computed_probabilities:      Txnstates
0007 %
0008 % OUTPUTS
0009 %    none
0010 %
0011 % SPECIAL REQUIREMENTS
0012 %    none
0013 
0014 % Copyright (C) 2011 Dynare Team
0015 %
0016 % This file is part of Dynare.
0017 %
0018 % Dynare is free software: you can redistribute it and/or modify
0019 % it under the terms of the GNU General Public License as published by
0020 % the Free Software Foundation, either version 3 of the License, or
0021 % (at your option) any later version.
0022 %
0023 % Dynare is distributed in the hope that it will be useful,
0024 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0026 % GNU General Public License for more details.
0027 %
0028 % You should have received a copy of the GNU General Public License
0029 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0030   
0031   [T,num_grand_regimes] = size(computed_probabilities);
0032   num_chains = length(options_.ms.ms_chain);
0033   for i=1:num_chains
0034     chains(i).num_regimes = length(options_.ms.ms_chain(i).regime);
0035     chains(i).probabilities = zeros([T,chains(i).num_regimes]);
0036   end
0037   
0038   for t=1:T
0039     chains = iterate_chain(computed_probabilities(t,:), t, chains, 1, num_chains);
0040   end
0041   
0042   for i=1:num_chains
0043     graph_name = ['MS-Probabilities, Chain ' int2str(i)];
0044     figure('Name',graph_name)
0045     plot(chains(i).probabilities,'LineWidth', 1.2);
0046     ltxt = {};
0047     for j=1:chains(i).num_regimes
0048       ltxt{j} = ['Regime ' int2str(j)];
0049     end
0050     legend(ltxt{:});
0051     title(['Chain ' int2str(i)]);
0052     ylim([0 1.0]);
0053     dyn_save_graph([options_.ms.output_file_tag filesep 'Output' filesep 'Probabilities'], ['MS-Probabilities-Chain-' int2str(i)], ...
0054         options_.graph_save_formats,options_.TeX,[],[],graph_name);
0055   end
0056 end
0057 
0058 function [chains] = iterate_chain(probs, t, chains, chain, num_chains)
0059   offset_length = length(probs)/chains(chain).num_regimes;
0060   for i=1:chains(chain).num_regimes
0061     p = probs( (i-1)*offset_length+1 : i*offset_length );
0062     chains(chain).probabilities(t, i) = chains(chain).probabilities(t, i) + sum( p );
0063     if chain < num_chains
0064       chains = iterate_chain(p, t, chains, chain+1, num_chains);
0065     end
0066   end
0067 end

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005