Home > matlab > ms-sbvar > ms_compute_mdd.m

ms_compute_mdd

PURPOSE ^

function [options_, oo_]=ms_compute_mdd(M_, options_, oo_)

SYNOPSIS ^

function [options_, oo_]=ms_compute_mdd(M_, options_, oo_)

DESCRIPTION ^

 function [options_, oo_]=ms_compute_mdd(M_, options_, oo_)
 Markov-switching SBVAR: Compute Marginal Data Density

 INPUTS
    M_:          (struct)    model structure
    options_:    (struct)    options
    oo_:         (struct)    results

 OUTPUTS
    options_:    (struct)    options
    oo_:         (struct)    results

 SPECIAL REQUIREMENTS
    none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [options_, oo_]=ms_compute_mdd(M_, options_, oo_)
0002 % function [options_, oo_]=ms_compute_mdd(M_, options_, oo_)
0003 % Markov-switching SBVAR: Compute Marginal Data Density
0004 %
0005 % INPUTS
0006 %    M_:          (struct)    model structure
0007 %    options_:    (struct)    options
0008 %    oo_:         (struct)    results
0009 %
0010 % OUTPUTS
0011 %    options_:    (struct)    options
0012 %    oo_:         (struct)    results
0013 %
0014 % SPECIAL REQUIREMENTS
0015 %    none
0016 
0017 % Copyright (C) 2011 Dynare Team
0018 %
0019 % This file is part of Dynare.
0020 %
0021 % Dynare is free software: you can redistribute it and/or modify
0022 % it under the terms of the GNU General Public License as published by
0023 % the Free Software Foundation, either version 3 of the License, or
0024 % (at your option) any later version.
0025 %
0026 % Dynare is distributed in the hope that it will be useful,
0027 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0028 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0029 % GNU General Public License for more details.
0030 %
0031 % You should have received a copy of the GNU General Public License
0032 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0033 
0034 disp('MS-SBVAR Marginal Data Density');
0035 options_ = set_file_tags(options_);
0036 clean_ms_mdd_files(options_.ms.output_file_tag, options_.ms.proposal_type);
0037 [options_, oo_] = set_ms_estimation_file(options_.ms.file_tag, options_, oo_);
0038 options_ = set_ms_simulation_file(options_);
0039 
0040 % setup command line options
0041 opt = ['-mdd -seed ' num2str(options_.DynareRandomStreams.seed)];
0042 opt = [opt ' -ft ' options_.ms.simulation_file_tag];
0043 opt = [opt ' -fto ' options_.ms.output_file_tag];
0044 opt = [opt ' -pf ' options_.ms.mh_file];
0045 opt = [opt ' -d ' num2str(options_.ms.proposal_draws)];
0046 opt = [opt ' -pt ' num2str(options_.ms.proposal_type)];
0047 opt = [opt ' -l '  num2str(options_.ms.proposal_lower_bound)];
0048 opt = [opt ' -h '  num2str(options_.ms.proposal_upper_bound)];
0049 if options_.ms.use_mean_center
0050     opt = [opt ' -use_mean'];
0051 end
0052 
0053 % compute mdd
0054 [err] = ms_sbvar_command_line(opt);
0055 mexErrCheck('ms_compute_mdd',err);
0056 
0057 % grab the muller/bridge log mdd from the output file
0058 mull_exp = 'Muller \w+\(\w+\) \= (\d+.\d+e\+\d+)';
0059 bridge_exp = 'Bridge \w+\(\w+\) \= (\d+.\d+e\+\d+)';
0060 bridge_mdd = -1; muller_mdd = -1;
0061 mdd_filename = ['mdd_t' num2str(options_.ms.proposal_type) '_' options_.ms.output_file_tag '.out'];
0062 if exist(mdd_filename,'file')
0063     mdd_fid = fopen(mdd_filename);
0064     tline = fgetl(mdd_fid);
0065     while ischar(tline)
0066         mull_tok = regexp(tline,mull_exp,'tokens');
0067         bridge_tok = regexp(tline,bridge_exp,'tokens');
0068         if (~isempty(mull_tok))
0069             muller_mdd = str2double(mull_tok{1}{1});
0070         end
0071         if (~isempty(bridge_tok))
0072             bridge_mdd = str2double(bridge_tok{1}{1});
0073         end
0074         tline = fgetl(mdd_fid);
0075     end
0076     oo_.ms.mueller_log_mdd = muller_mdd;
0077     oo_.ms.bridged_log_mdd = bridge_mdd;
0078 end
0079 end

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