From ee3ceb7db6eeefceac24d717dcac18f8c9c077f4 Mon Sep 17 00:00:00 2001 From: sebastien Date: Tue, 1 Dec 2009 17:51:47 +0000 Subject: [PATCH] M-files and preprocessor: * removed "options_.simul", and instead test if "options_.periods" is non-zero * test for the incompatibility of options "periods" and "hp_filter" in "stoch_simul.m", instead of in the preprocessor Reference manual: * removed "simul" options, updated "periods" * updated "order" option (for 3rd order) * added "k_order_solver" option * give some hints for installing a compiler for users of MATLAB for Windows git-svn-id: https://www.dynare.org/svn/dynare/trunk@3188 ac1d8469-bf42-47a9-8791-bf33cf982152 --- doc/manual.xml | 29 +++++++++++++---------------- matlab/disp_moments.m | 4 ++++ matlab/global_initialization.m | 1 - matlab/osr.m | 6 ------ matlab/simul.m | 4 ---- matlab/simult.m | 1 - matlab/stoch_simul.m | 8 ++------ matlab/stoch_simul_sparse.m | 7 ++----- preprocessor/ComputingTasks.cc | 25 ------------------------- preprocessor/DynareBison.yy | 5 ++--- preprocessor/ParsingDriver.cc | 4 +--- 11 files changed, 24 insertions(+), 70 deletions(-) diff --git a/doc/manual.xml b/doc/manual.xml index 7c1a32b30..bdce693bf 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -98,7 +98,7 @@ Currently the development team of Dynare is composed of S. Adjemian, H. Bastani, Installation and configuration -Software requirements +Software requirements Packaged versions of Dynare are available for Windows XP/Vista, Debian GNU/Linux and Ubuntu. Dynare should work on other systems, but some compilation steps are necessary in that case. @@ -109,13 +109,10 @@ Dynare should work on other systems, but some compilation steps are necessary in GNU Octave version 3.0.0 or above. - -Installation of GNU Octave +Some installation instructions for GNU Octave can be found on Dynare Wiki. -You can skip this step if you are planning to use only MATLAB with Dynare. - -Please refer to Dynare Wiki for detailed instructions. +If you are using MATLAB for Windows, and if you plan to use options or , you will need to install a C++ compiler on your machine. The easiest solution is to install Microsoft Visual C++ 2008 Express Edition, and then to type mex -setup on the MATLAB prompt (it should autodetect the compiler). For users of MATLAB 64-bit, please refer to these instructions. Users of MATLAB under Linux and MacOS, and users of GNU Octave normally need to do nothing, since a working compilation environment is available by default. @@ -840,9 +837,9 @@ Inside the model block, Dynare allows the creation of model-local vari Declares the model as being linear. It spares oneself from having to declare initial values for computing the steady state, and it sets automatically =1 in . - + - Instructs the preprocessor to create dynamic loadable libraries (DLL) containing the model equations and derivatives, instead of writing those in M-files. You need to having a working compilation environment (i.e. the mex command of MATLAB or Octave must be operational). Using this option can result in faster simulations or estimations, at the expense of some initial compilation time.In particular, for big models, the compilation step can be very time-consuming, and use of this option may be counter-productive in those cases. + Instructs the preprocessor to create dynamic loadable libraries (DLL) containing the model equations and derivatives, instead of writing those in M-files. You need a working compilation environment, i.e. a working mex command (see for more details). Using this option can result in faster simulations or estimations, at the expense of some initial compilation time.In particular, for big models, the compilation step can be very time-consuming, and use of this option may be counter-productive in those cases. @@ -1032,7 +1029,7 @@ For models with lags on more than one period, the command block, possibly recomputed by , will be used as starting point for the simulation. The simulated endogenous variables are made available to the user in a vector for each variable and in the global matrix oo_.endo_simul. The variables in the oo_.endo_simul matrix, in their order of declaration (as in M_.endo_names) Default: 0 = DOUBLE @@ -1847,10 +1848,6 @@ The simulated endogenous variables are available in global matrix oo_.e = INTEGER Number of simulated series used to compute the IRFs. Default: 1 if =1, and 50 otherwise - - - Computes a stochastic simulation of the model for the number of periods specified in the option. Uses values, possibly recomputed by , as initial values for the simulation. The simulated endogenous variables are made available to the user in a vector for each variable and in the global matrix oo_.endo_simul. The variables in the oo_.endo_simul matrix, in their order of declaration (as in M_.endo_names). Default: no simulation - = INTEGER Specifies a seed for the random generator so as to obtain the same random sample at each run of the program. Otherwise a different sample is used for each run. Default: seed not specified diff --git a/matlab/disp_moments.m b/matlab/disp_moments.m index a4dbf1f5d..734130861 100644 --- a/matlab/disp_moments.m +++ b/matlab/disp_moments.m @@ -23,6 +23,10 @@ function disp_moments(y,var_list) warning_old_state = warning; warning off + if options_.hp_filter + error('STOCH_SIMUL: HP filter is not yet implemented for empirical moments') + end + if size(var_list,1) == 0 var_list = M_.endo_names(1:M_.orig_endo_nbr, :); end diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m index 467c6927e..365658374 100644 --- a/matlab/global_initialization.m +++ b/matlab/global_initialization.m @@ -90,7 +90,6 @@ function global_initialization() options_.nocorr = 0; options_.periods = 0; options_.noprint = 0; - options_.simul = 0; options_.SpectralDensity = 0; % TeX output diff --git a/matlab/osr.m b/matlab/osr.m index 2e9a31e03..275763fc5 100644 --- a/matlab/osr.m +++ b/matlab/osr.m @@ -32,12 +32,6 @@ function osr(var_list,params,i_var,W) options_ = set_default_option(options_,'hp_ngrid',512); options_ = set_default_option(options_,'simul',0); options_ = set_default_option(options_,'periods',1); - if options_.simul & ~isempty(options_.periods) & options_.periods == 0 - options_.periods = options_.periods; - end - - options_.periods = max(options_.periods,1); - options_.periods = options_.periods; make_ex_; diff --git a/matlab/simul.m b/matlab/simul.m index fd7b5dc36..f2c3df2c8 100644 --- a/matlab/simul.m +++ b/matlab/simul.m @@ -37,14 +37,10 @@ if size(M_.lead_lag_incidence,2)-nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1 error (mess) ; end -if ~isfield(options_,'periods') & ~isempty(options_.periods) - options_.periods = options_.periods -end options_ = set_default_option(options_,'periods',0); if options_.periods == 0 error('SIMUL: number of periods for the simulation isn''t specified') end -options_.periods = options_.periods; if ~ options_.initval_file if ~isfield(options_,'datafile') diff --git a/matlab/simult.m b/matlab/simult.m index 728af3701..fba16268d 100644 --- a/matlab/simult.m +++ b/matlab/simult.m @@ -39,7 +39,6 @@ if replic == 0 replic = 1; end seed = options_.simul_seed; -options_.periods = options_.periods; it_ = M_.maximum_lag + 1 ; diff --git a/matlab/stoch_simul.m b/matlab/stoch_simul.m index 6e068a2b1..f7c1321cb 100644 --- a/matlab/stoch_simul.m +++ b/matlab/stoch_simul.m @@ -26,7 +26,6 @@ function info=stoch_simul(var_list) if options_.order == 1 options_.replic = 1; elseif options_.order == 3 - options_.simul = 1; options_.k_order_solver = 1; end @@ -70,12 +69,9 @@ function info=stoch_simul(var_list) end end - if options_.simul == 0 & options_.nomoments == 0 + if options_.periods == 0 && options_.nomoments == 0 disp_th_moments(oo_.dr,var_list); - elseif options_.simul == 1 - if options_.periods == 0 - error('STOCH_SIMUL error: number of periods for the simulation isn''t specified') - end + elseif options_.periods ~= 0 if options_.periods < options_.drop disp(['STOCH_SIMUL error: The horizon of simulation is shorter' ... ' than the number of observations to be DROPed']) diff --git a/matlab/stoch_simul_sparse.m b/matlab/stoch_simul_sparse.m index 04741fbd9..f5f47bec3 100644 --- a/matlab/stoch_simul_sparse.m +++ b/matlab/stoch_simul_sparse.m @@ -73,12 +73,9 @@ function info=stoch_simul_sparse(var_list) disp_dr_sparse(oo_.dr,options_.order,var_list); end - if options_.simul == 0 & options_.nomoments == 0 + if options_.periods == 0 && options_.nomoments == 0 disp_th_moments(oo_.dr,var_list); - elseif options_.simul == 1 - if options_.periods == 0 - error('STOCH_SIMUL error: number of periods for the simulation isn''t specified') - end + elseif options_.periods ~= 0 if options_.periods < options_.drop disp(['STOCH_SIMUL error: The horizon of simulation is shorter' ... ' than the number of observations to be DROPed']) diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 90f7e9a87..f802f917d 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -118,14 +118,6 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct) it = options_list.num_options.find("partial_information"); if (it != options_list.num_options.end() && it->second == "1") mod_file_struct.partial_information = true; - - // This (temporary) check is present in stoch_simul, osr and ramsey_policy - if (options_list.num_options.find("simul") != options_list.num_options.end() - && options_list.num_options.find("hp_filter") != options_list.num_options.end()) - { - cerr << "ERROR: stoch_simul: HP filter is not yet implemented when computing empirical simulations" << endl; - exit(EXIT_FAILURE); - } } void @@ -182,14 +174,6 @@ RamseyPolicyStatement::checkPass(ModFileStructure &mod_file_struct) it = options_list.num_options.find("partial_information"); if (it != options_list.num_options.end() && it->second == "1") mod_file_struct.partial_information = true; - - // This (temporary) check is present in stoch_simul, osr and ramsey_policy - if (options_list.num_options.find("simul") != options_list.num_options.end() - && options_list.num_options.find("hp_filter") != options_list.num_options.end()) - { - cerr << "ERROR: ramsey_policy: HP filter is not yet implemented when computing empirical simulations" << endl; - exit(EXIT_FAILURE); - } } void @@ -316,7 +300,6 @@ void PeriodsStatement::writeOutput(ostream &output, const string &basename) const { output << "options_.periods = " << periods << ";" << endl; - output << "options_.simul = 1;" << endl; } DsampleStatement::DsampleStatement(int val1_arg) : val1(val1_arg), val2(-1) @@ -747,14 +730,6 @@ OsrStatement::checkPass(ModFileStructure &mod_file_struct) it = options_list.num_options.find("partial_information"); if (it != options_list.num_options.end() && it->second == "1") mod_file_struct.partial_information = true; - - // This (temporary) check is present in stoch_simul, osr and ramsey_policy - if (options_list.num_options.find("simul") != options_list.num_options.end() - && options_list.num_options.find("hp_filter") != options_list.num_options.end()) - { - cerr << "ERROR: osr: HP filter is not yet implemented when computing empirical simulations" << endl; - exit(EXIT_FAILURE); - } } void diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index 925dc3e01..61ca875f4 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -1655,13 +1655,12 @@ o_nomoments : NOMOMENTS { driver.option_num("nomoments", "1"); }; o_irf : IRF EQUAL INT_NUMBER { driver.option_num("irf", $3); }; o_hp_filter : HP_FILTER EQUAL INT_NUMBER { driver.option_num("hp_filter", $3); }; o_hp_ngrid : HP_NGRID EQUAL INT_NUMBER { driver.option_num("hp_ngrid", $3); }; -o_periods : PERIODS EQUAL INT_NUMBER - { driver.option_num("periods", $3); driver.option_num("simul", "1"); }; +o_periods : PERIODS EQUAL INT_NUMBER { driver.option_num("periods", $3); }; o_cutoff : CUTOFF EQUAL number { driver.cutoff($3); } o_markowitz : MARKOWITZ EQUAL number { driver.option_num("markowitz", $3); }; o_minimal_solving_periods : MINIMAL_SOLVING_PERIODS EQUAL number { driver.option_num("minimal_solving_periods", $3); }; o_mfs : MFS EQUAL INT_NUMBER { driver.mfs($3); }; -o_simul : SIMUL { driver.option_num("simul", "1"); }; +o_simul : SIMUL; // Do nothing, only here for backward compatibility o_simul_seed : SIMUL_SEED EQUAL INT_NUMBER { driver.option_num("simul_seed", $3); } ; o_qz_criterium : QZ_CRITERIUM EQUAL number { driver.option_num("qz_criterium", $3); }; o_datafile : DATAFILE EQUAL filename { driver.option_str("datafile", $3); }; diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index e4b000827..890f57414 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -648,9 +648,7 @@ ParsingDriver::option_num(const string &name_option, string *opt) void ParsingDriver::option_num(const string &name_option, const string &opt) { - // Since "periods" option automatically sets "simul" option, we don't want to fail if user explicitly sets both "simul" and "periods" - if (name_option != "simul" - && (options_list.num_options.find(name_option) != options_list.num_options.end())) + if (options_list.num_options.find(name_option) != options_list.num_options.end()) error("option " + name_option + " declared twice"); if ((name_option == "periods") && mod_file->block)