0001 function [options_, oo_]=ms_compute_mdd(M_, options_, oo_)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
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
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
0054 [err] = ms_sbvar_command_line(opt);
0055 mexErrCheck('ms_compute_mdd',err);
0056
0057
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