ms-sbvar: ms_simulation: add option to save mcmc draws

time-shift
Houtan Bastani 2013-10-23 17:03:52 +02:00
parent 84dd46d9e5
commit 4da6f10233
6 changed files with 18 additions and 1 deletions

View File

@ -7004,6 +7004,13 @@ The total number of draws is equal to
@item adaptive_mh_draws = @var{INTEGER}
Tuning period for Metropolis-Hasting draws. Default: @code{30,000}
@item save_draws
Save all elements of @math{A^0}, @math{A^+}, @math{\xi}, and the
transition matrix to a file named @code{draws_<<file_tag>>.out} with
each draw on a separate line. A file that describes how these matrices
are laid out is contained in
@code{draws_header_<<file_tag>>.out}. Default: @code{off}
@end table
@end deffn

View File

@ -30,4 +30,6 @@ function clean_ms_simulation_files(file_tag)
delete_if_exists(['simulation_' file_tag '.out']);
delete_if_exists(['simulation_info_' file_tag '.out']);
delete_if_exists(['draws_test_' file_tag '.out']);
delete_if_exists(['draws_header_' file_tag '.out']);
end

View File

@ -73,6 +73,7 @@ options_.ms.mh_replic = 10000; % default differs from Dan's code
options_.ms.thinning_factor = 1;
options_.ms.drop = 0.1*options_.ms.mh_replic*options_.ms.thinning_factor;
options_.ms.adaptive_mh_draws = 30000;
options_.ms.save_draws = 0;
% mdd
options_.ms.proposal_draws = 100000;
options_.ms.use_mean_center = 0;

View File

@ -45,6 +45,10 @@ opt = [opt ' -burnin ' num2str(options_.ms.drop)];
opt = [opt ' -thin ' num2str(options_.ms.thinning_factor)];
opt = [opt ' -mh ' num2str(options_.ms.adaptive_mh_draws)];
if options_.ms.save_draws
opt = [opt ' -flat '];
end
% simulation
[err] = ms_sbvar_command_line(opt);
mexErrCheck('ms_simulation',err);

View File

@ -116,7 +116,7 @@ class ParsingDriver;
%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO DIFFUSE_FILTER SUB_DRAWS TAPER_STEPS GEWEKE_INTERVAL
%token <string_val> NAME
%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS
%token NOGRAPH NOMOMENTS NOPRINT NORMAL_PDF
%token NOGRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS
%token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED
%token PARALLEL_LOCAL_FILES PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERFECT_FORESIGHT PERIODS PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE
%token PRINT PRIOR_MC PRIOR_TRUNC PRIOR_MODE PRIOR_MEAN POSTERIOR_MODE POSTERIOR_MEAN POSTERIOR_MEDIAN PRUNING
@ -1991,6 +1991,7 @@ ms_simulation_option : o_output_file_tag
| o_ms_drop
| o_thinning_factor
| o_adaptive_mh_draws
| o_save_draws
;
ms_simulation_options_list : ms_simulation_option COMMA ms_simulation_options_list
@ -2652,6 +2653,7 @@ o_random_parameter_convergence_criterion : RANDOM_PARAMETER_CONVERGENCE_CRITERIO
{ driver.option_num("ms.random_parameter_convergence_criterion",$3); };
o_thinning_factor : THINNING_FACTOR EQUAL INT_NUMBER { driver.option_num("ms.thinning_factor",$3); };
o_adaptive_mh_draws : ADAPTIVE_MH_DRAWS EQUAL INT_NUMBER { driver.option_num("ms.adaptive_mh_draws",$3); };
o_save_draws : SAVE_DRAWS { driver.option_num("ms.save_draws","1"); };
o_proposal_draws : PROPOSAL_DRAWS EQUAL INT_NUMBER { driver.option_num("ms.proposal_draws",$3); };
o_use_mean_center : USE_MEAN_CENTER { driver.option_num("ms.use_mean_center","1"); };
o_proposal_type : PROPOSAL_TYPE EQUAL INT_NUMBER { driver.option_num("ms.proposal_type",$3); }

View File

@ -473,6 +473,7 @@ string eofbuff;
<DYNARE_STATEMENT>filter_decomposition {return token::FILTER_DECOMPOSITION; }
<DYNARE_STATEMENT>selected_variables_only {return token::SELECTED_VARIABLES_ONLY; }
<DYNARE_STATEMENT>pruning {return token::PRUNING; }
<DYNARE_STATEMENT>save_draws {return token::SAVE_DRAWS; }
<DYNARE_STATEMENT>deflator {return token::DEFLATOR;}
<DYNARE_STATEMENT>log_deflator {return token::LOG_DEFLATOR;}
<DYNARE_STATEMENT>growth_factor {return token::GROWTH_FACTOR;}