From 7408714ea19fb86e3469b7ac0038b8b7f4f4de02 Mon Sep 17 00:00:00 2001 From: Michel Juillard <michel.juillard@mjui.fr> Date: Thu, 15 Dec 2011 11:56:23 +0100 Subject: [PATCH] added dname as argument to CheckPath function and changed all calls to this function. Suppressed use of globals in CheckPath. --- matlab/CheckPath.m | 15 +++++++-------- matlab/CutSample.m | 2 +- matlab/GetAllPosteriorDraws.m | 2 +- matlab/GetPosteriorParametersStatistics.m | 4 ++-- matlab/McMCDiagnostics.m | 4 ++-- matlab/McMCDiagnostics_core.m | 2 +- matlab/PlotPosteriorDistributions.m | 2 +- matlab/PosteriorFilterSmootherAndForecast.m | 4 ++-- matlab/PosteriorIRF.m | 12 ++++++------ matlab/PosteriorIRF_core1.m | 8 ++++---- matlab/PosteriorIRF_core2.m | 2 +- matlab/ReshapeMatFiles.m | 14 +++++++------- matlab/check_prior_analysis_data.m | 2 +- matlab/compute_mh_covariance_matrix.m | 2 +- ...eoretical_conditional_variance_decomposition.m | 2 +- matlab/dsge_simulated_theoretical_correlation.m | 2 +- matlab/dsge_simulated_theoretical_covariance.m | 2 +- ...simulated_theoretical_variance_decomposition.m | 2 +- matlab/dynare_estimation_1.m | 2 +- matlab/dynare_identification.m | 2 +- matlab/dynare_sensitivity.m | 8 ++++---- matlab/get_name_of_the_last_mh_file.m | 2 +- matlab/gsa/filt_mc_.m | 6 +++--- matlab/gsa/gsa_plotmatrix.m | 2 +- matlab/ident_bruteforce.m | 2 +- matlab/independent_metropolis_hastings_core.m | 2 +- matlab/marginal_density.m | 2 +- matlab/metropolis_draw.m | 2 +- matlab/metropolis_hastings_initialization.m | 2 +- matlab/mh_autocorrelation_function.m | 2 +- matlab/pm3_core.m | 2 +- matlab/prior_posterior_statistics.m | 10 +++++----- matlab/prior_posterior_statistics_core.m | 8 ++++---- matlab/prior_sampler.m | 2 +- matlab/random_walk_metropolis_hastings_core.m | 2 +- matlab/selec_posterior_draws.m | 2 +- matlab/set_prior.m | 2 +- matlab/trace_plot.m | 2 +- 38 files changed, 73 insertions(+), 74 deletions(-) diff --git a/matlab/CheckPath.m b/matlab/CheckPath.m index fdaa2dd3ae..4513c3b8a2 100644 --- a/matlab/CheckPath.m +++ b/matlab/CheckPath.m @@ -1,8 +1,9 @@ -function DirectoryName = CheckPath(type) +function DirectoryName = CheckPath(type,dname) % Creates the subfolder "./M_.dname/type" if it does not exist yet. % % INPUTS -% type [string] Name of the subfolder. +% type [string] Name of the subfolder. +% dname [string] Name of the directory % % OUTPUTS % none. @@ -27,14 +28,12 @@ function DirectoryName = CheckPath(type) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -global M_ +DirectoryName = [ dname '/' type ]; -DirectoryName = [ M_.dname '/' type ]; - -if ~isdir(M_.dname) +if ~isdir(dname) % Make sure there isn't a file with the same name, see trac ticket #47 - delete(M_.dname) - mkdir('.', M_.dname); + delete(dname) + mkdir('.', dname); end if ~isdir(DirectoryName) diff --git a/matlab/CutSample.m b/matlab/CutSample.m index 18595631c9..7beb9993d6 100644 --- a/matlab/CutSample.m +++ b/matlab/CutSample.m @@ -33,7 +33,7 @@ function CutSample(M_, options_, estim_params_) npar = estim_params_.np+estim_params_.nvn+estim_params_.ncx+estim_params_.ncn+estim_params_.nvx; -DirectoryName = CheckPath('metropolis'); +DirectoryName = CheckPath('metropolis',M_.dname); file = dir([ DirectoryName ,filesep, M_.fname '_mh_history.mat']); files = dir([ DirectoryName ,filesep, M_.fname '_mh*.mat' ]); if ~length(files) diff --git a/matlab/GetAllPosteriorDraws.m b/matlab/GetAllPosteriorDraws.m index 49bb8a9944..3a3a489ecb 100644 --- a/matlab/GetAllPosteriorDraws.m +++ b/matlab/GetAllPosteriorDraws.m @@ -39,7 +39,7 @@ nblck = options_.mh_nblck; iline = FirstLine; linee = 1; -DirectoryName = CheckPath('metropolis'); +DirectoryName = CheckPath('metropolis',M_.dname); if nblck>1 && nargin<6 Draws = zeros(NumberOfDraws*nblck,1); diff --git a/matlab/GetPosteriorParametersStatistics.m b/matlab/GetPosteriorParametersStatistics.m index 3d69fd49fb..3df62968b9 100644 --- a/matlab/GetPosteriorParametersStatistics.m +++ b/matlab/GetPosteriorParametersStatistics.m @@ -45,8 +45,8 @@ ncn = estim_params_.ncn; np = estim_params_.np ; nx = nvx+nvn+ncx+ncn+np; -DirectoryName = CheckPath('metropolis'); -OutputDirectoryName = CheckPath('Output'); +DirectoryName = CheckPath('metropolis',M_.dname); +OutputDirectoryName = CheckPath('Output',M_.dname); load([ DirectoryName '/' M_.fname '_mh_history']) FirstMhFile = record.KeepedDraws.FirstMhFile; diff --git a/matlab/McMCDiagnostics.m b/matlab/McMCDiagnostics.m index 29ffc96184..de8974f048 100644 --- a/matlab/McMCDiagnostics.m +++ b/matlab/McMCDiagnostics.m @@ -33,8 +33,8 @@ function McMCDiagnostics(options_, estim_params_, M_) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -DirectoryName = CheckPath('Output'); -MhDirectoryName = CheckPath('metropolis'); +DirectoryName = CheckPath('Output',M_.dname); +MhDirectoryName = CheckPath('metropolis',M_.dname); TeX = options_.TeX; nblck = options_.mh_nblck; diff --git a/matlab/McMCDiagnostics_core.m b/matlab/McMCDiagnostics_core.m index 0c398703dc..540c322e6f 100644 --- a/matlab/McMCDiagnostics_core.m +++ b/matlab/McMCDiagnostics_core.m @@ -56,7 +56,7 @@ if whoiam Parallel=myinputs.Parallel; end if ~exist('MhDirectoryName'), - MhDirectoryName = CheckPath('metropolis'); + MhDirectoryName = CheckPath('metropolis',M_.dname); end ALPHA = 0.2; % increase too much with the number of simulations. diff --git a/matlab/PlotPosteriorDistributions.m b/matlab/PlotPosteriorDistributions.m index 53de1924a3..b0daaf69b2 100644 --- a/matlab/PlotPosteriorDistributions.m +++ b/matlab/PlotPosteriorDistributions.m @@ -33,7 +33,7 @@ function oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -OutputDirectoryName = CheckPath('Output'); +OutputDirectoryName = CheckPath('Output',M_.dname); TeX = options_.TeX; nblck = options_.mh_nblck; diff --git a/matlab/PosteriorFilterSmootherAndForecast.m b/matlab/PosteriorFilterSmootherAndForecast.m index 7836974d89..4cce1159e5 100644 --- a/matlab/PosteriorFilterSmootherAndForecast.m +++ b/matlab/PosteriorFilterSmootherAndForecast.m @@ -55,8 +55,8 @@ i_last_obs = gend+(1-M_.maximum_endo_lag:0); horizon = options_.forecast; maxlag = M_.maximum_endo_lag; %% -CheckPath('Plots/'); -DirectoryName = CheckPath('metropolis'); +CheckPath('Plots/',M_.dname); +DirectoryName = CheckPath('metropolis',M_.dname); load([ DirectoryName '/' M_.fname '_mh_history.mat']) FirstMhFile = record.KeepedDraws.FirstMhFile; FirstLine = record.KeepedDraws.FirstLine; diff --git a/matlab/PosteriorIRF.m b/matlab/PosteriorIRF.m index fdbf101417..c70b05f82a 100644 --- a/matlab/PosteriorIRF.m +++ b/matlab/PosteriorIRF.m @@ -76,17 +76,17 @@ else MAX_nirfs_dsgevar = 0; end -DirectoryName = CheckPath('Output'); +DirectoryName = CheckPath('Output',M_.dname); if strcmpi(type,'posterior') - MhDirectoryName = CheckPath('metropolis'); + MhDirectoryName = CheckPath('metropolis',M_.dname); elseif strcmpi(type,'gsa') if options_.opt_gsa.pprior - MhDirectoryName = CheckPath(['GSA' filesep 'prior']); + MhDirectoryName = CheckPath(['GSA' filesep 'prior'],M_.dname); else - MhDirectoryName = CheckPath(['GSA' filesep 'mc']); + MhDirectoryName = CheckPath(['GSA' filesep 'mc'],M_.dname); end else - MhDirectoryName = CheckPath('prior'); + MhDirectoryName = CheckPath('prior',M_.dname); end delete([MhDirectoryName filesep M_.fname '_IRF_DSGEs*.mat']); delete([MhDirectoryName filesep M_.fname '_IRF_BVARDSGEs*.mat']); @@ -95,7 +95,7 @@ if strcmpi(type,'posterior') TotalNumberOfMhDraws = sum(record.MhDraws(:,1)); NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws); elseif strcmpi(type,'gsa') - RootDirectoryName = CheckPath('gsa'); + RootDirectoryName = CheckPath('gsa',M_.dname); if options_.opt_gsa.pprior load([ RootDirectoryName filesep M_.fname '_prior.mat'],'lpmat0','lpmat','istable') else diff --git a/matlab/PosteriorIRF_core1.m b/matlab/PosteriorIRF_core1.m index 068ecb2a0a..861772d752 100644 --- a/matlab/PosteriorIRF_core1.m +++ b/matlab/PosteriorIRF_core1.m @@ -84,15 +84,15 @@ end % MhDirectoryName = myinputs.MhDirectoryName; if strcmpi(type,'posterior') - MhDirectoryName = CheckPath('metropolis'); + MhDirectoryName = CheckPath('metropolis',M_.dname); elseif strcmpi(type,'gsa') if options_.opt_gsa.pprior - MhDirectoryName = CheckPath(['gsa' filesep 'prior']); + MhDirectoryName = CheckPath(['gsa' filesep 'prior'],M_.dname); else - MhDirectoryName = CheckPath(['gsa' filesep 'mc']); + MhDirectoryName = CheckPath(['gsa' filesep 'mc'],M_.dname); end else - MhDirectoryName = CheckPath('prior'); + MhDirectoryName = CheckPath('prior',M_.dname); end RemoteFlag = 0; diff --git a/matlab/PosteriorIRF_core2.m b/matlab/PosteriorIRF_core2.m index c1f1a81898..d2f27b691c 100644 --- a/matlab/PosteriorIRF_core2.m +++ b/matlab/PosteriorIRF_core2.m @@ -69,7 +69,7 @@ end % To save the figures where the function is computed! -DirectoryName = CheckPath('Output'); +DirectoryName = CheckPath('Output',M_.dname); RemoteFlag = 0; if whoiam, diff --git a/matlab/ReshapeMatFiles.m b/matlab/ReshapeMatFiles.m index 6ed8f1f2a6..fc99e4afbb 100644 --- a/matlab/ReshapeMatFiles.m +++ b/matlab/ReshapeMatFiles.m @@ -45,22 +45,22 @@ function ReshapeMatFiles(type, type2) global M_ options_ if nargin==1, - MhDirectoryName = [ CheckPath('metropolis') filesep ]; + MhDirectoryName = [ CheckPath('metropolis',M_.dname) filesep ]; else if strcmpi(type2,'posterior') - MhDirectoryName = [CheckPath('metropolis') filesep ]; + MhDirectoryName = [CheckPath('metropolis',M_.dname) filesep ]; elseif strcmpi(type2,'gsa') if options_.opt_gsa.morris==1, - MhDirectoryName = [CheckPath('gsa/screen') filesep ]; + MhDirectoryName = [CheckPath('gsa/screen',M_.dname) filesep ]; elseif options_.opt_gsa.morris==2, - MhDirectoryName = [CheckPath('gsa/identif') filesep ]; + MhDirectoryName = [CheckPath('gsa/identif',M_.dname) filesep ]; elseif options_.opt_gsa.pprior - MhDirectoryName = [CheckPath(['gsa' filesep 'prior']) filesep ]; + MhDirectoryName = [CheckPath(['gsa' filesep 'prior'],M_.dname) filesep ]; else - MhDirectoryName = [CheckPath(['gsa' filesep 'mc']) filesep ]; + MhDirectoryName = [CheckPath(['gsa' filesep 'mc'],M_.dname) filesep ]; end else - MhDirectoryName = [CheckPath('prior') filesep ]; + MhDirectoryName = [CheckPath('prior',M_.dname) filesep ]; end end switch type diff --git a/matlab/check_prior_analysis_data.m b/matlab/check_prior_analysis_data.m index 2afff80984..e60d586d28 100644 --- a/matlab/check_prior_analysis_data.m +++ b/matlab/check_prior_analysis_data.m @@ -68,7 +68,7 @@ switch type otherwise disp(['This feature is not yet implemented!']) end -CheckPath('prior/moments'); +CheckPath('prior/moments',M_.dname); pdfinfo = dir([ M_.dname '/prior/' generic_prior_data_file_name '*']); if isempty(pdfinfo) info = 4; diff --git a/matlab/compute_mh_covariance_matrix.m b/matlab/compute_mh_covariance_matrix.m index 9c2949b728..90c4a5e9d7 100644 --- a/matlab/compute_mh_covariance_matrix.m +++ b/matlab/compute_mh_covariance_matrix.m @@ -42,7 +42,7 @@ n = estim_params_.np + ... estim_params_.nvx; nblck = options_.mh_nblck; -MhDirectoryName = CheckPath('metropolis'); +MhDirectoryName = CheckPath('metropolis',M_.dname); load([ MhDirectoryName '/' M_.fname '_mh_history.mat']) FirstMhFile = record.KeepedDraws.FirstMhFile; diff --git a/matlab/dsge_simulated_theoretical_conditional_variance_decomposition.m b/matlab/dsge_simulated_theoretical_conditional_variance_decomposition.m index 7f53a8eb06..60c9aaf9f5 100644 --- a/matlab/dsge_simulated_theoretical_conditional_variance_decomposition.m +++ b/matlab/dsge_simulated_theoretical_conditional_variance_decomposition.m @@ -40,7 +40,7 @@ if strcmpi(type,'posterior') posterior = 1; elseif strcmpi(type,'prior') DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]); - CheckPath('prior/moments'); + CheckPath('prior/moments',M_.dname); posterior = 0; else disp('dsge_simulated_theoretical_conditional_variance_decomposition:: Unknown type!') diff --git a/matlab/dsge_simulated_theoretical_correlation.m b/matlab/dsge_simulated_theoretical_correlation.m index 2e4c751ff3..d8a81a149c 100644 --- a/matlab/dsge_simulated_theoretical_correlation.m +++ b/matlab/dsge_simulated_theoretical_correlation.m @@ -40,7 +40,7 @@ if strcmpi(type,'posterior') posterior = 1; elseif strcmpi(type,'prior') DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]); - CheckPath('prior/moments'); + CheckPath('prior/moments',M_.dname); posterior = 0; else disp('dsge_simulated_theoretical_correlation:: Unknown type!'); diff --git a/matlab/dsge_simulated_theoretical_covariance.m b/matlab/dsge_simulated_theoretical_covariance.m index c4fe83bb6c..1231b8b586 100644 --- a/matlab/dsge_simulated_theoretical_covariance.m +++ b/matlab/dsge_simulated_theoretical_covariance.m @@ -40,7 +40,7 @@ if strcmpi(type,'posterior') posterior = 1; elseif strcmpi(type,'prior') DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]); - CheckPath('prior/moments'); + CheckPath('prior/moments',M_.dname); posterior = 0; else disp('dsge_simulated_theoretical_covariance:: Unknown type!') diff --git a/matlab/dsge_simulated_theoretical_variance_decomposition.m b/matlab/dsge_simulated_theoretical_variance_decomposition.m index cf7d1297f6..a4008b31ab 100644 --- a/matlab/dsge_simulated_theoretical_variance_decomposition.m +++ b/matlab/dsge_simulated_theoretical_variance_decomposition.m @@ -41,7 +41,7 @@ if strcmpi(type,'posterior') posterior = 1; elseif strcmpi(type,'prior') DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]); - CheckPath('prior/moments'); + CheckPath('prior/moments',M_.dname); posterior = 0; else disp('dsge_simulated_theoretical_variance_decomposition:: Unknown type!') diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index 108b0dcdd6..0f8837171f 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -567,7 +567,7 @@ elseif ~any(bayestopt_.pshape > 0) && options_.mh_posterior_mode_estimation end -OutputDirectoryName = CheckPath('Output'); +OutputDirectoryName = CheckPath('Output',M_.dname); if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior mode) Latex output if np diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m index 2a621b90fd..b60ffec943 100644 --- a/matlab/dynare_identification.m +++ b/matlab/dynare_identification.m @@ -158,7 +158,7 @@ if ~(exist('sylvester3mr','file')==2), addpath([dynareroot 'gensylv']) end -IdentifDirectoryName = CheckPath('identification'); +IdentifDirectoryName = CheckPath('identification',M_.dname); if prior_exist, indx = []; diff --git a/matlab/dynare_sensitivity.m b/matlab/dynare_sensitivity.m index 691a953d9f..a832a87afc 100644 --- a/matlab/dynare_sensitivity.m +++ b/matlab/dynare_sensitivity.m @@ -136,12 +136,12 @@ if options_gsa.morris==1 || options_gsa.morris==3, options_gsa.ksstat=1; if options_gsa.morris==3, options_gsa = set_default_option(options_gsa,'Nsam',256); - OutputDirectoryName = CheckPath('gsa/identif'); + OutputDirectoryName = CheckPath('gsa/identif',M_.dname); else - OutputDirectoryName = CheckPath('gsa/screen'); + OutputDirectoryName = CheckPath('gsa/screen',M_.dname); end else - OutputDirectoryName = CheckPath('gsa'); + OutputDirectoryName = CheckPath('gsa',M_.dname); end options_.opt_gsa = options_gsa; @@ -281,7 +281,7 @@ if options_gsa.glue, dr_ = oo_.dr; if options_gsa.ppost load([OutputDirectoryName,'/',fname_,'_post']); - DirectoryName = CheckPath('metropolis'); + DirectoryName = CheckPath('metropolis',M_.dname); else if options_gsa.pprior load([OutputDirectoryName,'/',fname_,'_prior']); diff --git a/matlab/get_name_of_the_last_mh_file.m b/matlab/get_name_of_the_last_mh_file.m index 77368a5de7..c3f39e6a64 100644 --- a/matlab/get_name_of_the_last_mh_file.m +++ b/matlab/get_name_of_the_last_mh_file.m @@ -31,7 +31,7 @@ function [mhname,info] = get_name_of_the_last_mh_file(M_) mhname = []; info = 1; -MhDirectoryName = CheckPath('metropolis'); +MhDirectoryName = CheckPath('metropolis',M_.dname); load([ MhDirectoryName '/' M_.fname '_mh_history.mat']) ; mh_number = record.LastFileNumber ; diff --git a/matlab/gsa/filt_mc_.m b/matlab/gsa/filt_mc_.m index c1e5650b9c..5fb84cfbff 100644 --- a/matlab/gsa/filt_mc_.m +++ b/matlab/gsa/filt_mc_.m @@ -93,14 +93,14 @@ end if options_.opt_gsa.ppost, fnamtmp=[fname_,'_post']; - DirectoryName = CheckPath('metropolis'); + DirectoryName = CheckPath('metropolis',M_.dname); else if options_.opt_gsa.pprior fnamtmp=[fname_,'_prior']; - DirectoryName = CheckPath(['gsa' filesep 'prior']); + DirectoryName = CheckPath(['gsa' filesep 'prior'],M_.dname); else fnamtmp=[fname_,'_mc']; - DirectoryName = CheckPath(['gsa' filesep 'mc']); + DirectoryName = CheckPath(['gsa' filesep 'mc'],M_.dname); end end if ~loadSA, diff --git a/matlab/gsa/gsa_plotmatrix.m b/matlab/gsa/gsa_plotmatrix.m index dfbd8790e3..1309e875a2 100644 --- a/matlab/gsa/gsa_plotmatrix.m +++ b/matlab/gsa/gsa_plotmatrix.m @@ -21,7 +21,7 @@ function gsa_plotmatrix(type,varargin) global bayestopt_ options_ M_ -RootDirectoryName = CheckPath('gsa'); +RootDirectoryName = CheckPath('gsa',M_.dname); if options_.opt_gsa.pprior load([ RootDirectoryName filesep M_.fname '_prior.mat'],'lpmat0','lpmat','istable','iunstable','iindeterm','iwrong') diff --git a/matlab/ident_bruteforce.m b/matlab/ident_bruteforce.m index 4be84c1c64..93b7a5c58f 100644 --- a/matlab/ident_bruteforce.m +++ b/matlab/ident_bruteforce.m @@ -27,7 +27,7 @@ function [pars, cosnJ] = ident_bruteforce(J,n,TeX, pnames_TeX) % along with Dynare. If not, see <http://www.gnu.org/licen global M_ options_ -OutputDirectoryName = CheckPath('Identification'); +OutputDirectoryName = CheckPath('Identification',M_.dname); k = size(J,2); % number of parameters diff --git a/matlab/independent_metropolis_hastings_core.m b/matlab/independent_metropolis_hastings_core.m index f4aecb4696..af62a5338e 100644 --- a/matlab/independent_metropolis_hastings_core.m +++ b/matlab/independent_metropolis_hastings_core.m @@ -71,7 +71,7 @@ end % (re)Set the penalty. bayestopt_.penalty = Inf; -MhDirectoryName = CheckPath('metropolis'); +MhDirectoryName = CheckPath('metropolis',M_.dname); OpenOldFile = ones(nblck,1); if strcmpi(ProposalFun,'rand_multivariate_normal') diff --git a/matlab/marginal_density.m b/matlab/marginal_density.m index e423ea807d..2bb23e7372 100644 --- a/matlab/marginal_density.m +++ b/matlab/marginal_density.m @@ -36,7 +36,7 @@ function [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_) npar = estim_params_.np+estim_params_.nvn+estim_params_.ncx+estim_params_.ncn+estim_params_.nvx; nblck = options_.mh_nblck; -MhDirectoryName = CheckPath('metropolis'); +MhDirectoryName = CheckPath('metropolis',M_.dname); load([ MhDirectoryName '/' M_.fname '_mh_history.mat']) FirstMhFile = record.KeepedDraws.FirstMhFile; diff --git a/matlab/metropolis_draw.m b/matlab/metropolis_draw.m index eb8e8e150f..86fce488ec 100644 --- a/matlab/metropolis_draw.m +++ b/matlab/metropolis_draw.m @@ -39,7 +39,7 @@ if init ncn = estim_params_.ncn; np = estim_params_.np ; npar = nvx+nvn+ncx+ncn+np; - MhDirectoryName = CheckPath('metropolis'); + MhDirectoryName = CheckPath('metropolis',M_.dname); fname = [ MhDirectoryName '/' M_.fname]; load([ fname '_mh_history']); FirstMhFile = record.KeepedDraws.FirstMhFile; diff --git a/matlab/metropolis_hastings_initialization.m b/matlab/metropolis_hastings_initialization.m index 9ddcd2f797..80c2f3532a 100644 --- a/matlab/metropolis_hastings_initialization.m +++ b/matlab/metropolis_hastings_initialization.m @@ -56,7 +56,7 @@ end bayestopt_.penalty = 1e8; -MhDirectoryName = CheckPath('metropolis'); +MhDirectoryName = CheckPath('metropolis',M_.dname); nblck = options_.mh_nblck; nruns = ones(nblck,1)*options_.mh_replic; diff --git a/matlab/mh_autocorrelation_function.m b/matlab/mh_autocorrelation_function.m index 446a567010..a77506578b 100644 --- a/matlab/mh_autocorrelation_function.m +++ b/matlab/mh_autocorrelation_function.m @@ -47,7 +47,7 @@ if isempty(column) end % Get informations about the posterior draws: -DirectoryName = CheckPath('metropolis'); +DirectoryName = CheckPath('metropolis',M_.dname); try load([DirectoryName '/' M_.fname '_mh_history.mat']); catch diff --git a/matlab/pm3_core.m b/matlab/pm3_core.m index 11090b9416..7cfb3f6cbe 100644 --- a/matlab/pm3_core.m +++ b/matlab/pm3_core.m @@ -96,7 +96,7 @@ for i=fpar:nvar if whoiam, if Parallel(ThisMatlab).Local==0 - DirectoryName = CheckPath('Output'); + DirectoryName = CheckPath('Output',M_.dname); end end diff --git a/matlab/prior_posterior_statistics.m b/matlab/prior_posterior_statistics.m index 6ae0a3e55a..9c6cffcf0d 100644 --- a/matlab/prior_posterior_statistics.m +++ b/matlab/prior_posterior_statistics.m @@ -69,7 +69,7 @@ end maxlag = M_.maximum_endo_lag; %% if strcmpi(type,'posterior') - DirectoryName = CheckPath('metropolis'); + DirectoryName = CheckPath('metropolis',M_.dname); load([ DirectoryName '/' M_.fname '_mh_history']) FirstMhFile = record.KeepedDraws.FirstMhFile; FirstLine = record.KeepedDraws.FirstLine; @@ -86,12 +86,12 @@ if strcmpi(type,'posterior') B = min(1200, round(0.25*NumberOfDraws)); end elseif strcmpi(type,'gsa') - RootDirectoryName = CheckPath('gsa'); + RootDirectoryName = CheckPath('gsa',M_.dname); if options_.opt_gsa.pprior - DirectoryName = CheckPath(['gsa',filesep,'prior']); + DirectoryName = CheckPath(['gsa',filesep,'prior'],M_.dname); load([ RootDirectoryName filesep M_.fname '_prior.mat'],'lpmat0','lpmat','istable') else - DirectoryName = CheckPath(['gsa',filesep,'mc']); + DirectoryName = CheckPath(['gsa',filesep,'mc'],M_.dname); load([ RootDirectoryName filesep M_.fname '_mc.mat'],'lpmat0','lpmat','istable') end x=[lpmat0(istable,:) lpmat(istable,:)]; @@ -99,7 +99,7 @@ elseif strcmpi(type,'gsa') NumberOfDraws=size(x,1); B=NumberOfDraws; elseif strcmpi(type,'prior') - DirectoryName = CheckPath('prior'); + DirectoryName = CheckPath('prior',M_.dname); if ~isempty(options_.subdraws) B = options_.subdraws; else diff --git a/matlab/prior_posterior_statistics_core.m b/matlab/prior_posterior_statistics_core.m index 1c3349e4f3..7787829dbb 100644 --- a/matlab/prior_posterior_statistics_core.m +++ b/matlab/prior_posterior_statistics_core.m @@ -97,15 +97,15 @@ end % DirectoryName = myinputs.DirectoryName; if strcmpi(type,'posterior') - DirectoryName = CheckPath('metropolis'); + DirectoryName = CheckPath('metropolis',M_.dname); elseif strcmpi(type,'gsa') if options_.opt_gsa.pprior - DirectoryName = CheckPath(['gsa',filesep,'prior']); + DirectoryName = CheckPath(['gsa',filesep,'prior'],M_.dname); else - DirectoryName = CheckPath(['gsa',filesep,'mc']); + DirectoryName = CheckPath(['gsa',filesep,'mc'],M_.dname); end elseif strcmpi(type,'prior') - DirectoryName = CheckPath('prior'); + DirectoryName = CheckPath('prior',M_.dname); end RemoteFlag = 0; diff --git a/matlab/prior_sampler.m b/matlab/prior_sampler.m index 36ba42bdd5..ff7c1e8cff 100644 --- a/matlab/prior_sampler.m +++ b/matlab/prior_sampler.m @@ -32,7 +32,7 @@ function results = prior_sampler(drsave,M_,bayestopt_,options_,oo_) % Initialization. prior_draw(1); -PriorDirectoryName = CheckPath('prior/draws'); +PriorDirectoryName = CheckPath('prior/draws',M_.dname); work = ~drsave; iteration = 0; loop_indx = 0; diff --git a/matlab/random_walk_metropolis_hastings_core.m b/matlab/random_walk_metropolis_hastings_core.m index 398984b549..1898d478ab 100644 --- a/matlab/random_walk_metropolis_hastings_core.m +++ b/matlab/random_walk_metropolis_hastings_core.m @@ -103,7 +103,7 @@ end % (re)Set the penalty bayestopt_.penalty = Inf; -MhDirectoryName = CheckPath('metropolis'); +MhDirectoryName = CheckPath('metropolis',M_.dname); options_.lik_algo = 1; OpenOldFile = ones(nblck,1); diff --git a/matlab/selec_posterior_draws.m b/matlab/selec_posterior_draws.m index d1b60fb389..59f0fe07a7 100644 --- a/matlab/selec_posterior_draws.m +++ b/matlab/selec_posterior_draws.m @@ -63,7 +63,7 @@ switch nargin end % Get informations about the mcmc: -MhDirectoryName = CheckPath('metropolis'); +MhDirectoryName = CheckPath('metropolis',M_.dname); fname = [ MhDirectoryName '/' M_.fname]; load([ fname '_mh_history.mat']); FirstMhFile = record.KeepedDraws.FirstMhFile; diff --git a/matlab/set_prior.m b/matlab/set_prior.m index ffc1bdaa81..2d3f453444 100644 --- a/matlab/set_prior.m +++ b/matlab/set_prior.m @@ -263,7 +263,7 @@ if options_.initialize_estimated_parameters_with_the_prior_mode end % I create subfolder M_.dname/prior if needed. -CheckPath('prior'); +CheckPath('prior',M_.dname); % I save the prior definition if the prior has changed. if exist([ M_.dname '/prior/definition.mat']) diff --git a/matlab/trace_plot.m b/matlab/trace_plot.m index fb8d6f5f95..588eadb91a 100644 --- a/matlab/trace_plot.m +++ b/matlab/trace_plot.m @@ -46,7 +46,7 @@ if isempty(column) end % Get informations about the posterior draws: -DirectoryName = CheckPath('metropolis'); +DirectoryName = CheckPath('metropolis',M_.dname); try load([DirectoryName '/' M_.fname '_mh_history.mat']); catch -- GitLab