Commit 8747d91d authored by Houtan Bastani's avatar Houtan Bastani
Browse files

MS-SBVAR: fix processing for ms_estimation

parent d115a112
......@@ -32,12 +32,10 @@ function options_=initialize_ms_sbvar_options(M_, options_)
% MS SBVAR
% all mex functions
options_.ms.file_tag = M_.fname;
if isfield(options_.ms,'initialization_file_tag')
options_.ms = rmfield(options_.ms,'initialization_file_tag');
end
if isfield(options_.ms,'estimation_file_tag')
options_.ms = rmfield(options_.ms,'estimation_file_tag');
end
options_.ms.create_init = 1;
if isfield(options_.ms,'free_param_file')
options_.ms = rmfield(options_.ms,'free_param_file');
end
......
......@@ -33,14 +33,18 @@ function [options_, oo_]=ms_estimation(M_, options_, oo_)
disp('MS-SBVAR Estimation');
options_ = set_file_tags(options_);
clean_ms_estimation_files(options_.ms.output_file_tag);
% general setup
if ~isfield(options_.ms, 'initialization_file_tag')
clean_ms_init_files(options_.ms.output_file_tag);
if options_.ms.create_init
clean_ms_init_files(options_.ms.file_tag);
ms_sbvar_setup(options_);
clean_ms_estimation_files(options_.ms.file_tag);
clean_ms_estimation_files(options_.ms.output_file_tag);
else
if ~strcmp(options_.ms.file_tag, options_.ms.output_file_tag)
clean_ms_estimation_files(options_.ms.output_file_tag);
end
end
options_ = set_ms_init_file(options_);
% setup command line options
opt = ['-estimate -seed ' num2str(options_.DynareRandomStreams.seed)];
......
......@@ -434,7 +434,7 @@ fclose(fidForC);
%== Create C initialization filename
%======================================================================
ms_write_markov_file(markov_file,options_)
create_init_file = [matlab_filename,' ',markov_file,' ',options_.ms.output_file_tag];
create_init_file = [matlab_filename,' ',markov_file,' ',options_.ms.file_tag];
[err] = ms_sbvar_create_init_file(create_init_file);
mexErrCheck('ms_sbvar_create_init_file',err);
end
function options_=set_ms_init_file(options_)
%function set_ms_init_file()
% Set options_.ms.init_file based on user input
%
% INPUTS
% options_: (struct) options
% oo_: (struct) results
%
% OUTPUTS
% oo_: (struct) results
%
% 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, 'initialization_file_tag')
options_.ms.initialization_file_tag = options_.ms.output_file_tag;
end
options_.ms.init_file = ['init_' options_.ms.initialization_file_tag '.dat'];
if ~exist(options_.ms.init_file,'file')
error(['ERROR: Could not find initialization file: ' options_.ms.init_file]);
end
end
......@@ -159,7 +159,7 @@ class ParsingDriver;
%token SVAR COEFFICIENTS VARIANCES CONSTANTS EQUATIONS
%token EXTERNAL_FUNCTION EXT_FUNC_NAME EXT_FUNC_NARGS FIRST_DERIV_PROVIDED SECOND_DERIV_PROVIDED
%token SELECTED_VARIABLES_ONLY COVA_COMPUTE ESTIMATION_FILE_TAG SIMULATION_FILE_TAG FILE_TAG
%token NO_ERROR_BANDS ERROR_BAND_PERCENTILES SHOCKS_PER_PARAMETER INITIALIZATION_FILE_TAG
%token NO_ERROR_BANDS ERROR_BAND_PERCENTILES SHOCKS_PER_PARAMETER NO_CREATE_INIT
%token SHOCK_DRAWS FREE_PARAMETERS MEDIAN DATA_OBS_NBR NEIGHBORHOOD_WIDTH PVALUE_KS PVALUE_CORR
%token FILTERED_PROBABILITIES FILTERED REAL_TIME_SMOOTHED
%token PROPOSAL_TYPE MDD_PROPOSAL_DRAWS MDD_USE_MEAN_CENTER
......@@ -1630,7 +1630,7 @@ ms_estimation_option : o_coefficients_prior_hyperparameters
| o_gsig2_lmdm
| o_output_file_tag
| o_file_tag
| o_initialization_file_tag
| o_no_create_init
| o_convergence_starting_value
| o_convergence_ending_value
| o_convergence_increment_value
......@@ -2087,7 +2087,7 @@ o_cova_compute : COVA_COMPUTE EQUAL INT_NUMBER
;
o_output_file_tag : OUTPUT_FILE_TAG EQUAL filename {driver.option_str("ms.output_file_tag", $3); };
o_file_tag : FILE_TAG EQUAL filename { driver.option_str("ms.file_tag", $3); };
o_initialization_file_tag : INITIALIZATION_FILE_TAG EQUAL filename { driver.option_str("ms.initialization_file_tag", $3); };
o_no_create_init : NO_CREATE_INIT { driver.option_str("ms.create_init", "0"); };
o_estimation_file_tag : ESTIMATION_FILE_TAG EQUAL filename { driver.option_str("ms.estimation_file_tag", $3); };
o_simulation_file_tag : SIMULATION_FILE_TAG EQUAL filename { driver.option_str("ms.simulation_file_tag", $3); };
o_coefficients_prior_hyperparameters : COEFFICIENTS_PRIOR_HYPERPARAMETERS EQUAL vec_value
......
......@@ -320,7 +320,7 @@ string eofbuff;
<DYNARE_STATEMENT>output_file_tag {return token::OUTPUT_FILE_TAG;}
<DYNARE_STATEMENT>file_tag {return token::FILE_TAG;};
<DYNARE_STATEMENT>initialization_file_tag {return token::INITIALIZATION_FILE_TAG;};
<DYNARE_STATEMENT>no_create_init {return token::NO_CREATE_INIT;};
<DYNARE_STATEMENT>estimation_file_tag {return token::ESTIMATION_FILE_TAG;};
<DYNARE_STATEMENT>simulation_file_tag {return token::SIMULATION_FILE_TAG;};
<DYNARE_STATEMENT>filtered {return token::FILTERED;}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment