Commit 0ee09b5b authored by sebastien's avatar sebastien
Browse files

v4.1: merged r2044, 2045 and 2046 changesets from 4.0 branch


git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@2047 ac1d8469-bf42-47a9-8791-bf33cf982152
parent fa0a9f27
......@@ -31,8 +31,6 @@ function CutSample(M_, options_, estim_params_)
% 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_ options_ estim_params_
npar = estim_params_.np+estim_params_.nvn+estim_params_.ncx+estim_params_.ncn+estim_params_.nvx;
DirectoryName = CheckPath('metropolis');
......@@ -50,7 +48,7 @@ else
end
TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8)
MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
FirstDraw = max(1,floor(options_.mh_drop*TotalNumberOfMhDraws));
FirstMhFile = ceil(FirstDraw/MAX_nruns);
FirstLine = FirstDraw-(FirstMhFile-1)*MAX_nruns+1;
......
......@@ -32,8 +32,6 @@ function oo_ = GetPosteriorParametersStatistics(estim_params_, M_, options_, bay
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global estim_params_ M_ options_ bayestopt_ oo_
%if ~options_.mh_replic & options_.load_mh_file
% load([M_.fname '_results.mat'],'oo_');
%end
......@@ -53,7 +51,7 @@ OutputDirectoryName = CheckPath('Output');
load([ DirectoryName '/' M_.fname '_mh_history'])
FirstMhFile = record.KeepedDraws.FirstMhFile;
FirstLine = record.KeepedDraws.FirstLine;
TotalNumberOfMhFiles = sum(record.MhDraws(:,2))
TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
FirstMhFile = record.KeepedDraws.FirstMhFile;
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
......
......@@ -33,8 +33,6 @@ 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/>.
global estim_params_ M_ options_ bayestopt_ oo_
OutputDirectoryName = CheckPath('Output');
TeX = options_.TeX;
......
......@@ -33,7 +33,7 @@ function varlist = check_list_of_variables(options_, M_, varlist)
if isempty(varlist)
disp(' ')
disp(['You did not declared endogenous variables after the estimation command.'])
disp(['You did not declare endogenous variables after the estimation command.'])
cas = [];
if options_.bayesian_irf
cas = 'Posterior IRFs';
......
......@@ -198,7 +198,6 @@ while ~done
end
wall3=badg3;
% g3
badg3
save g3.mat g3 x3 f3 varargin;
%ARGLIST
%save g3 g3 x3 f3 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13;
......@@ -219,17 +218,17 @@ while ~done
end
%how to pick gh and xh
if f3 < f - crit & badg3==0
ih=3
ih=3;
fh=f3;xh=x3;gh=g3;badgh=badg3;retcodeh=retcode3;
elseif f2 < f - crit & badg2==0
ih=2
ih=2;
fh=f2;xh=x2;gh=g2;badgh=badg2;retcodeh=retcode2;
elseif f1 < f - crit & badg1==0
ih=1
ih=1;
fh=f1;xh=x1;gh=g1;badgh=badg1;retcodeh=retcode1;
else
[fh,ih] = min([f1,f2,f3]);
disp(sprintf('ih = %d',ih))
%disp(sprintf('ih = %d',ih))
%eval(['xh=x' num2str(ih) ';'])
switch ih
case 1
......
......@@ -276,7 +276,7 @@ else% if the steady state file is not provided.
oo_.steady_state = dd.ys; clear('dd');
end
if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)
disp('no constant')
disp('No constant.')
options_.noconstant = 1;
else
options_.noconstant = 0;
......@@ -924,7 +924,7 @@ if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ...
McMCDiagnostics(options_, estim_params_, M_);
end
%% Here i discard first half of the draws:
CutSample;
CutSample(M_, options_, estim_params_);
%% Estimation of the marginal density from the Mh draws:
if options_.mh_replic
[marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_);
......@@ -934,7 +934,6 @@ if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ...
%% Results are saved (in case of an anormal exit from dynare or matlab)...
%%save([M_.fname '_results.mat'],'oo_','M_');
%%
oo_
oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt_, oo_);
metropolis_draw(1);
if options_.bayesian_irf
......@@ -978,7 +977,7 @@ if (~((any(bayestopt_.pshape > 0) & options_.mh_replic) | (any(bayestopt_.pshape
eval(['oo_.SmoothedVariables.' deblank(M_.endo_names(dr.order_var(i),:)) ' = atT(i,:)'';']);
eval(['oo_.FilteredVariables.' deblank(M_.endo_names(dr.order_var(i),:)) ' = squeeze(aK(1,i,:))'';']);
eval(['oo_.UpdatedVariables.' deblank(M_.endo_names(dr.order_var(i),:)) ...
' = updated variables(i,:)'';']);
' = updated_variables(i,:)'';']);
end
[nbplt,nr,nc,lr,lc,nstar] = pltorg(M_.exo_nbr);
if options_.TeX
......
......@@ -63,12 +63,12 @@ if ~options_.load_mh_file & ~options_.mh_recover
files = dir([ MhDirectoryName '/' ModelName '_mh*_blck*.mat']);
if length(files)
delete([ MhDirectoryName '/' ModelName '_mh*_blck*.mat']);
disp('MH: Old _mh files succesfully erased!')
disp('MH: Old _mh files successfully erased!')
end
file = dir([ MhDirectoryName '/metropolis.log']);
if length(file)
delete([ MhDirectoryName '/metropolis.log']);
disp('MH: Old metropolis.log file succesfully erased!')
disp('MH: Old metropolis.log file successfully erased!')
disp('MH: Creation of a new metropolis.log file.')
end
fidlog = fopen([MhDirectoryName '/metropolis.log'],'w');
......@@ -150,7 +150,7 @@ if ~options_.load_mh_file & ~options_.mh_recover
file = dir([MhDirectoryName '/' ModelName '_mh_history.mat']);
if length(files)
delete([ MhDirectoryName '/' ModelName '_mh_history.mat']);
disp('MH: Old mh_history file succesfully erased!')
disp('MH: Old mh_history file successfully erased!')
end
AnticipatedNumberOfFiles = ceil(nruns(1)/MAX_nruns);
AnticipatedNumberOfLinesInTheLastFile = nruns(1) - (AnticipatedNumberOfFiles-1)*MAX_nruns;
......
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