diff --git a/matlab/ms-sbvar/clean_swz_files.m b/matlab/ms-sbvar/clean_ms_files.m similarity index 93% rename from matlab/ms-sbvar/clean_swz_files.m rename to matlab/ms-sbvar/clean_ms_files.m index 9ee29d345e91185825e34567063d8ad3c69f668e..2d0e86d3544a3f9c6fef54b0cc3d5d95767b2135 100644 --- a/matlab/ms-sbvar/clean_swz_files.m +++ b/matlab/ms-sbvar/clean_ms_files.m @@ -1,6 +1,6 @@ -function clean_swz_files(mod_name) -% function clean_swz_files() -% removes SWZ intermediary files +function clean_ms_files(mod_name) +% function clean_ms_files() +% removes MS intermediary files % % INPUTS % none @@ -11,7 +11,7 @@ function clean_swz_files(mod_name) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2007-2008, 2010 Dynare Team +% Copyright (C) 2007-2011 Dynare Team % % This file is part of Dynare. % diff --git a/matlab/ms-sbvar/swz_mardd.m b/matlab/ms-sbvar/ms_mardd.m similarity index 97% rename from matlab/ms-sbvar/swz_mardd.m rename to matlab/ms-sbvar/ms_mardd.m index e27b085262ee26312d3de55f95a88d9dea6eb5f9..9b8070c36f6d41e7fb560efdd9cb6baf3a299da6 100644 --- a/matlab/ms-sbvar/swz_mardd.m +++ b/matlab/ms-sbvar/ms_mardd.m @@ -1,4 +1,4 @@ -function swz_mardd(options_) +function ms_mardd(options_) % Applies to both linear and exclusion restrictions. % (1) Marginal likelihood function p(Y) for constant structural VAR models, using Chib (1995)'s ``Marginal Likelihood from the Gibbs Output'' in JASA. % (2) Conditional likelihood function f(Y|A0, A+) on the ML estimate for constant exclusion-identified models. diff --git a/matlab/ms-sbvar/swz_sbvar.m b/matlab/ms-sbvar/ms_sbvar.m similarity index 81% rename from matlab/ms-sbvar/swz_sbvar.m rename to matlab/ms-sbvar/ms_sbvar.m index 63c748acb16d48c456d34ac8c8cacd6f469d0ab8..6774db32f069c6efca37f194d5339ee1d2cf2990 100644 --- a/matlab/ms-sbvar/swz_sbvar.m +++ b/matlab/ms-sbvar/ms_sbvar.m @@ -1,14 +1,14 @@ -function swz_sbvar(ms_flag, M, options) +function ms_sbvar(ms_flag, M, options) dynareroot = strrep(which('dynare'),'dynare.m',''); -swz_root = [dynareroot '/ms-sbvar']; +ms_root = [dynareroot '/ms-sbvar']; -addpath([swz_root '/cstz']); -addpath([swz_root '/identification']); -addpath([swz_root '/switching_specification']); -addpath([swz_root '/mhm_specification']); +addpath([ms_root '/cstz']); +addpath([ms_root '/identification']); +addpath([ms_root '/switching_specification']); +addpath([ms_root '/mhm_specification']); -clean_swz_files(M.fname); +clean_ms_files(M.fname); options.data = read_variables(options.datafile,options.varobs,[],options.xls_sheet,options.xls_range); @@ -35,7 +35,7 @@ elseif ~isempty(options.ms.Qi) && ~isempty(options.ms.Ri) end if ms_flag == 1 - % changing some option names to match SWZ code + % changing some option names to match MS code options.ms.firstMetrop = options.ms.draws_nbr_burn_in_1; options.ms.secondMetrop = options.ms.draws_nbr_burn_in_2; options.ms.ndrawsmv = options.ms.draws_nbr_mean_var_estimate; @@ -50,5 +50,5 @@ if ms_flag == 1 options.ms.markov_file = 'markov_file'; sz_prd(M,options); else - swz_mardd(options); + ms_mardd(options); end diff --git a/matlab/ms-sbvar/swz_write_markov_file.m b/matlab/ms-sbvar/ms_write_markov_file.m similarity index 96% rename from matlab/ms-sbvar/swz_write_markov_file.m rename to matlab/ms-sbvar/ms_write_markov_file.m index ce253158fc32792a9d6876040a7254f200ca4b2f..defd64225164eee907edd9b56b1b19a8e8c93a5b 100644 --- a/matlab/ms-sbvar/swz_write_markov_file.m +++ b/matlab/ms-sbvar/ms_write_markov_file.m @@ -1,4 +1,4 @@ -function swz_write_markov_file(fname,M,options) +function ms_write_markov_file(fname,M,options) n_chains = length(options.ms.ms_chain); nvars = size(options.varobs,1); diff --git a/matlab/ms-sbvar/swz_write_mhm_input.m b/matlab/ms-sbvar/ms_write_mhm_input.m similarity index 96% rename from matlab/ms-sbvar/swz_write_mhm_input.m rename to matlab/ms-sbvar/ms_write_mhm_input.m index e455f810d434f0d209c192a019c7ee7387b71efe..2debc1203907c3e1d6b767a8624a3995f91d02d2 100644 --- a/matlab/ms-sbvar/swz_write_mhm_input.m +++ b/matlab/ms-sbvar/ms_write_mhm_input.m @@ -1,4 +1,4 @@ -function swz_write_mhm_input(fname,options_ms) +function ms_write_mhm_input(fname,options_ms) fh = fopen(fname,'w'); diff --git a/matlab/ms-sbvar/sz_prd.m b/matlab/ms-sbvar/sz_prd.m index a4be892e91c03bc1964e96476bc3b3975d1f48d4..a11e5dd495a09af040e59fc7c0859ddf36f1a502 100644 --- a/matlab/ms-sbvar/sz_prd.m +++ b/matlab/ms-sbvar/sz_prd.m @@ -6,17 +6,17 @@ function sz_prd(M,options_) %generation of mhm file %generateMHM_input(options_); -swz_root = strrep(which('swz_sbvar'),'/swz_sbvar.m',''); +ms_root = strrep(which('ms_sbvar'),'/ms_sbvar.m',''); % path for C executables %c_path='./c-executables'; -c_path = [swz_root '/bin']; +c_path = [ms_root '/bin']; % path for Markov specification -m_spec_path=[swz_root '/switching_specification']; +m_spec_path=[ms_root '/switching_specification']; % path for MHM specification -mhm_spec_path=[swz_root '/mhm_specification']; +mhm_spec_path=[ms_root '/mhm_specification']; %========================================================================== %== Processing control @@ -486,7 +486,7 @@ if options_.ms.create_initialization_file == 1 %====================================================================== %== Create C initialization filename %====================================================================== - swz_write_markov_file(markov_file,M,options_) + ms_write_markov_file(markov_file,M,options_) if options_.ms.standalone == 1 if use_linux == 1 create_init_file=[c_path,'/sbvar_init_file ',matlab_filename,' ',markov_file,' ',options_.ms.output_file_tag]; @@ -527,7 +527,7 @@ end %========================================================================== if options_.ms.compute_mdd == 1 mhm_file = ['mhm_input_' M.fname '.dat']; - swz_write_mhm_input(mhm_file,options_.ms); + ms_write_mhm_input(mhm_file,options_.ms); if options_.ms.standalone == 1 if use_linux == 1 compute_mdd1=[c_path,'/sbvar_mhm_1 -cseed 5 -ft ',options_.ms.output_file_tag,' -fi ',mhm_file]; @@ -588,4 +588,4 @@ if options_.ms.print_draws == 1 %error here as well [err] = mex_sbvar_draws(print_draws); mexErrCheck('mex_sbvar_draws',err); end -end \ No newline at end of file +end diff --git a/ms-sbvar/mex/mex_top_level.cc b/ms-sbvar/mex/mex_top_level.cc index 1ae594e2278ec8c915e71c7d7042752d05a752ab..e81c522df439ea3d4185c7e697a29be66f415ab1 100644 --- a/ms-sbvar/mex/mex_top_level.cc +++ b/ms-sbvar/mex/mex_top_level.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Dynare Team + * Copyright (C) 2010-2011 Dynare Team * * This file is part of Dynare. * @@ -44,38 +44,38 @@ mexFunction(int nlhs, mxArray *plhs[], * Check args */ if (nrhs != 1 || !mxIsChar(prhs[0]) || nlhs != 1) - DYN_MEX_FUNC_ERR_MSG_TXT("Error in swz_mex: this function takes 1 string input argument and returns 1 output argument."); + DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: this function takes 1 string input argument and returns 1 output argument."); /* * Allocate memory */ maxnargs = (int)(mxGetN(prhs[0])/2+1); - argument = (char *)swzCalloc(mxGetN(prhs[0])+1, sizeof(char)); - args = (char **)swzCalloc(maxnargs, sizeof(char *)); + argument = (char *)mxCalloc(mxGetN(prhs[0])+1, sizeof(char)); + args = (char **)mxCalloc(maxnargs, sizeof(char *)); if (argument==NULL || args==NULL) - DYN_MEX_FUNC_ERR_MSG_TXT("Error in swz_mex: could not allocate memory. (1)"); + DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (1)"); /* * Create argument string from prhs and parse to create args / nargs */ - if (!(args[nargs] = (char *)swzCalloc(strlen(mainarg)+1, sizeof(char)))) - DYN_MEX_FUNC_ERR_MSG_TXT("Error in swz_mex: could not allocate memory. (2)"); + if (!(args[nargs] = (char *)mxCalloc(strlen(mainarg)+1, sizeof(char)))) + DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (2)"); strncpy(args[nargs++], mainarg, strlen(mainarg)); if (mxGetString(prhs[0], argument, mxGetN(prhs[0])+1)) - DYN_MEX_FUNC_ERR_MSG_TXT("Error in swz_mex: error using mxGetString.\n"); + DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: error using mxGetString.\n"); beginarg = &argument[0]; while((n=strcspn(beginarg, " "))) { - if (!(args[nargs] = (char *)swzCalloc(n+1, sizeof(char)))) - DYN_MEX_FUNC_ERR_MSG_TXT("Error in swz_mex: could not allocate memory. (3)"); + if (!(args[nargs] = (char *)mxCalloc(n+1, sizeof(char)))) + DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (3)"); strncpy(args[nargs++], beginarg, n); beginarg += (isspace(beginarg[n]) || isblank(beginarg[n]) ? ++n : n); } - swzFree(argument); + mxFree(argument); /* * Call top_level function (formerly main) @@ -93,8 +93,8 @@ mexFunction(int nlhs, mxArray *plhs[], * free memory */ for (n=0; n<nargs; n++) - swzFree(args[n]); - swzFree(args); + mxFree(args[n]); + mxFree(args); plhs[0] = mxCreateDoubleScalar(0); } diff --git a/ms-sbvar/mex/modify_for_mex.cc b/ms-sbvar/mex/modify_for_mex.cc index c7e7d20ba628bdb84607711efa6508bd31365c83..8d9cc5a466d54c12b2300e4b4fabdbeeba2ee838 100644 --- a/ms-sbvar/mex/modify_for_mex.cc +++ b/ms-sbvar/mex/modify_for_mex.cc @@ -36,7 +36,7 @@ extern "C" int constant_seed; void - swz_fprintf_err(char *str, ...) + ms_fprintf_err(char *str, ...) { va_list ap; va_start(ap, str); @@ -53,10 +53,10 @@ extern "C" void - swzExit(int status) + msExit(int status) { #if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE) - throw "Error in SWZ mex file.\n"; + throw "Error in MS-SBVAR MEX file.\n"; #else exit(status); #endif diff --git a/ms-sbvar/mex/modify_for_mex.h b/ms-sbvar/mex/modify_for_mex.h index 3c66102c896a4948b042c29586a1c2e541db8724..671ca54768e9e992f4eee2100fd7ec9fe26be7b5 100644 --- a/ms-sbvar/mex/modify_for_mex.h +++ b/ms-sbvar/mex/modify_for_mex.h @@ -20,8 +20,8 @@ #ifndef _MEXMOD #define _MEXMOD -void swz_exit(int status); -void swz_fprintf_err(const char * str, ...); +void ms_exit(int status); +void ms_fprintf_err(const char * str, ...); extern int constant_seed; #endif @@ -34,10 +34,10 @@ extern int constant_seed; #include <dynlapack.h> #include <mat.h> -#define swzMalloc mxMalloc -#define swzCalloc mxCalloc -#define swzRealloc mxRealloc -#define swzFree mxFree +#define msMalloc mxMalloc +#define msCalloc mxCalloc +#define msRealloc mxRealloc +#define msFree mxFree mxArray *globalMatlabStruct; @@ -52,10 +52,10 @@ mxArray *getMxArray(double *, int, int); #else -#define swz_fprintf_stdout printf -#define swzMalloc malloc -#define swzCalloc calloc -#define swzRealloc realloc -#define swzFree free +#define ms_fprintf_stdout printf +#define msMalloc malloc +#define msCalloc calloc +#define msRealloc realloc +#define msFree free #endif diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 0cb37338a9d127de5b898f33f6452e5c88cc4d64..7d917e3555776308c56225f420173908cb790d0c 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -852,7 +852,7 @@ void SBVARStatement::writeOutput(ostream &output, const string &basename) const { options_list.writeOutput(output); - output << "swz_sbvar(0,M_,options_);" << endl; + output << "ms_sbvar(0,M_,options_);" << endl; } MS_SBVARStatement::MS_SBVARStatement(const OptionsList &options_list_arg) : @@ -870,7 +870,7 @@ void MS_SBVARStatement::writeOutput(ostream &output, const string &basename) const { options_list.writeOutput(output); - output << "swz_sbvar(1,M_,options_);" << endl; + output << "ms_sbvar(1,M_,options_);" << endl; } IdentificationStatement::IdentificationStatement(const OptionsList &options_list_arg) : diff --git a/tests/.gitignore b/tests/.gitignore index 88c873bc7062a0bd35a79bb641ef13f6ffb7e7c2..b1231b4f6ea8efa06f0e929702ddd48e65c7bfab 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -40,6 +40,7 @@ !/ls2003/data_ca1.m !/objectives/sgu_ex1.mat !/missing/simulate_data_with_missing_observations.m +!/ms-sbvar/data.m !/parallel/data_ca1.m !/pi2004/idata.m !/pi2004/ych.dat @@ -51,6 +52,5 @@ !/recursive/data_ca1.m !/run_test.m !/run_test_octave.m -!/swz/data.m !/test.m !/fs2000_ssfile_aux.m