Commit 0f001abb authored by Houtan Bastani's avatar Houtan Bastani
Browse files

MS-SBVAR: input options that allow code to be called with previous output files

parent 676f201e
function clean_files_for_second_type_of_mex(M_, options_, type)
%function clean_files_for_second_type_of_mex()
% clean the files for the appropriate file tag and mex function
%
% INPUTS
% M_: (struct) model structure
% options_: (struct) options
% type: (string) one of irf, forecast or
% variance_decomposition
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2011 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if isfield(options_.ms,'estimation_file_tag')
tagtouse = options_.ms.estimation_file_tag;
else
tagtouse = options_.ms.file_tag;
end
if ~strcmp(tagtouse, options_.ms.output_file_tag) || ...
~strcmp(M_.fname, options_.ms.output_file_tag)
tagtouse = options_.ms.output_file_tag;
end
switch type
case 'irf'
clean_ms_irf_files(tagtouse);
case 'forecast'
clean_ms_forecast_files(tagtouse);
case 'variance_decomposition'
clean_ms_variance_decomposition_files(tagtouse);
otherwise
error('clean_files_for_second_type_of_mex: should not arrive here');
end
function clean_ms_forecast_files(file_tag)
% function clean_ms_forecast_files()
% removes MS forecast files
%
% INPUTS
% file_tag: string indicating tag to use when deleting files
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2011 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
delete_dir_if_exists([file_tag filesep 'Forecast']);
delete_dir_if_exists([file_tag filesep 'Output' filesep 'Forecast']);
end
function clean_ms_irf_files(file_tag)
% function clean_ms_irf_files()
% removes MS irf files
%
% INPUTS
% file_tag: string indicating tag to use when deleting files
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2011 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
delete_dir_if_exists([file_tag filesep 'IRF']);
delete_dir_if_exists([file_tag filesep 'Output' filesep 'IRF']);
end
......@@ -30,4 +30,5 @@ function clean_ms_probabilities_files(file_tag)
delete_if_exists(['smoothed_' file_tag '.out']);
delete_if_exists(['filtered_' file_tag '.out']);
delete_dir_if_exists([file_tag filesep 'Output' filesep 'Probabilities']);
end
function clean_ms_variance_decomposition_files(file_tag)
% function clean_ms_variance_decomposition_files()
% removes MS variance decomposition files
%
% INPUTS
% file_tag: string indicating tag to use when deleting files
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2011 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
delete_dir_if_exists([file_tag filesep 'Variance_Decomposition']);
delete_dir_if_exists([file_tag filesep 'Output' filesep 'Variance_Decomposition']);
end
function create_dir(dirname)
% function create_dir()
% creates directory if it doesn't exist
%
% INPUTS
% dirname: string indicating name of directory
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2011 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if ~exist(dirname, 'dir')
mkdir(dirname);
end
end
function delete_dir_if_exists(dirname)
% function delete_dir_if_exists()
% removes directory if it exists
%
% INPUTS
% dirname: directory to delete
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2011 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if exist(dirname, 'dir')
rmdir(dirname,'s');
end
end
......@@ -30,7 +30,8 @@ function dyn_save_graph(dirname,graph_name,graph_formats,TeX,names,texnames,capt
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
graph_name = [dirname filesep 'Output' filesep regexprep(graph_name,' ','_')];
create_dir(dirname);
graph_name = [dirname filesep regexprep(graph_name,' ','_')];
if nargin <= 2
TeX = 0;
elseif nargin <= 4
......@@ -66,4 +67,3 @@ function dyn_save_graph(dirname,graph_name,graph_formats,TeX,names,texnames,capt
fprintf(fh,'%% End of TeX file.\n');
fclose(fh);
end
......@@ -32,7 +32,27 @@ function options_=initialize_ms_sbvar_options(M_, options_)
% MS SBVAR
% all mex functions
options_.ms.file_tag = M_.fname;
options_.ms.output_file_tag = M_.fname;
if isfield(options_.ms,'initialization_file_tag')
options_.ms = rmfield(options_.ms,'initialization_file_tag');
end
if isfield(options_.ms,'init_file')
options_.ms = rmfield(options_.ms,'init_file');
end
if isfield(options_.ms,'estimation_file_tag')
options_.ms = rmfield(options_.ms,'estimation_file_tag');
end
if isfield(options_.ms,'free_param_file')
options_.ms = rmfield(options_.ms,'free_param_file');
end
if isfield(options_.ms,'simulation_file_tag')
options_.ms = rmfield(options_.ms,'simulation_file_tag');
end
if isfield(options_.ms,'mh_file')
options_.ms = rmfield(options_.ms,'mh_file');
end
if isfield(options_.ms,'output_file_tag')
options_.ms = rmfield(options_.ms,'output_file_tag');
end
% prepare ms sbvar & estimation
options_.ms.coefficients_prior_hyperparameters = [1.0 1.0 0.1 1.2 1.0 1.0];
options_.ms.freq = 4;
......@@ -97,10 +117,4 @@ options_.ms.shocks_per_parameter = 10;
options_.ms.median = 0;
% forecast
options_.ms.forecast_data_obs = 0;
if isfield(options_.ms,'free_parameters')
options_.ms = rmfield(options_.ms,'free_parameters');
end
if isfield(options_.ms,'simulation_file')
options_.ms = rmfield(options_.ms,'simulation_file');
end
end
function [options_, oo_]=ms_compute_mdd(M_, options_, oo_)
%function ms_compute_mdd()
% Compute marginal data density
% MS Sbvar Compute Marginal Data Density
%
% INPUTS
% M_: (struct) model structure
......@@ -31,15 +31,17 @@ function [options_, oo_]=ms_compute_mdd(M_, options_, oo_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
disp('Marginal Data Density');
clean_ms_mdd_files(options_.ms.output_file_tag,options_.ms.mdd_proposal_type(1));
options_ = set_ms_estimation_flags_for_other_mex(options_);
options_ = set_ms_simulation_flags_for_other_mex(options_);
oo_ = set_oo_w_estimation_output(options_, oo_);
disp('MS-SBVAR Marginal Data Density');
options_ = set_file_tags(options_);
clean_ms_mdd_files(options_.ms.output_file_tag, options_.ms.mdd_proposal_type(1));
[options_, oo_] = set_ms_estimation_file(options_, oo_);
options_ = set_ms_simulation_file(options_);
% setup command line options
opt = ['-mdd -seed ' num2str(options_.DynareRandomStreams.seed)];
opt = [opt ' -ft ' options_.ms.output_file_tag];
opt = [opt ' -ft ' options_.ms.simulation_file_tag];
opt = [opt ' -fto ' options_.ms.output_file_tag];
opt = [opt ' -pf ' options_.ms.mh_file];
opt = [opt ' -d ' num2str(options_.ms.mdd_proposal_draws)];
if options_.ms.mdd_use_mean_center
opt = [opt ' -use_mean'];
......@@ -54,7 +56,7 @@ end
% compute mdd
[err] = ms_sbvar_command_line(opt);
mexErrCheck('ms_sbvar_command_line mdd',err);
mexErrCheck('ms_compute_mdd',err);
% grab the muller/bridge log mdd from the output file
mull_exp = 'Muller \w+\(\w+\) \= (\d+.\d+e\+\d+)';
......
function [options_, oo_]=ms_compute_probabilities(M_, options_, oo_)
%function ms_simulation()
% Compute posterior mode regime probabilities
% MS Sbvar Compute Posterior Mode Regime Probabilities
%
% INPUTS
% M_: (struct) model structure
......@@ -31,14 +31,15 @@ function [options_, oo_]=ms_compute_probabilities(M_, options_, oo_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
disp('Compute Regime Probabilities');
options_ = set_ms_estimation_flags_for_other_mex(options_);
options_ = set_ms_simulation_flags_for_other_mex(options_);
oo_ = set_oo_w_estimation_output(options_, oo_);
disp('MS-SBVAR Compute Regime Probabilities');
options_ = set_file_tags(options_);
clean_ms_probabilities_files(options_.ms.output_file_tag);
[options_, oo_] = set_ms_estimation_file(options_, oo_);
% setup command line options
opt = ['-probabilities -seed ' num2str(options_.DynareRandomStreams.seed)];
opt = [opt ' -ft ' options_.ms.output_file_tag];
opt = [opt ' -ft ' options_.ms.estimation_file_tag];
opt = [opt ' -fto ' options_.ms.output_file_tag];
if options_.ms.filtered_probabilities
opt = [opt ' -filtered' ];
......@@ -53,12 +54,12 @@ end
% compute probabilities
[err] = ms_sbvar_command_line(opt);
mexErrCheck('ms_sbvar_command_line probabilities',err);
mexErrCheck('ms_compute_probabilities',err);
% now we want to plot the probabilities for each chain
if ischar(prob_out_file)
computed_probabilities = load(prob_out_file);
plot_ms_probabilities(computed_probabilities,options_,M_.fname);
plot_ms_probabilities(computed_probabilities,options_);
end
options_ = initialize_ms_sbvar_options(M_, options_);
end
......@@ -31,18 +31,21 @@ function [options_, oo_]=ms_estimation(M_, options_, oo_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
disp('Estimation');
% cleanup old files
clean_ms_init_files(options_.ms.output_file_tag);
disp('MS-SBVAR Estimation');
options_ = set_file_tags(options_);
clean_ms_estimation_files(options_.ms.output_file_tag);
% general setup
ms_sbvar_setup(options_);
if ~isfield(options_.ms, 'initialization_file_tag')
clean_ms_init_files(options_.ms.output_file_tag);
ms_sbvar_setup(options_);
end
options_ = set_ms_init_file(options_);
% setup command line options
opt = ['-estimate -seed ' num2str(options_.DynareRandomStreams.seed)];
opt = [opt ' -ft ' options_.ms.output_file_tag];
opt = [opt ' -ft ' options_.ms.file_tag];
opt = [opt ' -fto ' options_.ms.output_file_tag];
opt = [opt ' -cb ' num2str(options_.ms.convergence_starting_value)];
opt = [opt ' -ce ' num2str(options_.ms.convergence_ending_value)];
opt = [opt ' -ci ' num2str(options_.ms.convergence_increment_value)];
......@@ -61,9 +64,11 @@ opt = [opt ' -random_tol_parms ' num2str(options_.ms.random_parameter_convergenc
% estimation
[err] = ms_sbvar_command_line(opt);
mexErrCheck('ms_sbvar_command_line estimation', err);
mexErrCheck('ms_estimation', err);
options_ = set_ms_estimation_flags_for_other_mex(options_);
oo_ = set_oo_w_estimation_output(options_, oo_);
[options_, oo_] = set_ms_estimation_file(options_, oo_);
[err, oo_.ms.A0, oo_.ms.Aplus, oo_.ms.Zeta, oo_.ms.Q] = ...
mex_ms_convert_free_parameters(options_.ms.estimation_file_tag, oo_.ms.maxparams);
mexErrCheck('mex_ms_convert_free_parameters', err);
options_ = initialize_ms_sbvar_options(M_, options_);
end
function [options_, oo_]=ms_forecast(M_, options_, oo_)
%function ms_forecast()
% calls ms irf mex function
% MS-SBVAR Forecast
%
% INPUTS
% M_: (struct) model structure
......@@ -31,12 +31,15 @@ function [options_, oo_]=ms_forecast(M_, options_, oo_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
disp('Forecasts');
options_ = set_ms_estimation_flags_for_other_mex(options_);
options_ = set_ms_simulation_flags_for_other_mex(options_);
oo_ = set_oo_w_estimation_output(options_, oo_);
disp('MS-SBVAR Forecasts');
options_ = set_file_tags(options_);
[options_, oo_] = set_ms_estimation_file(options_, oo_);
options_ = set_ms_simulation_file(options_);
clean_files_for_second_type_of_mex(M_, options_, 'forecast')
forecastdir = [options_.ms.output_file_tag filesep 'Forecast'];
create_dir(forecastdir);
opt = {options_.ms.output_file_tag, ...
opt = {options_.ms.estimation_file_tag, ...
'seed', options_.DynareRandomStreams.seed, ...
'horizon', options_.ms.horizon, ...
'data',options_.ms.forecast_data_obs ...
......@@ -46,22 +49,22 @@ opt = {options_.ms.output_file_tag, ...
[err, forecast] = mex_ms_forecast(opt{:},'free_parameters',oo_.ms.maxparams,'shocks_per_parameter', options_.ms.shock_draws);
mexErrCheck('mex_ms_forecast ergodic ', err);
plot_ms_forecast(M_,forecast,'Forecast',options_.graph_save_formats,options_.TeX);
plot_ms_forecast(M_,options_,forecast,'Forecast',options_.graph_save_formats,options_.TeX);
[err, regime_forecast] = mex_ms_forecast(opt{:},'free_parameters',oo_.ms.maxparams,'shocks_per_parameter', options_.ms.shock_draws,'regimes');
mexErrCheck('mex_ms_forecast ergodic regimes', err);
save([M_.fname '/' options_.ms.output_file_tag '_ergodic_forecast.mat'], 'forecast', 'regime_forecast');
save([forecastdir filesep 'ergodic_forecast.mat'], 'forecast', 'regime_forecast');
if exist(options_.ms.load_mh_file,'file') > 0
if exist(options_.ms.mh_file,'file') > 0
[err, forecast] = mex_ms_forecast(opt{:},'free_parameters',oo_.ms.maxparams,'shocks_per_parameter', options_.ms.shocks_per_parameter, ...
'simulation_file',options_.ms.load_mh_file,'parameter_uncertainty');
'simulation_file',options_.ms.mh_file,'parameter_uncertainty');
mexErrCheck('mex_ms_forecast bayesian ', err);
plot_ms_forecast(M_,forecast,'Forecast w/ Parameter Uncertainty',options_.graph_save_formats,options_.TeX);
plot_ms_forecast(M_,options_,forecast,'Forecast w/ Parameter Uncertainty',options_.graph_save_formats,options_.TeX);
[err, regime_forecast] = mex_ms_forecast(opt{:},'free_parameters',oo_.ms.maxparams,'shocks_per_parameter', options_.ms.shocks_per_parameter, ...
'simulation_file',options_.ms.load_mh_file,'parameter_uncertainty','regimes');
'simulation_file',options_.ms.mh_file,'parameter_uncertainty','regimes');
mexErrCheck('mex_ms_forecast bayesian regimes ', err);
save([M_.fname '/' options_.ms.output_file_tag '_bayesian_forecast.mat'], 'forecast', 'regime_forecast');
save([forecastdir filesep 'bayesian_forecast.mat'], 'forecast', 'regime_forecast');
end
options_ = initialize_ms_sbvar_options(M_, options_);
end
function [options_, oo_]=ms_irf(varlist,M_, options_, oo_)
%function ms_irf()
% calls ms irf mex function
% MS-SBVAR Impulse Response Function
%
% INPUTS
% varlist: (chararray) list of selected endogenous variables
......@@ -32,12 +32,15 @@ function [options_, oo_]=ms_irf(varlist,M_, options_, oo_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
disp('IRFs');
options_ = set_ms_estimation_flags_for_other_mex(options_);
options_ = set_ms_simulation_flags_for_other_mex(options_);
oo_ = set_oo_w_estimation_output(options_, oo_);
disp('MS-SBVAR Impulse Response Function');
options_ = set_file_tags(options_);
[options_, oo_] = set_ms_estimation_file(options_, oo_);
options_ = set_ms_simulation_file(options_);
clean_files_for_second_type_of_mex(M_, options_, 'irf')
irfdir = [options_.ms.output_file_tag filesep 'IRF'];
create_dir(irfdir);
opt = {options_.ms.output_file_tag, ...
opt = {options_.ms.estimation_file_tag, ...
'seed', options_.DynareRandomStreams.seed, ...
'horizon', options_.ms.horizon, ...
'filtered', options_.ms.filtered_probabilities, ...
......@@ -55,22 +58,22 @@ for i=1:size(regime_irfs,1)
plot_ms_irf(M_,options_,squeeze(regime_irfs(i,:,:,:)),options_.varobs,['Ergodic ' ...
'Impulse Responses State ' int2str(i)],varlist);
end
save([M_.fname '/' options_.ms.output_file_tag '_ergodic_irf.mat'], 'irf', 'regime_irfs');
save([irfdir filesep 'ergodic_irf.mat'], 'irf', 'regime_irfs');
if exist(options_.ms.load_mh_file,'file') > 0
if exist(options_.ms.mh_file,'file') > 0
[err, irf] = mex_ms_irf(opt{:}, 'shocks_per_parameter', options_.ms.shocks_per_parameter, ...
'parameter_uncertainty','simulation_file',options_.ms.load_mh_file);
'parameter_uncertainty','simulation_file',options_.ms.mh_file);
mexErrCheck('mex_ms_irf bayesian ',err);
plot_ms_irf(M_,options_,irf,options_.varobs,'Impulse Responses with Parameter Uncertainty',varlist);
[err, regime_irfs] = mex_ms_irf(opt{:}, 'shocks_per_parameter', options_.ms.shocks_per_parameter, ...
'simulation_file',options_.ms.load_mh_file,'parameter_uncertainty','regimes');
'simulation_file',options_.ms.mh_file,'parameter_uncertainty','regimes');
mexErrCheck('mex_ms_irf bayesian regimes ',err);
for i=1:size(regime_irfs,1)
plot_ms_irf(M_,options_,squeeze(regime_irfs(i,:,:,:)),options_.varobs,['Impulse ' ...
'Responses with Parameter Uncertainty State ' int2str(i)],varlist);
end
save([M_.fname '/' options_.ms.output_file_tag '_bayesian_irf.mat'], 'irf', 'regime_irfs');
save([irfdir filesep 'bayesian_irf.mat'], 'irf', 'regime_irfs');
end
options_ = initialize_ms_sbvar_options(M_, options_);
end
......@@ -31,14 +31,15 @@ function [options_, oo_]=ms_simulation(M_, options_, oo_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
disp('Simulation');
disp('MS-SBVAR Simulation');
options_ = set_file_tags(options_);
clean_ms_simulation_files(options_.ms.output_file_tag);
options_ = set_ms_estimation_flags_for_other_mex(options_);
oo_ = set_oo_w_estimation_output(options_, oo_);
[options_, oo_] = set_ms_estimation_file(options_, oo_);
% setup command line options
opt = ['-simulate -seed ' num2str(options_.DynareRandomStreams.seed)];
opt = [opt ' -ft ' options_.ms.output_file_tag];
opt = [opt ' -ft ' options_.ms.estimation_file_tag];
opt = [opt ' -fto ' options_.ms.output_file_tag];
opt = [opt ' -ndraws ' num2str(options_.ms.mh_replic)];
opt = [opt ' -burnin ' num2str(options_.ms.drop)];
opt = [opt ' -thin ' num2str(options_.ms.thinning_factor)];
......@@ -46,8 +47,7 @@ opt = [opt ' -mh ' num2str(options_.ms.adaptive_mh_draws)];
% simulation
[err] = ms_sbvar_command_line(opt);
mexErrCheck('ms_sbvar_command_line simulate',err);
mexErrCheck('ms_simulation',err);
options_.ms.simulation_file_tag = options_.ms.output_file_tag;
options_ = initialize_ms_sbvar_options(M_, options_);
end
function [options_, oo_]=ms_variance_decomposition(M_, options_, oo_)
%function ms_variance_decomposition()
% calls ms_variance_decomposition mex function
% MS-SBVAR Variance Decomposition
%
% INPUTS
% M_: (struct) model structure
......@@ -31,14 +31,17 @@ function [options_, oo_]=ms_variance_decomposition(M_, options_, oo_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
disp('Variance Decomposition');
options_ = set_ms_estimation_flags_for_other_mex(options_);
options_ = set_ms_simulation_flags_for_other_mex(options_);
oo_ = set_oo_w_estimation_output(options_, oo_);
disp('MS-SBVAR Variance Decomposition');
options_ = set_file_tags(options_);
[options_, oo_] = set_ms_estimation_file(options_, oo_);
options_ = set_ms_simulation_file(options_);
clean_files_for_second_type_of_mex(M_, options_, 'variance_decomposition')
vddir = [options_.ms.output_file_tag filesep 'Variance_Decomposition'];
create_dir(vddir);
% NOTICE THAT VARIANCE DECOMPOSITION DEFAULTS TO USING THE MEAN, NOT MEDIAN OR BANDED
opt = {options_.ms.output_file_tag, ...
opt = {options_.ms.estimation_file_tag, ...
'seed', options_.DynareRandomStreams.seed, ...
'horizon', options_.ms.horizon, ...
'filtered', options_.ms.filtered_probabilities, ...
......@@ -49,19 +52,19 @@ opt = {options_.ms.output_file_tag, ...
[err, vd] = mex_ms_variance_decomposition(opt{:},'free_parameters',oo_.ms.maxparams,'shocks',options_.ms.shock_draws);
mexErrCheck('mex_ms_variance_decomposition ergodic ', err);
plot_ms_