Commit fa1f7794 authored by Johannes Pfeifer's avatar Johannes Pfeifer
Browse files

Delete stale files from previous MCMC runs

Closes #566. Also adds cosmetic changes to headers of affected routines
parent 3bcb89bd
......@@ -16,7 +16,7 @@ function PosteriorIRF(type)
% functions associated with it(the _core1 and _core2).
% See also the comments random_walk_metropolis_hastings.m funtion.
% Copyright (C) 2006-2013 Dynare Team
% Copyright (C) 2006-2015 Dynare Team
%
% This file is part of Dynare.
%
......@@ -93,8 +93,15 @@ elseif strcmpi(type,'gsa')
else
MhDirectoryName = CheckPath('prior',M_.dname);
end
delete([MhDirectoryName filesep M_.fname '_IRF_DSGEs*.mat']);
delete([MhDirectoryName filesep M_.fname '_IRF_BVARDSGEs*.mat']);
%delete old stale files before creating new ones
delete_stale_file([MhDirectoryName filesep M_.fname '_IRF_DSGEs*.mat']);
delete_stale_file([MhDirectoryName filesep M_.fname '_IRF_BVARDSGEs*.mat']);
delete_stale_file([MhDirectoryName filesep M_.fname '_irf_dsge*.mat']);
delete_stale_file([MhDirectoryName filesep M_.fname '_irf_bvardsge*.mat']);
delete_stale_file([MhDirectoryName filesep M_.fname '_param_irf*.mat']);
if strcmpi(type,'posterior')
B = options_.sub_draws;
options_.B = B;
......@@ -112,16 +119,7 @@ else% type = 'prior'
B = options_.prior_draws;
options_.B = B;
end
try
delete([MhDirectoryName filesep M_.fname '_irf_dsge*.mat'])
catch
disp('No _IRFs (dsge) files to be deleted!')
end
try
delete([MhDirectoryName filesep M_.fname '_irf_bvardsge*.mat'])
catch
disp('No _IRFs (bvar-dsge) files to be deleted!')
end
irun = 0;
IRUN = 0;
irun2 = 0;
......
function oo_ = ...
conditional_variance_decomposition_mc_analysis(NumberOfSimulations, type, dname, fname, Steps, exonames, exo, var_list, endogenous_variable_index, mh_conf_sig, oo_)
% This function analyses the (posterior or prior) distribution of the
% endogenous conditional variance decomposition.
% endogenous variables' conditional variance decomposition.
%
% INPUTS
% NumberOfSimulations [integer] scalar, number of simulations.
% type [string] 'prior' or 'posterior'
% dname [string] directory name where to save
% fname [string] name of the mod-file
% Steps [integers] horizons at which to conduct decomposition
% exonames [string] (n_exo*char_length) character array with names of exogenous variables
% exo [string] name of current exogenous
% variable
% var_list [string] (n_endo*char_length) character array with name
% of endogenous variables
% endogenous_variable_index [integer] index of the current
% endogenous variable
% mh_conf_sig [double] 2 by 1 vector with upper
% and lower bound of HPD intervals
% oo_ [structure] Dynare structure where the results are saved.
%
% OUTPUTS
% oo_ [structure] Dynare structure where the results are saved.
% Copyright (C) 2009-2013 Dynare Team
%
......
function oo_ = covariance_mc_analysis(NumberOfSimulations,type,dname,fname,vartan,nvar,var1,var2,mh_conf_sig,oo_)
% This function analyses the (posterior or prior) distribution of the
% endogenous variables covariance matrix.
% endogenous variables' covariance matrix.
%
% INPUTS
% NumberOfSimulations [integer] scalar, number of simulations.
% type [string] 'prior' or 'posterior'
% dname [string] directory name where to save
% fname [string] name of the mod-file
% vartan [char] array of characters (with nvar rows).
% nvar [integer] nvar is the number of stationary variables.
% var1 [string] name of the first variable
% var2 [string] name of the second variable
% mh_conf_sig [double] 2 by 1 vector with upper
% and lower bound of HPD intervals
% oo_ [structure] Dynare structure where the results are saved.
%
% OUTPUTS
% oo_ [structure] Dynare structure where the results are saved.
% Copyright (C) 2008-2013 Dynare Team
% Copyright (C) 2008-2015 Dynare Team
%
% This file is part of Dynare.
%
......
function [nvar,vartan,NumberOfConditionalDecompFiles] = ...
dsge_simulated_theoretical_conditional_variance_decomposition(SampleSize,Steps,M_,options_,oo_,type)
% function [nvar,vartan,NumberOfConditionalDecompFiles] = ...
% dsge_simulated_theoretical_conditional_variance_decomposition(SampleSize,Steps,M_,options_,oo_,type)
% This function computes the posterior or prior distribution of the conditional variance
% decomposition of the endogenous variables (or a subset of the endogenous variables).
%
% INPUTS
% SampleSize [integer] scalar, number of simulations.
% Steps [integers] horizons at which to conduct decomposition
% M_ [structure] Dynare structure describing the model.
% options_ [structure] Dynare structure defining global options.
% oo_ [structure] Dynare structure where the results are saved.
......@@ -16,7 +19,7 @@ function [nvar,vartan,NumberOfConditionalDecompFiles] = ...
% vartan [char] array of characters (with nvar rows).
% NumberOfConditionalDecompFiles [integer] scalar, number of prior or posterior data files (for covariance).
% Copyright (C) 2009-2012 Dynare Team
% Copyright (C) 2009-2015 Dynare Team
%
% This file is part of Dynare.
%
......@@ -47,6 +50,13 @@ else
error()
end
%delete old stale files before creating new ones
if posterior
delete_stale_file([M_.dname '/metropolis/' M_.fname '_PosteriorConditionalVarianceDecomposition*'])
else
delete_stale_file([M_.dname '/prior/moments/' M_.fname '_PriorConditionalVarianceDecomposition*'])
end
% Set varlist (vartan)
if ~posterior
if isfield(options_,'varlist')
......
function [nvar,vartan,CorrFileNumber] = dsge_simulated_theoretical_correlation(SampleSize,nar,M_,options_,oo_,type)
% function [nvar,vartan,CorrFileNumber] = dsge_simulated_theoretical_correlation(SampleSize,nar,M_,options_,oo_,type)
% This function computes the posterior or prior distribution of the endogenous
% variables second order moments.
% variables' second order moments.
%
% INPUTS
% SampleSize [integer]
% nar [integer]
% M_ [structure]
% options_ [structure]
% oo_ [structure]
% type [string]
% SampleSize [integer] scalar, number of simulations.
% nar [integer] maximum number of autocorrelations to
% consider
% M_ [structure] Dynare structure describing the model.
% options_ [structure] Dynare structure defining global options
% oo_ [structure] Dynare structure where the results are saved.
% type [string] 'prior' or 'posterior'
%
% OUTPUTS
% nvar [integer]
% vartan [char]
% CorrFileNumber [integer]
% Copyright (C) 2007-2012 Dynare Team
% nvar [integer] nvar is the number of stationary variables.
% vartan [char] array of characters (with nvar rows).
% CorrFileNumber [integer] scalar, number of prior or posterior data files (for correlation).
% Copyright (C) 2007-2015 Dynare Team
%
% This file is part of Dynare.
%
......@@ -48,6 +50,13 @@ else
end
NumberOfDrawsFiles = length(DrawsFiles);
%delete old stale files before creating new ones
if posterior
delete_stale_file([M_.dname '/metropolis/' M_.fname '_PosteriorCorrelations*']);
else
delete_stale_file([M_.dname '/prior/moments/' M_.fname '_PriorCorrelations*']);
end
% Set varlist (vartan)
if ~posterior
if isfield(options_,'varlist')
......
function [nvar,vartan,CovarFileNumber] = dsge_simulated_theoretical_covariance(SampleSize,M_,options_,oo_,type)
% function [nvar,vartan,CovarFileNumber] = dsge_simulated_theoretical_covariance(SampleSize,M_,options_,oo_,type)
% This function computes the posterior or prior distribution of the endogenous
% variables second order moments.
%
......@@ -15,7 +16,7 @@ function [nvar,vartan,CovarFileNumber] = dsge_simulated_theoretical_covariance(S
% vartan [char] array of characters (with nvar rows).
% CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance).
% Copyright (C) 2007-2012 Dynare Team
% Copyright (C) 2007-2015 Dynare Team
%
% This file is part of Dynare.
%
......@@ -48,6 +49,13 @@ else
end
NumberOfDrawsFiles = length(DrawsFiles);
%delete old stale files before creating new ones
if posterior
delete_stale_file([M_.dname '/metropolis/' M_.fname '_Posterior2ndOrderMoments*'])
else
delete_stale_file([M_.dname '/prior/moments/' M_.fname '_Prior2ndOrderMoments*'])
end
% Set varlist (vartan)
if ~posterior
if isfield(options_,'varlist')
......
function [nvar,vartan,NumberOfDecompFiles] = ...
dsge_simulated_theoretical_variance_decomposition(SampleSize,M_,options_,oo_,type)
% function [nvar,vartan,NumberOfDecompFiles] = ...
% dsge_simulated_theoretical_variance_decomposition(SampleSize,M_,options_,oo_,type)
% This function computes the posterior or prior distribution of the variance
% decomposition of the observed endogenous variables.
%
......@@ -16,7 +18,7 @@ function [nvar,vartan,NumberOfDecompFiles] = ...
% vartan [char] array of characters (with nvar rows).
% CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance).
% Copyright (C) 2007-2012 Dynare Team
% Copyright (C) 2007-2015 Dynare Team
%
% This file is part of Dynare.
%
......@@ -47,7 +49,13 @@ else
disp('dsge_simulated_theoretical_variance_decomposition:: Unknown type!')
error()
end
NumberOfDrawsFiles = length(DrawsFiles);
%delete old stale files before creating new ones
if posterior
delete_stale_file([M_.dname '/metropolis/' M_.fname '_PosteriorVarianceDecomposition*']);
else
delete_stale_file([M_.dname '/prior/moments/' M_.fname '_PosteriorVarianceDecomposition*']);
end
% Set varlist (vartan)
if ~posterior
......
function delete_stale_file(fname)
% function delete_old_files(fname)
% Checks for presence of files and deletes them if necessary
% Copyright (C) 2015 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/>.
Files_info = dir(fname);
if length(Files_info)>0
delete(fname)
end
function oo_ = variance_decomposition_mc_analysis(NumberOfSimulations,type,dname,fname,exonames,exo,vartan,var,mh_conf_sig,oo_)
% function oo_ = variance_decomposition_mc_analysis(NumberOfSimulations,type,dname,fname,exonames,exo,vartan,var,mh_conf_sig,oo_)
% This function analyses the (posterior or prior) distribution of the
% endogenous variance decomposition.
% endogenous variables' variance decomposition.
%
% INPUTS
% NumberOfSimulations [integer] scalar, number of simulations.
% type [string] 'prior' or 'posterior'
% dname [string] directory name where to save
% fname [string] name of the mod-file
% exonames [string] (n_exo*char_length) character array with names of exogenous variables
% exo [string] name of current exogenous
% variable
% vartan [string] (n_endo*char_length) character array with name
% of endogenous variables
% var [integer] index of the current
% endogenous variable
% mh_conf_sig [double] 2 by 1 vector with upper
% and lower bound of HPD intervals
% oo_ [structure] Dynare structure where the results are saved.
%
% OUTPUTS
% oo_ [structure] Dynare structure where the results are saved.
% Copyright (C) 2008-2013 Dynare Team
%
......
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