ms-sbvar: remove unused field removal statements (and set options_.datafile='' in global_initialization)

time-shift
Houtan Bastani 2012-09-25 15:49:59 +02:00
parent 894b3d69f4
commit 12af7298ef
8 changed files with 60 additions and 33 deletions

View File

@ -114,7 +114,7 @@ options_.Schur_vec_tol = 1.e-8;
options_.nomoments=0;
options_.analytic_derivation=1;
options_ = set_default_option(options_,'datafile',[]);
options_ = set_default_option(options_,'datafile','');
options_.mode_compute = 0;
options_.plot_priors = 0;
[dataset_,xparam1, M_, options_, oo_, estim_params_,bayestopt_]=dynare_estimation_init(M_.endo_names,fname_,1, M_, options_, oo_, estim_params_, bayestopt_);

View File

@ -32,7 +32,7 @@ global oo_ M_ options_ estim_params_ bayestopt_ estimation_info ex0_ ys0_ ex_de
estim_params_ = [];
bayestopt_ = [];
options_.datafile = '';
options_.console_mode = 0;
options_.verbosity = 1;

View File

@ -0,0 +1,38 @@
function check_datafile_years_assigned(options_)
% function check_datafile_years_assigned(options_)
% check that datafile, initial_year and final_year were assigned
%
% INPUTS
% options_: (struct) options
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2012 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 isempty(options_.ms.initial_year)
error('Must set initial_year option');
end
if isempty(options_.ms.final_year)
error('Must set final_year option');
end
if isempty(options_.datafile)
error('Must set datafile option');
end

View File

@ -33,15 +33,11 @@ function options_=initialize_ms_sbvar_options(M_, options_)
% all mex functions
options_.ms.file_tag = M_.fname;
options_.ms.create_init = 1;
if isfield(options_.ms,'free_param_file')
options_.ms = rmfield(options_.ms,'free_param_file');
end
options_.ms.mh_file = '';
options_.ms.free_param_file = '';
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
@ -58,15 +54,8 @@ options_.ms.alpha = 1;
options_.ms.beta = 1;
options_.ms.gsig2_lmdm = 50^2;
options_.ms.specification = 2;
if isfield(options_.ms,'initial_year')
options_.ms = rmfield(options_.ms,'initial_year');
end
if isfield(options_.ms,'final_year')
options_.ms = rmfield(options_.ms,'final_year');
end
if isfield(options_,'datafile')
options_ = rmfield(options_,'datafile');
end
options_.ms.initial_year = '';
options_.ms.final_year = '';
% estimation
options_.ms.convergence_starting_value = 1e-3;
options_.ms.convergence_ending_value = 1e-6;

View File

@ -11,7 +11,7 @@ function ms_sbvar_setup(options_)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-2011 Dynare Team
% Copyright (C) 2003-2012 Dynare Team
%
% This file is part of Dynare.
%
@ -28,18 +28,7 @@ function ms_sbvar_setup(options_)
% 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,'initial_year')
error('Must set initial_year option');
end
if ~isfield(options_.ms,'final_year')
error('Must set final_year option');
end
if ~isfield(options_,'datafile')
error('Must set datafile option');
end
check_datafile_years_assigned(options_)
options_.data = read_variables(options_.datafile, ...
options_.varobs, [], options_.xls_sheet, options_.xls_range);

View File

@ -33,7 +33,7 @@ function sbvar(M, options)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
clean_sbvar_files();
check_datafile_years_assigned(options)
options.data = read_variables(options.datafile,options.varobs,[],options.xls_sheet,options.xls_range);
if options.forecast == 0

View File

@ -65,7 +65,7 @@ if options_.periods == 0
end
if ~ options_.initval_file
if ~isfield(options_,'datafile')
if isempty(options_.datafile)
make_ex_;
make_y_;
else

View File

@ -979,12 +979,23 @@ void
MSSBVAREstimationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{
mod_file_struct.bvar_present = true;
if (options_list.num_options.find("ms.create_init") == options_list.num_options.end())
if (options_list.string_options.find("datafile") == options_list.string_options.end() ||
options_list.num_options.find("ms.initial_year") == options_list.num_options.end() ||
options_list.num_options.find("ms.final_year") == options_list.num_options.end())
{
cerr << "ERROR: If you do not pass no_create_init to ms_estimation, "
<< "you must pass the datafile, initial_year and end_year options." << endl;
exit(EXIT_FAILURE);
}
}
void
MSSBVAREstimationStatement::writeOutput(ostream &output, const string &basename) const
{
output << "options_ = initialize_ms_sbvar_options(M_, options_);" << endl;
output << "options_ = initialize_ms_sbvar_options(M_, options_);" << endl
<< "options_.datafile = '';" << endl;
options_list.writeOutput(output);
output << "[options_, oo_] = ms_estimation(M_, options_, oo_);" << endl;
}