Use cells of strings instead of char arrays.

time-shift
Stéphane Adjemian (Scylla) 2017-10-10 10:05:59 +02:00 committed by Stéphane Adjemian (Charybdis)
parent 2be12bd50d
commit 7be8f10e0e
188 changed files with 2024 additions and 2181 deletions

View File

@ -17,7 +17,7 @@ global M_
% read out parameters to access them with their name % read out parameters to access them with their name
NumberOfParameters = M_.param_nbr; NumberOfParameters = M_.param_nbr;
for ii = 1:NumberOfParameters for ii = 1:NumberOfParameters
paramname = deblank(M_.param_names(ii,:)); paramname = M_.param_names{ii};
eval([ paramname ' = M_.params(' int2str(ii) ');']); eval([ paramname ' = M_.params(' int2str(ii) ');']);
end end
% initialize indicator % initialize indicator
@ -96,11 +96,11 @@ g2=epsilon/(epsilon-1)*g1;
%% end own model equations %% end own model equations
for iter = 1:length(M_.params) %update parameters set in the file for iter = 1:length(M_.params) %update parameters set in the file
eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names(iter,:) ';' ]) eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names{iter} ';' ])
end end
NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables for ii = 1:NumberOfEndogenousVariables
varname = deblank(M_.endo_names(ii,:)); varname = M_.endo_names{ii};
eval(['ys(' int2str(ii) ') = ' varname ';']); eval(['ys(' int2str(ii) ') = ' varname ';']);
end end

View File

@ -8,7 +8,7 @@ function oo_ = GetPosteriorParametersStatistics(estim_params_, M_, options_, bay
% options_ [structure] % options_ [structure]
% bayestopt_ [structure] % bayestopt_ [structure]
% oo_ [structure] % oo_ [structure]
% pnames [char] Array of char, names of the prior shapes available % pnames [cell] cell of strings, names of the prior shapes available
% %
% OUTPUTS % OUTPUTS
% oo_ [structure] % oo_ [structure]
@ -16,7 +16,7 @@ function oo_ = GetPosteriorParametersStatistics(estim_params_, M_, options_, bay
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% None. % None.
% Copyright (C) 2006-2017 Dynare Team % Copyright (C) 2006-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -60,7 +60,7 @@ FirstMhFile = record.KeepedDraws.FirstMhFile;
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws); NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
clear record; clear record;
header_width = row_header_width(M_,estim_params_,bayestopt_); header_width = row_header_width(M_, estim_params_, bayestopt_);
hpd_interval=[num2str(options_.mh_conf_sig*100), '% HPD interval']; hpd_interval=[num2str(options_.mh_conf_sig*100), '% HPD interval'];
tit2 = sprintf('%-*s %12s %12s %23s %8s %12s\n',header_width,' ','prior mean','post. mean',hpd_interval,'prior','pstdev'); tit2 = sprintf('%-*s %12s %12s %23s %8s %12s\n',header_width,' ','prior mean','post. mean',hpd_interval,'prior','pstdev');
pformat = '%-*s %12.3f % 12.4f %11.4f %11.4f %7s %12.4f'; pformat = '%-*s %12.3f % 12.4f %11.4f %11.4f %7s %12.4f';
@ -70,23 +70,26 @@ disp('ESTIMATION RESULTS')
skipline() skipline()
try try
disp(sprintf('Log data density is %f.',oo_.MarginalDensity.ModifiedHarmonicMean)) disp(sprintf('Log data density is %f.', oo_.MarginalDensity.ModifiedHarmonicMean))
catch catch
[marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_, bayestopt_); [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_, bayestopt_);
disp(sprintf('Log data density is %f.',oo_.MarginalDensity.ModifiedHarmonicMean)) disp(sprintf('Log data density is %f.', oo_.MarginalDensity.ModifiedHarmonicMean))
end end
num_draws=NumberOfDraws*options_.mh_nblck; num_draws=NumberOfDraws*options_.mh_nblck;
hpd_draws = round((1-options_.mh_conf_sig)*num_draws); hpd_draws = round((1-options_.mh_conf_sig)*num_draws);
if hpd_draws<2 if hpd_draws<2
fprintf('posterior_moments: There are not enough draws computes to compute HPD Intervals. Skipping their computation.\n') fprintf('posterior_moments: There are not enough draws computes to compute HPD Intervals. Skipping their computation.\n')
end end
if num_draws<9 if num_draws<9
fprintf('posterior_moments: There are not enough draws computes to compute deciles. Skipping their computation.\n') fprintf('posterior_moments: There are not enough draws computes to compute deciles. Skipping their computation.\n')
end end
if np if np
type = 'parameters'; type = 'parameters';
if TeX if TeX
fid = TeXBegin(OutputFolder,M_.fname,1,type); fid = TeXBegin(OutputFolder, M_.fname, 1, type);
end end
skipline() skipline()
disp(type) disp(type)
@ -94,44 +97,42 @@ if np
ip = nvx+nvn+ncx+ncn+1; ip = nvx+nvn+ncx+ncn+1;
for i=1:np for i=1:np
if options_.mh_replic if options_.mh_replic
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws); Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, ... [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
density] = posterior_moments(Draws,1,options_.mh_conf_sig);
name = bayestopt_.name{ip}; name = bayestopt_.name{ip};
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density); oo_ = Filloo(oo_, name, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
else else
try try
name = bayestopt_.name{ip}; name = bayestopt_.name{ip};
[post_mean,hpd_interval,post_var] = Extractoo(oo_,name,type); [post_mean, hpd_interval, post_var] = Extractoo(oo_, name, type);
catch catch
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws); Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, ... [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
density] = posterior_moments(Draws,1,options_.mh_conf_sig);
name = bayestopt_.name{ip}; name = bayestopt_.name{ip};
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density); oo_ = Filloo(oo_, name, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
end end
end end
disp(sprintf(pformat,header_width,name,bayestopt_.p1(ip),... disp(sprintf(pformat, header_width, name, bayestopt_.p1(ip),...
post_mean, ... post_mean, ...
hpd_interval, ... hpd_interval, ...
pnames(bayestopt_.pshape(ip)+1,:), ... pnames{bayestopt_.pshape(ip)+1}, ...
bayestopt_.p2(ip))); bayestopt_.p2(ip)));
if TeX if TeX
k = estim_params_.param_vals(i,1); k = estim_params_.param_vals(i,1);
name = deblank(M_.param_names_tex(k,:)); name = M_.param_names_tex{k};
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),... TeXCore(fid, name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval);
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
end end
ip = ip+1; ip = ip+1;
end end
if TeX if TeX
TeXEnd(fid,1,type); TeXEnd(fid, 1, type);
end end
end end
if nvx if nvx
type = 'shocks_std'; type = 'shocks_std';
if TeX if TeX
fid = TeXBegin(OutputFolder,FileName,2,'standard deviation of structural shocks'); fid = TeXBegin(OutputFolder, FileName,2, 'standard deviation of structural shocks');
end end
ip = 1; ip = 1;
skipline() skipline()
@ -139,45 +140,43 @@ if nvx
disp(tit2) disp(tit2)
for i=1:nvx for i=1:nvx
if options_.mh_replic if options_.mh_replic
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws); Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ... [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
posterior_moments(Draws,1,options_.mh_conf_sig);
k = estim_params_.var_exo(i,1); k = estim_params_.var_exo(i,1);
name = deblank(M_.exo_names(k,:)); name = M_.exo_names{k};
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density); oo_ = Filloo(oo_, name, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
M_.Sigma_e(k,k) = post_mean*post_mean; M_.Sigma_e(k,k) = post_mean*post_mean;
else else
try try
k = estim_params_.var_exo(i,1); k = estim_params_.var_exo(i,1);
name = deblank(M_.exo_names(k,:)); name = M_.exo_names{k};
[post_mean,hpd_interval,post_var] = Extractoo(oo_,name,type); [post_mean, hpd_interval, post_var] = Extractoo(oo_, name, type);
catch catch
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws); Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ... [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ...
posterior_moments(Draws,1,options_.mh_conf_sig); posterior_moments(Draws, 1, options_.mh_conf_sig);
k = estim_params_.var_exo(i,1); k = estim_params_.var_exo(i,1);
name = deblank(M_.exo_names(k,:)); name = M_.exo_names{k};
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density); oo_ = Filloo(oo_, name, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
M_.Sigma_e(k,k) = post_mean*post_mean; M_.Sigma_e(k,k) = post_mean*post_mean;
end end
end end
disp(sprintf(pformat,header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval,... disp(sprintf(pformat,header_width,name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip)));
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX if TeX
name = deblank(M_.exo_names_tex(k,:)); name = M_.exo_names_tex{k};
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),... TeXCore(fid,name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval);
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
end end
ip = ip+1; ip = ip+1;
end end
if TeX if TeX
TeXEnd(fid,2,'standard deviation of structural shocks'); TeXEnd(fid, 2, 'standard deviation of structural shocks');
end end
end end
if nvn if nvn
type = 'measurement_errors_std'; type = 'measurement_errors_std';
if TeX if TeX
fid = TeXBegin(OutputFolder,FileName,3,'standard deviation of measurement errors'); fid = TeXBegin(OutputFolder, FileName, 3, 'standard deviation of measurement errors');
end end
skipline() skipline()
disp('standard deviation of measurement errors') disp('standard deviation of measurement errors')
@ -185,37 +184,34 @@ if nvn
ip = nvx+1; ip = nvx+1;
for i=1:nvn for i=1:nvn
if options_.mh_replic if options_.mh_replic
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws); Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ... [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
posterior_moments(Draws,1,options_.mh_conf_sig);
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)}; name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density); oo_ = Filloo(oo_, name, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
else else
try try
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)}; name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
[post_mean,hpd_interval,post_var] = Extractoo(oo_,name,type); [post_mean,hpd_interval,post_var] = Extractoo(oo_,name,type);
catch catch
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws); Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ... [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws,1,options_.mh_conf_sig);
posterior_moments(Draws,1,options_.mh_conf_sig);
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)}; name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density); oo_ = Filloo(oo_,name,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density);
end end
end end
disp(sprintf(pformat,header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval, ... disp(sprintf(pformat, header_width, name,bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip)));
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX if TeX
k = estim_params_.var_endo(i,1); k = estim_params_.var_endo(i,1);
name = deblank(M_.endo_names_tex(k,:)); name = M_.endo_names_tex{k};
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),... TeXCore(fid, name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval);
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
end end
ip = ip+1; ip = ip+1;
end end
if TeX if TeX
TeXEnd(fid,3,'standard deviation of measurement errors'); TeXEnd(fid, 3, 'standard deviation of measurement errors');
end end
end end
if ncx if ncx
type = 'shocks_corr'; type = 'shocks_corr';
if TeX if TeX
@ -227,53 +223,49 @@ if ncx
ip = nvx+nvn+1; ip = nvx+nvn+1;
for i=1:ncx for i=1:ncx
if options_.mh_replic if options_.mh_replic
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws); Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ... [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws,1,options_.mh_conf_sig);
posterior_moments(Draws,1,options_.mh_conf_sig);
k1 = estim_params_.corrx(i,1); k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2); k2 = estim_params_.corrx(i,2);
name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))]; name = sprintf('%s,%s', M_.exo_names{k1}, M_.exo_names{k2});
NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))]; NAME = sprintf('%s_%s', M_.exo_names{k1}, M_.exo_names{k2});
oo_ = Filloo(oo_,NAME,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density); oo_ = Filloo(oo_, NAME, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
M_.Sigma_e(k1,k2) = post_mean*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2)); M_.Sigma_e(k1,k2) = post_mean*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2); M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
else else
try try
k1 = estim_params_.corrx(i,1); k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2); k2 = estim_params_.corrx(i,2);
name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))]; name = sprintf('%s,%s', M_.exo_names{k1}, M_.exo_names{k2});
NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))]; NAME = sprintf('%s_%s', M_.exo_names{k1}, M_.exo_names{k2});
[post_mean,hpd_interval,post_var] = Extractoo(oo_,NAME,type); [post_mean,hpd_interval,post_var] = Extractoo(oo_, NAME, type);
catch catch
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws); Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ... [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
posterior_moments(Draws,1,options_.mh_conf_sig);
k1 = estim_params_.corrx(i,1); k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2); k2 = estim_params_.corrx(i,2);
name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))]; name = sprintf('%s,%s', M_.exo_names{k1}, M_.exo_names{k2});
NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))]; NAME = sprintf('%s_%s', M_.exo_names{k1}, M_.exo_names{k2});
oo_ = Filloo(oo_,NAME,type,post_mean,hpd_interval,post_median,post_var,post_deciles,density); oo_ = Filloo(oo_, NAME, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
M_.Sigma_e(k1,k2) = post_mean*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2)); M_.Sigma_e(k1,k2) = post_mean*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2); M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
end end
end end
disp(sprintf(pformat, header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval, ... disp(sprintf(pformat, header_width,name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip)));
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX if TeX
name = ['(',deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:)),')']; name = sprintf('(%s,%s)', M_.exo_names_tex{k1}, M_.exo_names_tex{k2});
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),... TeXCore(fid, name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval);
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
end end
ip = ip+1; ip = ip+1;
end end
if TeX if TeX
TeXEnd(fid,4,'correlation of structural shocks'); TeXEnd(fid, 4, 'correlation of structural shocks');
end end
end end
if ncn if ncn
type = 'measurement_errors_corr'; type = 'measurement_errors_corr';
if TeX if TeX
fid = TeXBegin(OutputFolder,FileName,5,'correlation of measurement errors'); fid = TeXBegin(OutputFolder, FileName, 5, 'correlation of measurement errors');
end end
skipline() skipline()
disp('correlation of measurement errors') disp('correlation of measurement errors')
@ -282,44 +274,38 @@ if ncn
for i=1:ncn for i=1:ncn
if options_.mh_replic if options_.mh_replic
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws); Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ... [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
posterior_moments(Draws,1,options_.mh_conf_sig);
k1 = estim_params_.corrn(i,1); k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2); k2 = estim_params_.corrn(i,2);
name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))]; name = sprintf('%s,%s', M_.endo_names{k1}, M_.endo_names{k2});
NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))]; NAME = sprintf('%s_%s', M_.endo_names{k1}, M_.endo_names{k2});
oo_ = Filloo(oo_,NAME,type,post_mean,hpd_interval,... oo_ = Filloo(oo_, NAME, type, post_mean, hpd_interval, post_median, post_var, post_deciles,density);
post_median,post_var,post_deciles,density);
else else
try try
k1 = estim_params_.corrn(i,1); k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2); k2 = estim_params_.corrn(i,2);
name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))]; name = sprintf('%s,%s', M_.endo_names{k1}, M_.endo_names{k2});
NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))]; NAME = sprintf('%s_%s', M_.endo_names{k1}, M_.endo_names{k2});
[post_mean,hpd_interval,post_var] = Extractoo(oo_,NAME,type); [post_mean,hpd_interval,post_var] = Extractoo(oo_, NAME, type);
catch catch
Draws = GetAllPosteriorDraws(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws); Draws = GetAllPosteriorDraws(ip, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws);
[post_mean, post_median, post_var, hpd_interval, post_deciles, density] = ... [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(Draws, 1, options_.mh_conf_sig);
posterior_moments(Draws,1,options_.mh_conf_sig);
k1 = estim_params_.corrn(i,1); k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2); k2 = estim_params_.corrn(i,2);
name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))]; name = sprintf('%s,%s', M_.endo_names{k1}, M_.endo_names{k2});
NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))]; NAME = sprintf('%s_%s', M_.endo_names{k1}, M_.endo_names{k2});
oo_ = Filloo(oo_,NAME,type,post_mean,hpd_interval,... oo_ = Filloo(oo_, NAME, type, post_mean, hpd_interval, post_median, post_var, post_deciles, density);
post_median,post_var,post_deciles,density);
end end
end end
disp(sprintf(pformat, header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval, ... disp(sprintf(pformat, header_width, name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip)));
pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
if TeX if TeX
name = ['(',deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:)),')']; name = sprintf('(%s,%s)', M_.endo_names_tex{k1}, M_.endo_names_tex{k2});
TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),... TeXCore(fid, name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval);
bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
end end
ip = ip+1; ip = ip+1;
end end
if TeX if TeX
TeXEnd(fid,5,'correlation of measurement errors'); TeXEnd(fid, 5, 'correlation of measurement errors');
end end
end end
@ -327,57 +313,57 @@ end
% %
%% subfunctions: %% subfunctions:
% %
function fid = TeXBegin(directory,fname,fnum,title) function fid = TeXBegin(directory, fname, fnum, title)
TeXfile = [directory '/' fname '_Posterior_Mean_' int2str(fnum) '.tex']; TeXfile = [directory '/' fname '_Posterior_Mean_' int2str(fnum) '.tex'];
fidTeX = fopen(TeXfile,'w'); fidTeX = fopen(TeXfile,'w');
fprintf(fidTeX,'%% TeX-table generated by Dynare.\n'); fprintf(fidTeX, '%% TeX-table generated by Dynare.\n');
fprintf(fidTeX,['%% RESULTS FROM METROPOLIS HASTINGS (' title ')\n']); fprintf(fidTeX, ['%% RESULTS FROM METROPOLIS HASTINGS (' title ')\n']);
fprintf(fidTeX,['%% ' datestr(now,0)]); fprintf(fidTeX, ['%% ' datestr(now, 0)]);
fprintf(fidTeX,' \n'); fprintf(fidTeX, ' \n');
fprintf(fidTeX,' \n'); fprintf(fidTeX, ' \n');
fprintf(fidTeX,'\\begin{center}\n'); fprintf(fidTeX, '\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{llcccccc} \n'); fprintf(fidTeX, '\\begin{longtable}{llcccccc} \n');
fprintf(fidTeX,['\\caption{Results from Metropolis-Hastings (' title ')}\n ']); fprintf(fidTeX, ['\\caption{Results from Metropolis-Hastings (' title ')}\n ']);
fprintf(fidTeX,['\\label{Table:MHPosterior:' int2str(fnum) '}\\\\\n']); fprintf(fidTeX, ['\\label{Table:MHPosterior:' int2str(fnum) '}\\\\\n']);
fprintf(fidTeX,'\\toprule \n'); fprintf(fidTeX, '\\toprule \n');
fprintf(fidTeX,' & \\multicolumn{3}{c}{Prior} & \\multicolumn{4}{c}{Posterior} \\\\\n'); fprintf(fidTeX, ' & \\multicolumn{3}{c}{Prior} & \\multicolumn{4}{c}{Posterior} \\\\\n');
fprintf(fidTeX,' \\cmidrule(r{.75em}){2-4} \\cmidrule(r{.75em}){5-8}\n'); fprintf(fidTeX, ' \\cmidrule(r{.75em}){2-4} \\cmidrule(r{.75em}){5-8}\n');
fprintf(fidTeX,' & Dist. & Mean & Stdev. & Mean & Stdev. & HPD inf & HPD sup\\\\\n'); fprintf(fidTeX, ' & Dist. & Mean & Stdev. & Mean & Stdev. & HPD inf & HPD sup\\\\\n');
fprintf(fidTeX,'\\midrule \\endfirsthead \n'); fprintf(fidTeX, '\\midrule \\endfirsthead \n');
fprintf(fidTeX,['\\caption{(continued)}\\\\']); fprintf(fidTeX, ['\\caption{(continued)}\\\\']);
fprintf(fidTeX,'\\toprule \n'); fprintf(fidTeX, '\\toprule \n');
fprintf(fidTeX,' & \\multicolumn{3}{c}{Prior} & \\multicolumn{4}{c}{Posterior} \\\\\n'); fprintf(fidTeX, ' & \\multicolumn{3}{c}{Prior} & \\multicolumn{4}{c}{Posterior} \\\\\n');
fprintf(fidTeX,' \\cmidrule(r{.75em}){2-4} \\cmidrule(r{.75em}){5-8}\n'); fprintf(fidTeX, ' \\cmidrule(r{.75em}){2-4} \\cmidrule(r{.75em}){5-8}\n');
fprintf(fidTeX,' & Dist. & Mean & Stdev. & Mean & Stdev. & HPD inf & HPD sup\\\\\n'); fprintf(fidTeX, ' & Dist. & Mean & Stdev. & Mean & Stdev. & HPD inf & HPD sup\\\\\n');
fprintf(fidTeX,'\\midrule \\endhead \n'); fprintf(fidTeX, '\\midrule \\endhead \n');
fprintf(fidTeX,'\\bottomrule \\multicolumn{8}{r}{(Continued on next page)} \\endfoot \n'); fprintf(fidTeX, '\\bottomrule \\multicolumn{8}{r}{(Continued on next page)} \\endfoot \n');
fprintf(fidTeX,'\\bottomrule \\endlastfoot \n'); fprintf(fidTeX, '\\bottomrule \\endlastfoot \n');
fid = fidTeX; fid = fidTeX;
function TeXCore(fid,name,shape,priormean,priorstd,postmean,poststd,hpd) function TeXCore(fid, name, shape, priormean, priorstd, postmean, poststd, hpd)
fprintf(fid,['$%s$ & %s & %7.3f & %6.4f & %7.3f& %6.4f & %7.4f & %7.4f \\\\ \n'],... fprintf(fid,['$%s$ & %s & %7.3f & %6.4f & %7.3f& %6.4f & %7.4f & %7.4f \\\\ \n'],...
name,... name, ...
shape,... shape, ...
priormean,... priormean, ...
priorstd,... priorstd, ...
postmean,... postmean, ...
poststd,... poststd, ...
hpd(1),... hpd(1), ...
hpd(2)); hpd(2));
function TeXEnd(fid,fnum,title) function TeXEnd(fid, fnum, title)
fprintf(fid,'\\end{longtable}\n '); fprintf(fid, '\\end{longtable}\n ');
fprintf(fid,'\\end{center}\n'); fprintf(fid, '\\end{center}\n');
fprintf(fid,'%% End of TeX file.\n'); fprintf(fid, '%% End of TeX file.\n');
fclose(fid); fclose(fid);
function oo = Filloo(oo,name,type,postmean,hpdinterval,postmedian,postvar,postdecile,density) function oo = Filloo(oo, name, type, postmean, hpdinterval, postmedian, postvar, postdecile, density)
oo.posterior_mean.(type).(name) = postmean; oo.posterior_mean.(type).(name) = postmean;
oo.posterior_hpdinf.(type).(name) = hpdinterval(1); oo.posterior_hpdinf.(type).(name) = hpdinterval(1);
oo.posterior_hpdsup.(type).(name) = hpdinterval(2); oo.posterior_hpdsup.(type).(name) = hpdinterval(2);
@ -387,7 +373,7 @@ oo.posterior_std.(type).(name) = sqrt(postvar);
oo.posterior_deciles.(type).(name) = postdecile; oo.posterior_deciles.(type).(name) = postdecile;
oo.posterior_density.(type).(name) = density; oo.posterior_density.(type).(name) = density;
function [post_mean,hpd_interval,post_var] = Extractoo(oo,name,type) function [post_mean,hpd_interval,post_var] = Extractoo(oo, name, type)
hpd_interval = zeros(2,1); hpd_interval = zeros(2,1);
post_mean = oo.posterior_mean.(type).(name); post_mean = oo.posterior_mean.(type).(name);
hpd_interval(1) = oo.posterior_hpdinf.(type).(name); hpd_interval(1) = oo.posterior_hpdinf.(type).(name);

View File

@ -16,7 +16,7 @@ function oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2005-2017 Dynare Team % Copyright (C) 2005-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -63,24 +63,24 @@ for i=1:npar
subplotnum = subplotnum+1; subplotnum = subplotnum+1;
if subplotnum == 1 if subplotnum == 1
figunumber = figunumber+1; figunumber = figunumber+1;
hfig=dyn_figure(options_.nodisplay,'Name',figurename); hfig=dyn_figure(options_.nodisplay, 'Name', figurename);
end end
[nam,texnam] = get_the_name(i,TeX,M_,estim_params_,options_); [nam,texnam] = get_the_name(i, TeX, M_, estim_params_, options_);
if subplotnum == 1 if subplotnum == 1
NAMES = nam; NAMES = {nam};
if TeX if TeX
TeXNAMES = texnam; TeXNAMES = {texnam};
end end
else else
NAMES = char(NAMES,nam); NAMES = [NAMES; {nam}];
if TeX if TeX
TeXNAMES = char(TeXNAMES,texnam); TeXNAMES = [TeXNAMES; {texnam}];
end end
end end
[x2,f2,abscissa,dens,binf2,bsup2] = draw_prior_density(i,bayestopt_); [x2, f2, abscissa, dens, binf2, bsup2] = draw_prior_density(i, bayestopt_);
top2 = max(f2); top2 = max(f2);
if i <= nvx if i <= nvx
name = deblank(M_.exo_names(estim_params_.var_exo(i,1),:)); name = M_.exo_names{estim_params_.var_exo(i,1)};
x1 = oo_.posterior_density.shocks_std.(name)(:,1); x1 = oo_.posterior_density.shocks_std.(name)(:,1);
f1 = oo_.posterior_density.shocks_std.(name)(:,2); f1 = oo_.posterior_density.shocks_std.(name)(:,2);
oo_.prior_density.shocks_std.(name)(:,1) = x2; oo_.prior_density.shocks_std.(name)(:,1) = x2;
@ -101,7 +101,7 @@ for i=1:npar
j = i - (nvx+nvn); j = i - (nvx+nvn);
k1 = estim_params_.corrx(j,1); k1 = estim_params_.corrx(j,1);
k2 = estim_params_.corrx(j,2); k2 = estim_params_.corrx(j,2);
name = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))]; name = sprintf('%s_%s', M_.exo_names{k1}, M_.exo_names{k2});
x1 = oo_.posterior_density.shocks_corr.(name)(:,1); x1 = oo_.posterior_density.shocks_corr.(name)(:,1);
f1 = oo_.posterior_density.shocks_corr.(name)(:,2); f1 = oo_.posterior_density.shocks_corr.(name)(:,2);
oo_.prior_density.shocks_corr.(name)(:,1) = x2; oo_.prior_density.shocks_corr.(name)(:,1) = x2;
@ -113,7 +113,7 @@ for i=1:npar
j = i - (nvx+nvn+ncx); j = i - (nvx+nvn+ncx);
k1 = estim_params_.corrn(j,1); k1 = estim_params_.corrn(j,1);
k2 = estim_params_.corrn(j,2); k2 = estim_params_.corrn(j,2);
name = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))]; name = sprintf('%s_%s', M_.endo_names{k1}, M_.endo_names{k2});
x1 = oo_.posterior_density.measurement_errors_corr.(name)(:,1); x1 = oo_.posterior_density.measurement_errors_corr.(name)(:,1);
f1 = oo_.posterior_density.measurement_errors_corr.(name)(:,2); f1 = oo_.posterior_density.measurement_errors_corr.(name)(:,2);
oo_.prior_density.measurement_errors_corr.(name)(:,1) = x2; oo_.prior_density.measurement_errors_corr.(name)(:,1) = x2;
@ -123,7 +123,7 @@ for i=1:npar
end end
else else
j = i - (nvx+nvn+ncx+ncn); j = i - (nvx+nvn+ncx+ncn);
name = deblank(M_.param_names(estim_params_.param_vals(j,1),:)); name = M_.param_names{estim_params_.param_vals(j,1)};
x1 = oo_.posterior_density.parameters.(name)(:,1); x1 = oo_.posterior_density.parameters.(name)(:,1);
f1 = oo_.posterior_density.parameters.(name)(:,2); f1 = oo_.posterior_density.parameters.(name)(:,2);
oo_.prior_density.parameters.(name)(:,1) = x2; oo_.prior_density.parameters.(name)(:,1) = x2;
@ -133,35 +133,36 @@ for i=1:npar
end end
end end
top1 = max(f1); top1 = max(f1);
top0 = max([top1;top2]); top0 = max([top1; top2]);
binf1 = x1(1); binf1 = x1(1);
bsup1 = x1(end); bsup1 = x1(end);
borneinf = min(binf1,binf2); borneinf = min(binf1, binf2);
bornesup = max(bsup1,bsup2); bornesup = max(bsup1, bsup2);
subplot(nn,nn,subplotnum) subplot(nn, nn, subplotnum)
hh = plot(x2,f2,'-k','linewidth',2); hh = plot(x2, f2, '-k', 'linewidth', 2);
set(hh,'color',[0.7 0.7 0.7]); set(hh, 'color', [0.7 0.7 0.7]);
hold on; hold on;
plot(x1,f1,'-k','linewidth',2); plot(x1, f1, '-k', 'linewidth', 2);
if ~options_.mh_posterior_mode_estimation if ~options_.mh_posterior_mode_estimation
plot( [pmod pmod], [0.0 1.1*top0], '--g', 'linewidth', 2); plot([pmod pmod], [0.0 1.1*top0], '--g', 'linewidth', 2);
end end
box on; box on
axis([borneinf bornesup 0 1.1*top0]); axis([borneinf bornesup 0 1.1*top0])
title(nam,'Interpreter','none'); title(nam, 'Interpreter', 'none')
hold off; hold off
drawnow drawnow
if subplotnum == MaxNumberOfPlotPerFigure || i == npar if subplotnum == MaxNumberOfPlotPerFigure || i == npar
dyn_saveas(hfig,[OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber)],options_.nodisplay,options_.graph_format); dyn_saveas(hfig,[OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber)], options_.nodisplay, options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format))) if TeX && any(strcmp('eps', cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n'); fprintf(fidTeX, '\\begin{figure}[H]\n');
for j = 1:size(NAMES,1) for j = 1:size(NAMES, 1)
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(j,:)),deblank(TeXNAMES(j,:))); fprintf(fidTeX, '\\psfrag{%s}[1][][0.5][0]{%s}\n', NAMES{j}, TeXNAMES{j});
end end
fprintf(fidTeX,'\\centering\n'); fprintf(fidTeX, '\\centering\n');
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s/%s_PriorsAndPosteriors%s}\n',options_.figures.textwidth*min(subplotnum/nn,1),OutputDirectoryName,M_.fname,int2str(figunumber)); fprintf(fidTeX, '\\includegraphics[width=%2.2f\\textwidth]{%s/%s_PriorsAndPosteriors%s}\n', ...
options_.figures.textwidth*min(subplotnum/nn,1), OutputDirectoryName, M_.fname, int2str(figunumber));
fprintf(fidTeX,'\\caption{Priors and posteriors.}'); fprintf(fidTeX,'\\caption{Priors and posteriors.}');
fprintf(fidTeX,'\\label{Fig:PriorsAndPosteriors:%s}\n',int2str(figunumber)); fprintf(fidTeX,'\\label{Fig:PriorsAndPosteriors:%s}\n', int2str(figunumber));
fprintf(fidTeX,'\\end{figure}\n'); fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
if i == npar if i == npar

View File

@ -16,7 +16,7 @@ function PosteriorIRF(type)
% functions associated with it(the _core1 and _core2). % functions associated with it(the _core1 and _core2).
% See also the comments posterior_sampler.m funtion. % See also the comments posterior_sampler.m funtion.
% Copyright (C) 2006-2017 Dynare Team % Copyright (C) 2006-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -43,17 +43,17 @@ end
% Set varlist if necessary % Set varlist if necessary
varlist = options_.varlist; varlist = options_.varlist;
if isempty(varlist) if isempty(varlist)
varlist = char(options_.varobs); varlist = options_.varobs;
end end
options_.varlist = varlist; options_.varlist = varlist;
nvar = size(varlist,1); nvar = length(varlist);
IndxVariables = []; IndxVariables = [];
for i=1:nvar for i=1:nvar
idx = strmatch(deblank(varlist(i,:)),M_.endo_names,'exact'); idx = strmatch(varlist{i}, M_.endo_names, 'exact');
if isempty(idx) if isempty(idx)
disp(['PosteriorIRF :: ' deblank(varlist(i,:)) 'is not a declared endogenous variable!']) disp(['PosteriorIRF :: ' varlist{i} 'is not a declared endogenous variable!'])
else else
IndxVariables = [IndxVariables,idx]; IndxVariables = [IndxVariables, idx];
end end
end end
@ -281,17 +281,14 @@ DistribIRF = zeros(options_.irf,9,nvar,M_.exo_nbr);
HPDIRF = zeros(options_.irf,2,nvar,M_.exo_nbr); HPDIRF = zeros(options_.irf,2,nvar,M_.exo_nbr);
if options_.TeX if options_.TeX
varlist_TeX = cell(nvar, 1);
for i=1:nvar for i=1:nvar
if i==1 varlist_TeX(i) = {M_.endo_names_tex{IndxVariables(i)}};
varlist_TeX = M_.endo_names_tex(IndxVariables(i),:);
else
varlist_TeX = char(varlist_TeX,M_.endo_names_tex(IndxVariables(i),:));
end
end end
end end
fprintf('Estimation::mcmc: Posterior (dsge) IRFs...\n'); fprintf('Estimation::mcmc: Posterior (dsge) IRFs...\n');
tit(M_.exo_names_orig_ord,:) = M_.exo_names; tit(M_.exo_names_orig_ord) = M_.exo_names;
kdx = 0; kdx = 0;
for file = 1:NumberOfIRFfiles_dsge for file = 1:NumberOfIRFfiles_dsge
@ -313,7 +310,7 @@ clear STOCK_IRF_DSGE;
for i = irf_shocks_indx for i = irf_shocks_indx
for j = 1:nvar for j = 1:nvar
name = [deblank(M_.endo_names(IndxVariables(j),:)) '_' deblank(tit(i,:))]; name = sprintf('%s_%s', M_.endo_names{IndxVariables(j)}, tit{i});
oo_.PosteriorIRF.dsge.Mean.(name) = MeanIRF(:,j,i); oo_.PosteriorIRF.dsge.Mean.(name) = MeanIRF(:,j,i);
oo_.PosteriorIRF.dsge.Median.(name) = MedianIRF(:,j,i); oo_.PosteriorIRF.dsge.Median.(name) = MedianIRF(:,j,i);
oo_.PosteriorIRF.dsge.Var.(name) = VarIRF(:,j,i); oo_.PosteriorIRF.dsge.Var.(name) = VarIRF(:,j,i);
@ -331,7 +328,7 @@ if MAX_nirfs_dsgevar
DistribIRFdsgevar = zeros(options_.irf,9,nvar,M_.exo_nbr); DistribIRFdsgevar = zeros(options_.irf,9,nvar,M_.exo_nbr);
HPDIRFdsgevar = zeros(options_.irf,2,nvar,M_.exo_nbr); HPDIRFdsgevar = zeros(options_.irf,2,nvar,M_.exo_nbr);
fprintf('Estimation::mcmc: Posterior (bvar-dsge) IRFs...\n'); fprintf('Estimation::mcmc: Posterior (bvar-dsge) IRFs...\n');
tit(M_.exo_names_orig_ord,:) = M_.exo_names; tit(M_.exo_names_orig_ord) = M_.exo_names;
kdx = 0; kdx = 0;
for file = 1:NumberOfIRFfiles_dsgevar for file = 1:NumberOfIRFfiles_dsgevar
load([MhDirectoryName filesep M_.fname '_IRF_BVARDSGEs' int2str(file) '.mat']); load([MhDirectoryName filesep M_.fname '_IRF_BVARDSGEs' int2str(file) '.mat']);
@ -350,7 +347,7 @@ if MAX_nirfs_dsgevar
clear STOCK_IRF_BVARDSGE; clear STOCK_IRF_BVARDSGE;
for i = irf_shocks_indx for i = irf_shocks_indx
for j = 1:nvar for j = 1:nvar
name = [deblank(M_.endo_names(IndxVariables(j),:)) '_' deblank(tit(i,:))]; name = sprintf('%s_%s', M_.endo_names{IndxVariables(j)}, tit{i});
oo_.PosteriorIRF.bvardsge.Mean.(name) = MeanIRFdsgevar(:,j,i); oo_.PosteriorIRF.bvardsge.Mean.(name) = MeanIRFdsgevar(:,j,i);
oo_.PosteriorIRF.bvardsge.Median.(name) = MedianIRFdsgevar(:,j,i); oo_.PosteriorIRF.bvardsge.Median.(name) = MedianIRFdsgevar(:,j,i);
oo_.PosteriorIRF.bvardsge.Var.(name) = VarIRFdsgevar(:,j,i); oo_.PosteriorIRF.bvardsge.Var.(name) = VarIRFdsgevar(:,j,i);
@ -396,13 +393,13 @@ if ~options_.nograph && ~options_.no_graph.posterior
% The files .TeX are generated in sequential way always! % The files .TeX are generated in sequential way always!
subplotnum = 0; subplotnum = 0;
tit_TeX(M_.exo_names_orig_ord,:) = M_.exo_names_tex; titTeX(M_.exo_names_orig_ord) = M_.exo_names_tex;
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([DirectoryName filesep M_.fname '_BayesianIRF.tex'],'w'); fidTeX = fopen([DirectoryName filesep M_.fname '_BayesianIRF.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by PosteriorIRF.m (Dynare).\n'); fprintf(fidTeX,'%% TeX eps-loader file generated by PosteriorIRF.m (Dynare).\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']); fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
titTeX(M_.exo_names_orig_ord,:) = M_.exo_names_tex; titTeX(M_.exo_names_orig_ord) = M_.exo_names_tex;
for ii=irf_shocks_indx for ii=irf_shocks_indx
figunumber = 0; figunumber = 0;
@ -414,24 +411,23 @@ if ~options_.nograph && ~options_.no_graph.posterior
if subplotnum == 1 if subplotnum == 1
fprintf(fidTeX,'\\begin{figure}[H]\n'); fprintf(fidTeX,'\\begin{figure}[H]\n');
end end
name = deblank(varlist(jj,:)); name = varlist{jj};
texname = deblank(varlist_TeX(jj,:)); texname = varlist_TeX{jj};
fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{%s}\n'],name,['$' texname '$']); fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{%s}\n'],name,['$' texname '$']);
end end
if subplotnum == MaxNumberOfPlotPerFigure || (jj == nvar && subplotnum> 0) if subplotnum == MaxNumberOfPlotPerFigure || (jj == nvar && subplotnum> 0)
figunumber = figunumber+1; figunumber = figunumber+1;
fprintf(fidTeX,'\\centering \n'); fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s/%s_Bayesian_IRF_%s_%d}\n',options_.figures.textwidth*min(subplotnum/nn,1),DirectoryName,M_.fname,deblank(tit(ii,:)),figunumber); fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s/%s_Bayesian_IRF_%s_%d}\n',options_.figures.textwidth*min(subplotnum/nn,1),DirectoryName,M_.fname,tit{ii},figunumber);
if options_.relative_irf if options_.relative_irf
fprintf(fidTeX,['\\caption{Bayesian relative IRF.}']); fprintf(fidTeX,['\\caption{Bayesian relative IRF.}']);
else else
fprintf(fidTeX,'\\caption{Bayesian IRF: Orthogonalized shock to $%s$.}\n',deblank(tit_TeX(ii,:))); fprintf(fidTeX,'\\caption{Bayesian IRF: Orthogonalized shock to $%s$.}\n',titTeX{ii});
end end
fprintf(fidTeX,'\\label{Fig:BayesianIRF:%s:%d}\n',deblank(tit(ii,:)),figunumber); fprintf(fidTeX,'\\label{Fig:BayesianIRF:%s:%d}\n', tit{ii},figunumber);
fprintf(fidTeX,'\\end{figure}\n'); fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
subplotnum = 0; subplotnum = 0;
end end
end end
@ -445,7 +441,7 @@ if ~options_.nograph && ~options_.no_graph.posterior
% Comment for testing! % Comment for testing!
if ~isoctave if ~isoctave
if isnumeric(options_.parallel) || (M_.exo_nbr*ceil(size(varlist,1)/MaxNumberOfPlotPerFigure))<8 if isnumeric(options_.parallel) || (M_.exo_nbr*ceil(length(varlist)/MaxNumberOfPlotPerFigure))<8
[fout] = PosteriorIRF_core2(localVars,1,M_.exo_nbr,0); [fout] = PosteriorIRF_core2(localVars,1,M_.exo_nbr,0);
else else
isRemoteOctave = 0; isRemoteOctave = 0;

View File

@ -23,7 +23,7 @@ function myoutput=PosteriorIRF_core1(myinputs,fpar,B,whoiam, ThisMatlab)
% SPECIAL REQUIREMENTS. % SPECIAL REQUIREMENTS.
% None. % None.
% %
% Copyright (C) 2006-2017 Dynare Team % Copyright (C) 2006-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -195,7 +195,7 @@ while fpar<B
if MAX_nirfs_dsgevar if MAX_nirfs_dsgevar
IRUN = IRUN+1; IRUN = IRUN+1;
[fval,info,junk1,junk2,junk3,junk3,junk4,PHI,SIGMAu,iXX] = dsge_var_likelihood(deep',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_); [fval,info,junk1,junk2,junk3,junk3,junk4,PHI,SIGMAu,iXX] = dsge_var_likelihood(deep',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
dsge_prior_weight = M_.params(strmatch('dsge_prior_weight',M_.param_names)); dsge_prior_weight = M_.params(strmatch('dsge_prior_weight', M_.param_names));
DSGE_PRIOR_WEIGHT = floor(dataset_.nobs*(1+dsge_prior_weight)); DSGE_PRIOR_WEIGHT = floor(dataset_.nobs*(1+dsge_prior_weight));
SIGMA_inv_upper_chol = chol(inv(SIGMAu*dataset_.nobs*(dsge_prior_weight+1))); SIGMA_inv_upper_chol = chol(inv(SIGMAu*dataset_.nobs*(dsge_prior_weight+1)));
explosive_var = 1; explosive_var = 1;

View File

@ -30,7 +30,7 @@ function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam,ThisMatlab)
% SPECIAL REQUIREMENTS. % SPECIAL REQUIREMENTS.
% None. % None.
% %
% Copyright (C) 2006-2017 Dynare Team % Copyright (C) 2006-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -103,9 +103,9 @@ for i=fpar:npar
if max(abs(MeanIRF(:,j,i))) >= options_.impulse_responses.plot_threshold if max(abs(MeanIRF(:,j,i))) >= options_.impulse_responses.plot_threshold
subplotnum = subplotnum+1; subplotnum = subplotnum+1;
if subplotnum == 1 && options_.relative_irf if subplotnum == 1 && options_.relative_irf
hh = dyn_figure(options_.nodisplay,'Name',['Relative response to orthogonalized shock to ' tit(i,:)]); hh = dyn_figure(options_.nodisplay,'Name',['Relative response to orthogonalized shock to ' tit{i}]);
elseif subplotnum == 1 && ~options_.relative_irf elseif subplotnum == 1 && ~options_.relative_irf
hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit(i,:)]); hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit{i}]);
end end
set(0,'CurrentFigure',hh) set(0,'CurrentFigure',hh)
@ -142,17 +142,17 @@ for i=fpar:npar
remove_fractional_xticks; remove_fractional_xticks;
hold off hold off
end end
name = deblank(varlist(j,:)); name = varlist{j};
title(name,'Interpreter','none') title(name,'Interpreter','none')
else else
if options_.debug if options_.debug
fprintf('POSTERIOR_IRF: The IRF of %s to %s is smaller than the irf_plot_threshold of %4.3f and will not be displayed.\n',deblank(varlist(j,:)),tit(i,:),options_.impulse_responses.plot_threshold) fprintf('POSTERIOR_IRF: The IRF of %s to %s is smaller than the irf_plot_threshold of %4.3f and will not be displayed.\n',varlist{j},tit{i},options_.impulse_responses.plot_threshold)
end end
end end
if subplotnum == MaxNumberOfPlotPerFigure || (j == nvar && subplotnum> 0) if subplotnum == MaxNumberOfPlotPerFigure || (j == nvar && subplotnum> 0)
figunumber = figunumber+1; figunumber = figunumber+1;
dyn_saveas(hh,[DirectoryName '/' M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber)],options_.nodisplay,options_.graph_format); dyn_saveas(hh,[DirectoryName '/' M_.fname '_Bayesian_IRF_' tit{i} '_' int2str(figunumber)],options_.nodisplay,options_.graph_format);
if RemoteFlag==1 if RemoteFlag==1
OutputFileName = [OutputFileName; {[DirectoryName,filesep], [M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber) '.*']}]; OutputFileName = [OutputFileName; {[DirectoryName,filesep], [M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber) '.*']}];
end end

View File

@ -19,7 +19,7 @@ function [oo_] = UnivariateSpectralDensity(M_,oo_,options_,var_list)
% Adapted from th_autocovariances.m. % Adapted from th_autocovariances.m.
% Copyright (C) 2006-2017 Dynare Team % Copyright (C) 2006-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -50,15 +50,15 @@ else
warning off MATLAB:dividebyzero warning off MATLAB:dividebyzero
end end
if nargin<2 if nargin<2
var_list = []; var_list = {};
end end
if size(var_list,1) == 0 if isempty(var_list)
var_list = M_.endo_names(1:M_.orig_endo_nbr, :); var_list = M_.endo_names(1:M_.orig_endo_nbr);
end end
nvar = size(var_list,1); nvar = length(var_list);
ivar=zeros(nvar,1); ivar=zeros(nvar,1);
for i=1:nvar for i=1:nvar
i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact'); i_tmp = strmatch(var_list{i}, M_.endo_names, 'exact');
if isempty(i_tmp) if isempty(i_tmp)
error (['One of the variables specified does not exist']) ; error (['One of the variables specified does not exist']) ;
else else
@ -159,12 +159,12 @@ if options_.nograph == 0
end end
for i= 1:nvar for i= 1:nvar
hh = dyn_figure(options_.nodisplay,'Name',['Spectral Density of ' deblank(M_.endo_names(ivar(i),:)) '.']); hh = dyn_figure(options_.nodisplay,'Name',['Spectral Density of ' M_.endo_names{ivar(i)} '.']);
plot(freqs,f(i,:),'-k','linewidth',2) plot(freqs,f(i,:),'-k','linewidth',2)
xlabel('0 \leq \omega \leq \pi') xlabel('0 \leq \omega \leq \pi')
ylabel('f(\omega)') ylabel('f(\omega)')
box on box on
axis tight axis tight
dyn_saveas(hh,[M_.fname ,filesep,'graphs', filesep, 'SpectralDensity_' deblank(M_.endo_names(ivar(i),:))],options_.nodisplay,options_.graph_format) dyn_saveas(hh,[M_.fname ,filesep,'graphs', filesep, 'SpectralDensity_' M_.endo_names{ivar(i)}],options_.nodisplay,options_.graph_format)
end end
end end

View File

@ -11,7 +11,7 @@ function WriteShockDecomp2Excel(z,shock_names,endo_names,i_var,initial_date,Dyna
% DynareModel [structure] Dynare model structure % DynareModel [structure] Dynare model structure
% DynareOptions [structure] Dynare options structure % DynareOptions [structure] Dynare options structure
% Copyright (C) 2016-2017 Dynare Team % Copyright (C) 2016-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -94,7 +94,7 @@ for j=1:nvar
z1 = squeeze(z(i_var(j),:,:)); z1 = squeeze(z(i_var(j),:,:));
if screen_shocks if screen_shocks
[junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend'); [junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
labels = char(char(shock_names(isort(1:16),:)),'Others', 'Initial values'); labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
zres = sum(z1(isort(17:end),:),1); zres = sum(z1(isort(17:end),:),1);
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)]; z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
comp_nbr=18; comp_nbr=18;
@ -115,9 +115,9 @@ for j=1:nvar
warning off warning off
if ~ismac if ~ismac
[STATUS,MESSAGE] = xlswrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,deblank(endo_names(i_var(j),:))); [STATUS,MESSAGE] = xlswrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,endo_names{i_var(j)});
else else
[STATUS] = xlwrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,deblank(endo_names(i_var(j),:))); [STATUS] = xlwrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,endo_names{i_var(j)});
end end
warning on warning on

View File

@ -32,7 +32,7 @@ function [z, endo_names, endo_names_tex, steady_state, i_var, oo_] = annualized_
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2017 Dynare Team % Copyright (C) 2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -109,17 +109,15 @@ elseif mytype
gtex = 'g'; gtex = 'g';
end end
steady_state=steady_state(i_var); steady_state=steady_state(i_var);
% endo_names = M_.endo_names(i_var,:);
% endo_names_tex = M_.endo_names_tex(i_var,:);
nterms = size(z,2); nterms = size(z,2);
nfrcst = opts.forecast/4; nfrcst = opts.forecast/4;
for j=1:nvar for j=1:nvar
if j>1 if j>1
endo_names = char(endo_names,[deblank(M_.endo_names(i_var(j),:)) '_A']); endo_names = char(endo_names, sprintf('%s_A', M_.endo_names{i_var(j)}));
endo_names_tex = char(endo_names_tex,['{' deblank(M_.endo_names_tex(i_var(j),:)) '}^A']); endo_names_tex = char(endo_names_tex, sprintf('{%s}^A', M_.endo_names_tex{i_var(j)}));
gendo_names = char(gendo_names,[gtxt endo_names(j,:)]); gendo_names = char(gendo_names,[gtxt endo_names{j}]);
gendo_names_tex = char(gendo_names_tex,[gtex '(' deblank(endo_names_tex(j,:)) ')']); gendo_names_tex = char(gendo_names_tex,[gtex '(' endo_names_tex{j} ')']);
else else
if nvar==1 && ~mytype if nvar==1 && ~mytype
endo_names = mytxt; endo_names = mytxt;
@ -127,10 +125,10 @@ for j=1:nvar
gendo_names = gtxt; gendo_names = gtxt;
gendo_names_tex = gtex; gendo_names_tex = gtex;
else else
endo_names = [deblank(M_.endo_names(i_var(j),:)) '_A']; endo_names = sprintf('%s_A', M_.endo_names{i_var(j)});
endo_names_tex = ['{' deblank(M_.endo_names_tex(i_var(j),:)) '}^A']; endo_names_tex = sprintf('{%s}^A', M_.endo_names_tex{i_var(j)});
gendo_names = [gtxt endo_names(j,:)]; gendo_names = [gtxt endo_names{j}];
gendo_names_tex = [gtex '(' deblank(endo_names_tex(j,:)) ')']; gendo_names_tex = [gtex '(' endo_names_tex{j} ')'];
end end
end end
for k =1:nterms for k =1:nterms
@ -331,3 +329,6 @@ else
steady_state = steady_state_a; steady_state = steady_state_a;
end end
end end
endo_names = cellstr(endo_names);
endo_names_tex = cellstr(endo_names_tex);

View File

@ -10,7 +10,7 @@ function forecasts = backward_model_forecast(initialcondition, listofvariables,
% OUTPUTS % OUTPUTS
% - forecast [dseries] % - forecast [dseries]
% Copyright (C) 2017 Dynare Team % Copyright (C) 2017-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -39,7 +39,7 @@ forecasts = struct();
% Set defaults. % Set defaults.
if nargin<2 if nargin<2
listofvariables = cellstr(M_.endo_names); listofvariables = M_.endo_names;
periods = 8; periods = 8;
withuncertainty = false; withuncertainty = false;
end end

View File

@ -19,7 +19,7 @@ function [deviations, baseline, irfs] = backward_model_irf(initialcondition, inn
% argument. % argument.
% - If second argument is not empty, periods must not be greater than innovationbaseline.nobs. % - If second argument is not empty, periods must not be greater than innovationbaseline.nobs.
% Copyright (C) 2017 Dynare Team % Copyright (C) 2017-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -72,7 +72,7 @@ else
end end
if deterministicshockflag if deterministicshockflag
numberofexperiments = length(listofshocks); numberofexperiments = length(listofshocks);
exonames = cellstr(M_.exo_names); exonames = M_.exo_names;
initialconditionperiod = initialcondition.dates(end); initialconditionperiod = initialcondition.dates(end);
for i=1:numberofexperiments for i=1:numberofexperiments
shock = listofshocks{i}; shock = listofshocks{i};
@ -108,7 +108,7 @@ if ~isempty(innovationbaseline)
error('The second input argument must at least have %s observations or lower the number of periods.', periods) error('The second input argument must at least have %s observations or lower the number of periods.', periods)
end end
% Fill innovations with provided paths for the innovations. % Fill innovations with provided paths for the innovations.
exonames = cellstr(M_.exo_names); exonames = M_.exo_names;
for i = 1:length(exonames) for i = 1:length(exonames)
if ~isempty(strmatch(exonames{i}, innovationbaseline.name)) if ~isempty(strmatch(exonames{i}, innovationbaseline.name))
Innovations(:,i) = innovationbaseline{exonames{i}}.data(1:periods); Innovations(:,i) = innovationbaseline{exonames{i}}.data(1:periods);
@ -183,9 +183,9 @@ for i=1:length(listofshocks)
endo_simul__1 = feval(transform, ysim__1); endo_simul__1 = feval(transform, ysim__1);
end end
% Instantiate a dseries object (with all the endogenous variables) % Instantiate a dseries object (with all the endogenous variables)
alldeviations = dseries(transpose(endo_simul__1-endo_simul__0), initialcondition.init, endonames(1:M_.orig_endo_nbr), cellstr(DynareModel.endo_names_tex(1:M_.orig_endo_nbr,:))); alldeviations = dseries(transpose(endo_simul__1-endo_simul__0), initialcondition.init, endonames(1:M_.orig_endo_nbr), DynareModel.endo_names_tex(1:M_.orig_endo_nbr));
if nargout>2 if nargout>2
allirfs = dseries(transpose(endo_simul__1), initialcondition.init, endonames(1:M_.orig_endo_nbr), cellstr(DynareModel.endo_names_tex(1:M_.orig_endo_nbr,:))); allirfs = dseries(transpose(endo_simul__1), initialcondition.init, endonames(1:M_.orig_endo_nbr), DynareModel.endo_names_tex(1:M_.orig_endo_nbr));
end end
% Extract a sub-dseries object % Extract a sub-dseries object
if deterministicshockflag if deterministicshockflag
@ -201,6 +201,6 @@ for i=1:length(listofshocks)
end end
if nargout>1 if nargout>1
baseline = dseries(transpose(endo_simul__0), initialcondition.init, endonames(1:M_.orig_endo_nbr), cellstr(DynareModel.endo_names_tex(1:M_.orig_endo_nbr,:))); baseline = dseries(transpose(endo_simul__0), initialcondition.init, endonames(1:M_.orig_endo_nbr), DynareModel.endo_names_tex(1:M_.orig_endo_nbr));
baseline = [baseline, innovationbaseline]; baseline = [baseline, innovationbaseline];
end end

View File

@ -18,7 +18,7 @@ function simulation = simul_backward_model(initialconditions, samplesize, innova
% [3] If the first input argument is empty, the endogenous variables are initialized with 0, or if available with the informations % [3] If the first input argument is empty, the endogenous variables are initialized with 0, or if available with the informations
% provided thrtough the histval block. % provided thrtough the histval block.
% Copyright (C) 2012-2017 Dynare Team % Copyright (C) 2012-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -47,7 +47,7 @@ else
end end
% Set array holding innovations values. % Set array holding innovations values.
Innovations = zeros(samplesize, M_.exo_nbr); Innovations = zeros(samplesize, M_.exo_nbr);
exonames = cellstr(M_.exo_names); exonames = M_.exo_names;
for i=1:M_.exo_nbr for i=1:M_.exo_nbr
if ismember(exonames{i}, innovations.name) if ismember(exonames{i}, innovations.name)
Innovations(:,i) = innovations{exonames{i}}.data(1:samplesize); Innovations(:,i) = innovations{exonames{i}}.data(1:samplesize);

View File

@ -2,7 +2,7 @@ function [initialconditions, samplesize, innovations, DynareOptions, DynareModel
% Initialization of the routines simulating backward models. % Initialization of the routines simulating backward models.
% Copyright (C) 2017 Dynare Team % Copyright (C) 2017-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -41,7 +41,7 @@ if ~isdseries(initialconditions)
end end
% Test if the first argument contains all the lagged endogenous variables % Test if the first argument contains all the lagged endogenous variables
endonames = cellstr(DynareModel.endo_names); endonames = DynareModel.endo_names;
missingendogenousvariables = setdiff(endonames, initialconditions.name); missingendogenousvariables = setdiff(endonames, initialconditions.name);
endolags = get_lags_on_endogenous_variables(DynareModel); endolags = get_lags_on_endogenous_variables(DynareModel);
endolags_ = endolags(find(endolags)); endolags_ = endolags(find(endolags));
@ -84,7 +84,7 @@ if missinginitialcondition
end end
% If the model has lags on the exogenous variables, test if we have corresponding initial conditions. % If the model has lags on the exogenous variables, test if we have corresponding initial conditions.
exonames = cellstr(DynareModel.exo_names); exonames = DynareModel.exo_names;
missingexogenousvariables = setdiff(exonames, initialconditions.name); missingexogenousvariables = setdiff(exonames, initialconditions.name);
exolags = get_lags_on_exogenous_variables(DynareModel); exolags = get_lags_on_exogenous_variables(DynareModel);
exolags_ = exolags(find(exolags)); exolags_ = exolags(find(exolags));
@ -131,16 +131,16 @@ k = 0;
for i = DynareModel.orig_endo_nbr+1:DynareModel.endo_nbr for i = DynareModel.orig_endo_nbr+1:DynareModel.endo_nbr
k = k+1; k = k+1;
if DynareModel.aux_vars(k).type==1 if DynareModel.aux_vars(k).type==1
if ismember(deblank(DynareModel.endo_names(DynareModel.aux_vars(k).orig_index,:)), initialconditions.name) if ismember(DynareModel.endo_names{DynareModel.aux_vars(k).orig_index}, initialconditions.name)
initialconditions{deblank(DynareModel.endo_names(DynareModel.aux_vars(k).endo_index, :))} = ... initialconditions{DynareModel.endo_names{DynareModel.aux_vars(k).endo_index}} = ...
initialconditions{deblank(DynareModel.endo_names(DynareModel.aux_vars(k).orig_index, :))}.lag(abs(DynareModel.aux_vars(k).orig_lead_lag)); initialconditions{DynareModel.endo_names{DynareModel.aux_vars(k).orig_index}}.lag(abs(DynareModel.aux_vars(k).orig_lead_lag));
else else
error('This is a bug. Please contact Dynare Team!'); error('This is a bug. Please contact Dynare Team!');
end end
elseif DynareModel.aux_vars(k).type==3 elseif DynareModel.aux_vars(k).type==3
if ismember(deblank(DynareModel.exo_names(DynareModel.aux_vars(k).orig_index, :)), initialconditions.name) if ismember(DynareModel.exo_names{DynareModel.aux_vars(k).orig_index}, initialconditions.name)
initialconditions{deblank(DynareModel.endo_names(DynareModel.aux_vars(k).endo_index,:))} = ... initialconditions{DynareModel.endo_names{DynareModel.aux_vars(k).endo_index}} = ...
initialconditions{deblank(DynareModel.exo_names(DynareModel.aux_vars(k).orig_index, :))}.lag(abs(DynareModel.aux_vars(k).orig_lead_lag)); initialconditions{DynareModel.exo_names{DynareModel.aux_vars(k).orig_index}}.lag(abs(DynareModel.aux_vars(k).orig_lead_lag));
else else
error('This is a bug. Please contact Dynare Team!'); error('This is a bug. Please contact Dynare Team!');
end end

View File

@ -0,0 +1,28 @@
function n = cellofchararraymaxlength(c)
% Copyright (C) 2018 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/>.
if ~all(cellfun(@ischar, c))
error('Input has to be a cell of char arrays!')
end
if ~all(cellfun(@isrow, c))
error('Input has to be a cell of one dimensional char arrays!')
end
n = max(cellfun(@length, c));

View File

@ -5,16 +5,16 @@ function varlist = check_list_of_variables(options_, M_, varlist)
% %
% INPUTS % INPUTS
% %
% options_ [structure] Dynare structure. % options_ [structure] Dynare structure.
% M_ [structure] Dynare structure (related to model definition). % M_ [structure] Dynare structure (related to model definition).
% varlist [string] Array of strings with name of the endogenous variables. % varlist [cell of char arrays] Array of strings with name of the endogenous variables.
% %
% OUTPUTS % OUTPUTS
% varlist [string] % varlist [cell of char arrays]
% %
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -33,21 +33,21 @@ function varlist = check_list_of_variables(options_, M_, varlist)
%get uniques %get uniques
[junk1,junk2,index_uniques] = varlist_indices(varlist,M_.endo_names); [junk1, junk2, index_uniques] = varlist_indices(varlist, M_.endo_names);
varlist=varlist(index_uniques,:); varlist = varlist(index_uniques);
msg = 0; msg = false;
if options_.dsge_var && options_.bayesian_irf if options_.dsge_var && options_.bayesian_irf
if ~isempty(varlist) if ~isempty(varlist)
for i=1:size(varlist,1) for i=1:size(varlist,1)
idx = strmatch(deblank(varlist(i,:)),options_.varobs,'exact'); idx = strmatch(varlist{i}, options_.varobs, 'exact');
if isempty(idx) if isempty(idx)
disp([varlist(i,:) ' is not an observed variable!']); disp(sprintf('%s is not an observed variable!', varlist{i}))
msg = 1; msg = true;
end end
end end
if size(varlist,1)~=length(options_.varobs) if ~isequal(size(varlist), length(options_.varobs))
msg = 1; msg = true;
end end
if msg if msg
skipline() skipline()
@ -55,7 +55,7 @@ if options_.dsge_var && options_.bayesian_irf
skipline() skipline()
end end
end end
varlist = char(options_.varobs); varlist = options_.varobs;
return return
end end
@ -63,16 +63,16 @@ if ~isempty(varlist) && ~isempty(options_.endo_vars_for_moment_computations_in_e
error('You cannot use the consider_all_endogenous or consider_all_observed options when listing variables after the estimation command') error('You cannot use the consider_all_endogenous or consider_all_observed options when listing variables after the estimation command')
elseif isempty(varlist) && ~isempty(options_.endo_vars_for_moment_computations_in_estimation) elseif isempty(varlist) && ~isempty(options_.endo_vars_for_moment_computations_in_estimation)
if strcmp(options_.endo_vars_for_moment_computations_in_estimation,'all_endogenous_variables') if strcmp(options_.endo_vars_for_moment_computations_in_estimation,'all_endogenous_variables')
varlist = M_.endo_names(1:M_.orig_endo_nbr, :); varlist = M_.endo_names(1:M_.orig_endo_nbr);
elseif strcmp(options_.endo_vars_for_moment_computations_in_estimation,'only_observed_variables') elseif strcmp(options_.endo_vars_for_moment_computations_in_estimation,'only_observed_variables')
varlist = char(options_.varobs'); varlist = options_.varobs;
else else
error('Unknown option') error('Unknown option')
end end
elseif isempty(varlist) && isempty(options_.endo_vars_for_moment_computations_in_estimation) elseif isempty(varlist) && isempty(options_.endo_vars_for_moment_computations_in_estimation)
skipline() skipline()
disp(['You did not declare endogenous variables after the estimation/calib_smoother command.']) disp(['You did not declare endogenous variables after the estimation/calib_smoother command.'])
cas = []; cas = '';
if options_.bayesian_irf if options_.bayesian_irf
cas = 'Posterior IRFs'; cas = 'Posterior IRFs';
end end
@ -80,37 +80,37 @@ elseif isempty(varlist) && isempty(options_.endo_vars_for_moment_computations_in
if isempty(cas) if isempty(cas)
cas = 'Posterior moments'; cas = 'Posterior moments';
else else
cas = [ cas , ', posterior moments']; cas = [cas, ', posterior moments'];
end end
end end
if options_.smoother if options_.smoother
if isempty(cas) if isempty(cas)
cas = 'Smoothed variables'; cas = 'Smoothed variables';
else else
cas = [ cas , ', smoothed variables']; cas = [cas, ', smoothed variables'];
end end
end end
if ~isempty(options_.filter_step_ahead) if ~isempty(options_.filter_step_ahead)
if isempty(cas) if isempty(cas)
cas = 'k-step ahead filtered variables'; cas = 'k-step ahead filtered variables';
else else
cas = [ cas , ', k-step ahead filtered variables']; cas = [cas, ', k-step ahead filtered variables'];
end end
end end
if options_.forecast if options_.forecast
if isempty(cas) if isempty(cas)
cas = 'Forecasts'; cas = 'Forecasts';
else else
cas = [ cas , ' and forecasts']; cas = [cas, ' and forecasts'];
end end
end end
if ~isempty(cas) if ~isempty(cas)
string = [ cas , ' will be computed for the ' num2str(M_.endo_nbr) ' endogenous variables']; str = sprintf('%s will be computed for the %s endogenous variables of your model', cas, num2str(M_.orig_endo_nbr));
string = [ string ' of your model, this can take a long time ....']; str = sprintf('%s, this can take a long time ....', str);
format_text(string, 10) format_text(str, 10)
if options_.nointeractive if options_.nointeractive
% Default behaviour is to consider all the endogenous variables. % Default behaviour is to consider all the endogenous variables.
varlist = M_.endo_names(1:M_.orig_endo_nbr, :); varlist = M_.endo_names(1:M_.orig_endo_nbr);
else else
choice = []; choice = [];
while isempty(choice) while isempty(choice)
@ -126,9 +126,9 @@ elseif isempty(varlist) && isempty(options_.endo_vars_for_moment_computations_in
choice=1; choice=1;
end end
if choice==1 if choice==1
varlist = M_.endo_names(1:M_.orig_endo_nbr, :); varlist = M_.endo_names(1:M_.orig_endo_nbr);
elseif choice==2 elseif choice==2
varlist = char(options_.varobs); varlist = options_.varobs;
elseif choice==3 elseif choice==3
varlist = NaN; varlist = NaN;
else else

View File

@ -1,14 +1,15 @@
function oo_ = compute_moments_varendo(type,options_,M_,oo_,var_list_) function oo_ = compute_moments_varendo(type, options_, M_, oo_, var_list_)
% Computes the second order moments (autocorrelation function, covariance % Computes the second order moments (autocorrelation function, covariance
% matrix and variance decomposition) distributions for all the endogenous variables selected in % matrix and variance decomposition) distributions for all the endogenous variables selected in
% var_list_. The results are saved in oo_ % var_list_. The results are saved in oo_
% %
% INPUTS: % INPUTS:
% type [string] 'posterior' or 'prior' % type [string] 'posterior' or 'prior'
% options_ [structure] Dynare structure. % options_ [structure] Dynare structure.
% M_ [structure] Dynare structure (related to model definition). % M_ [structure] Dynare structure (related to model definition).
% oo_ [structure] Dynare structure (results). % oo_ [structure] Dynare structure (results).
% var_list_ [string] Array of string with endogenous variable names. % var_list_ [cell of char arrays] Endogenous variable names.
% %
% OUTPUTS % OUTPUTS
% oo_ [structure] Dynare structure (results). % oo_ [structure] Dynare structure (results).
@ -16,7 +17,7 @@ function oo_ = compute_moments_varendo(type,options_,M_,oo_,var_list_)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2008-2017 Dynare Team % Copyright (C) 2008-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -39,21 +40,21 @@ fprintf('Estimation::compute_moments_varendo: I''m computing endogenous moments
if strcmpi(type,'posterior') if strcmpi(type,'posterior')
posterior = 1; posterior = 1;
if nargin==4 if nargin==4
var_list_ = char(options_.varobs); var_list_ = options_.varobs;
end end
elseif strcmpi(type,'prior') elseif strcmpi(type,'prior')
posterior = 0; posterior = 0;
if nargin==4 if nargin==4
var_list_ = options_.prior_analysis_endo_var_list; var_list_ = options_.prior_analysis_endo_var_list;
if isempty(var_list_) if isempty(var_list_)
options_.prior_analysis_var_list = char(options_.varobs); options_.prior_analysis_var_list = options_.varobs;
end end
end end
else else
error('compute_moments_varendo:: Unknown type!') error('compute_moments_varendo:: Unknown type!')
end end
NumberOfEndogenousVariables = rows(var_list_); NumberOfEndogenousVariables = length(var_list_);
NumberOfExogenousVariables = M_.exo_nbr; NumberOfExogenousVariables = M_.exo_nbr;
NumberOfLags = options_.ar; NumberOfLags = options_.ar;
NoDecomposition = options_.nodecomposition; NoDecomposition = options_.nodecomposition;
@ -64,9 +65,9 @@ else
end end
if options_.TeX if options_.TeX
var_list_tex=''; var_list_tex={};
for var_iter=1:size(var_list_,1) for var_iter = 1:length(var_list_)
var_list_tex=strvcat(var_list_tex,M_.endo_names_tex(strmatch(var_list_(var_iter,:),M_.endo_names,'exact'),:)); var_list_tex = vertcat(var_list_tex, M_.endo_names_tex{strmatch(var_list_{var_iter}, M_.endo_names, 'exact')});
end end
end end
@ -74,22 +75,23 @@ end
if posterior if posterior
for i=1:NumberOfEndogenousVariables for i=1:NumberOfEndogenousVariables
for j=i:NumberOfEndogenousVariables for j=i:NumberOfEndogenousVariables
oo_ = posterior_analysis('variance',var_list_(i,:),var_list_(j,:),[],options_,M_,oo_); oo_ = posterior_analysis('variance', var_list_{i}, var_list_{j}, [], options_, M_, oo_);
end end
end end
else else
for i=1:NumberOfEndogenousVariables for i=1:NumberOfEndogenousVariables
for j=i:NumberOfEndogenousVariables for j=i:NumberOfEndogenousVariables
oo_ = prior_analysis('variance',var_list_(i,:),var_list_(j,:),[],options_,M_,oo_); oo_ = prior_analysis('variance', var_list_{i}, var_list_{j}, [], options_, M_, oo_);
end end
end end
end end
% CORRELATION FUNCTION. % CORRELATION FUNCTION.
if posterior if posterior
for h=NumberOfLags:-1:1 for h=NumberOfLags:-1:1
for i=1:NumberOfEndogenousVariables for i=1:NumberOfEndogenousVariables
for j=1:NumberOfEndogenousVariables for j=1:NumberOfEndogenousVariables
oo_ = posterior_analysis('correlation',var_list_(i,:),var_list_(j,:),h,options_,M_,oo_); oo_ = posterior_analysis('correlation', var_list_{i}, var_list_{j}, h, options_, M_, oo_);
end end
end end
end end
@ -97,11 +99,12 @@ else
for h=NumberOfLags:-1:1 for h=NumberOfLags:-1:1
for i=1:NumberOfEndogenousVariables for i=1:NumberOfEndogenousVariables
for j=1:NumberOfEndogenousVariables for j=1:NumberOfEndogenousVariables
oo_ = prior_analysis('correlation',var_list_(i,:),var_list_(j,:),h,options_,M_,oo_); oo_ = prior_analysis('correlation', var_list_{i}, var_list_{j}, h, options_, M_, oo_);
end end
end end
end end
end end
% VARIANCE DECOMPOSITION. % VARIANCE DECOMPOSITION.
if M_.exo_nbr > 1 if M_.exo_nbr > 1
if ~NoDecomposition if ~NoDecomposition
@ -109,8 +112,8 @@ if M_.exo_nbr > 1
if posterior if posterior
for i=1:NumberOfEndogenousVariables for i=1:NumberOfEndogenousVariables
for j=1:NumberOfExogenousVariables for j=1:NumberOfExogenousVariables
oo_ = posterior_analysis('decomposition',var_list_(i,:),M_.exo_names(j,:),[],options_,M_,oo_); oo_ = posterior_analysis('decomposition', var_list_{i}, M_.exo_names{j}, [], options_, M_, oo_);
temp(i,j)=oo_.PosteriorTheoreticalMoments.dsge.VarianceDecomposition.Mean.(deblank(var_list_(i,:))).(deblank(M_.exo_names(j,:))); temp(i,j) = oo_.PosteriorTheoreticalMoments.dsge.VarianceDecomposition.Mean.(var_list_{i}).(M_.exo_names{j});
end end
end end
title='Posterior mean variance decomposition (in percent)'; title='Posterior mean variance decomposition (in percent)';
@ -118,160 +121,157 @@ if M_.exo_nbr > 1
else else
for i=1:NumberOfEndogenousVariables for i=1:NumberOfEndogenousVariables
for j=1:NumberOfExogenousVariables for j=1:NumberOfExogenousVariables
oo_ = prior_analysis('decomposition',var_list_(i,:),M_.exo_names(j,:),[],options_,M_,oo_); oo_ = prior_analysis('decomposition', var_list_{i}, M_.exo_names{j}, [], options_, M_, oo_);
temp(i,j)=oo_.PriorTheoreticalMoments.dsge.VarianceDecomposition.Mean.(deblank(var_list_(i,:))).(deblank(M_.exo_names(j,:))); temp(i,j)=oo_.PriorTheoreticalMoments.dsge.VarianceDecomposition.Mean.(var_list_{i}).(M_.exo_names{j});
end end
end end
title='Prior mean variance decomposition (in percent)'; title='Prior mean variance decomposition (in percent)';
save_name_string='dsge_prior_mean_var_decomp_uncond'; save_name_string='dsge_prior_mean_var_decomp_uncond';
end end
title=add_filter_subtitle(title,options_); title=add_filter_subtitle(title, options_);
headers = M_.exo_names; headers = M_.exo_names;
headers(M_.exo_names_orig_ord,:) = headers; headers(M_.exo_names_orig_ord) = headers;
headers = char(' ',headers); headers = vertcat(' ', headers);
lh = size(deblank(var_list_),2)+2; lh = cellofchararraymaxlength(var_list_)+2;
dyntable(options_,title,headers,deblank(var_list_),100* ... dyntable(options_, title, headers, var_list_, 100*temp, lh, 8, 2);
temp,lh,8,2);
if options_.TeX if options_.TeX
headers=M_.exo_names_tex; headers = M_.exo_names_tex;
headers = char(' ',headers); headers = vertcat(' ', headers);
labels = deblank(var_list_tex); labels = var_list_tex;
lh = size(labels,2)+2; lh = size(labels,2)+2;
dyn_latex_table(M_,options_,title,save_name_string,headers,labels,100*temp,lh,8,2); dyn_latex_table(M_, options_, title, save_name_string, headers, labels, 100*temp, lh, 8, 2);
end end
skipline(); skipline();
end end
skipline(); skipline();
if ~all(M_.H==0) if ~all(M_.H==0)
[observable_name_requested_vars,varlist_pos]=intersect(var_list_,options_.varobs,'stable'); [observable_name_requested_vars, varlist_pos] = intersect(var_list_, options_.varobs, 'stable');
if ~isempty(observable_name_requested_vars) if ~isempty(observable_name_requested_vars)
NumberOfObservedEndogenousVariables=length(observable_name_requested_vars); NumberOfObservedEndogenousVariables = length(observable_name_requested_vars);
temp=NaN(NumberOfObservedEndogenousVariables,NumberOfExogenousVariables+1); temp = NaN(NumberOfObservedEndogenousVariables, NumberOfExogenousVariables+1);
if posterior if posterior
for i=1:NumberOfObservedEndogenousVariables for i=1:NumberOfObservedEndogenousVariables
for j=1:NumberOfExogenousVariables for j=1:NumberOfExogenousVariables
temp(i,j,:)=oo_.PosteriorTheoreticalMoments.dsge.VarianceDecompositionME.Mean.(deblank(observable_name_requested_vars{i,1})).(deblank(M_.exo_names(j,:))); temp(i,j,:) = oo_.PosteriorTheoreticalMoments.dsge.VarianceDecompositionME.Mean.(observable_name_requested_vars{i}).(M_.exo_names{j});
end end
endo_index_varlist=strmatch(deblank(observable_name_requested_vars{i,1}),var_list_,'exact'); endo_index_varlist = strmatch(observable_name_requested_vars{i}, var_list_, 'exact');
oo_ = posterior_analysis('decomposition',var_list_(endo_index_varlist,:),'ME',[],options_,M_,oo_); oo_ = posterior_analysis('decomposition', var_list_{endo_index_varlist}, 'ME', [], options_, M_, oo_);
temp(i,j+1,:)=oo_.PosteriorTheoreticalMoments.dsge.VarianceDecompositionME.Mean.(deblank(observable_name_requested_vars{i,1})).('ME'); temp(i,j+1,:) = oo_.PosteriorTheoreticalMoments.dsge.VarianceDecompositionME.Mean.(observable_name_requested_vars{i}).('ME');
end end
title='Posterior mean variance decomposition (in percent) with measurement error'; title='Posterior mean variance decomposition (in percent) with measurement error';
save_name_string='dsge_post_mean_var_decomp_uncond_ME'; save_name_string='dsge_post_mean_var_decomp_uncond_ME';
else else
for i=1:NumberOfObservedEndogenousVariables for i=1:NumberOfObservedEndogenousVariables
for j=1:NumberOfExogenousVariables for j=1:NumberOfExogenousVariables
temp(i,j,:)=oo_.PriorTheoreticalMoments.dsge.VarianceDecompositionME.Mean.(deblank(observable_name_requested_vars(i,:))).(deblank(M_.exo_names(j,:))); temp(i,j,:) = oo_.PriorTheoreticalMoments.dsge.VarianceDecompositionME.Mean.(observable_name_requested_vars{i}).(M_.exo_names{j});
end end
endo_index_varlist=strmatch(deblank(observable_name_requested_vars{i,1}),var_list_,'exact'); endo_index_varlist = strmatch(observable_name_requested_vars{i}, var_list_, 'exact');
oo_ = prior_analysis('decomposition',var_list_(endo_index_varlist,:),'ME',[],options_,M_,oo_); oo_ = prior_analysis('decomposition', var_list_{endo_index_varlist}, 'ME', [], options_, M_, oo_);
temp(i,j+1,:)=oo_.PriorTheoreticalMoments.dsge.VarianceDecompositionME.Mean.(deblank(observable_name_requested_vars{i,1})).('ME'); temp(i,j+1,:) = oo_.PriorTheoreticalMoments.dsge.VarianceDecompositionME.Mean.(observable_name_requested_vars{i}).('ME');
end end
title='Prior mean variance decomposition (in percent) with measurement error'; title='Prior mean variance decomposition (in percent) with measurement error';
save_name_string='dsge_prior_mean_var_decomp_uncond_ME'; save_name_string='dsge_prior_mean_var_decomp_uncond_ME';
end end
title=add_filter_subtitle(title,options_); title=add_filter_subtitle(title, options_);
headers = M_.exo_names; headers = M_.exo_names;
headers(M_.exo_names_orig_ord,:) = headers; headers(M_.exo_names_orig_ord) = headers;
headers = char(' ',headers,'ME'); headers = vertcat(' ', headers, 'ME');
lh = size(deblank(var_list_),2)+2; lh = cellofchararraymaxlength(var_list_)+2;
dyntable(options_,title,headers,deblank(char(observable_name_requested_vars)),100* ... dyntable(options_, title, headers, observable_name_requested_vars,100*temp,lh,8,2);
temp,lh,8,2);
if options_.TeX if options_.TeX
headers=M_.exo_names_tex; headers = M_.exo_names_tex;
headers = char(' ',headers,'ME'); headers = vertcat(' ', headers, 'ME');
labels = deblank(var_list_tex(varlist_pos,:)); labels = var_list_tex(varlist_pos);
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyn_latex_table(M_,options_,title,save_name_string,headers,labels,100*temp,lh,8,2); dyn_latex_table(M_, options_, title, save_name_string, headers, labels, 100*temp, lh, 8, 2);
end end
skipline(); skipline();
end end
end end
% CONDITIONAL VARIANCE DECOMPOSITION. % CONDITIONAL VARIANCE DECOMPOSITION.
if Steps if Steps
temp=NaN(NumberOfEndogenousVariables,NumberOfExogenousVariables,length(Steps)); temp = NaN(NumberOfEndogenousVariables, NumberOfExogenousVariables, length(Steps));
if posterior if posterior
for i=1:NumberOfEndogenousVariables for i=1:NumberOfEndogenousVariables
for j=1:NumberOfExogenousVariables for j=1:NumberOfExogenousVariables
oo_ = posterior_analysis('conditional decomposition',i,M_.exo_names(j,:),Steps,options_,M_,oo_); oo_ = posterior_analysis('conditional decomposition', var_list_{i}, M_.exo_names{j}, Steps, options_, M_, oo_);
temp(i,j,:)=oo_.PosteriorTheoreticalMoments.dsge.ConditionalVarianceDecomposition.Mean.(deblank(var_list_(i,:))).(deblank(M_.exo_names(j,:))); temp(i,j,:) = oo_.PosteriorTheoreticalMoments.dsge.ConditionalVarianceDecomposition.Mean.(var_list_{i}).(M_.exo_names{j});
end end
end end
title='Posterior mean conditional variance decomposition (in percent)'; title = 'Posterior mean conditional variance decomposition (in percent)';
save_name_string='dsge_post_mean_var_decomp_cond_h'; save_name_string = 'dsge_post_mean_var_decomp_cond_h';
else else
for i=1:NumberOfEndogenousVariables for i=1:NumberOfEndogenousVariables
for j=1:NumberOfExogenousVariables for j=1:NumberOfExogenousVariables
oo_ = prior_analysis('conditional decomposition',var_list_(i,:),M_.exo_names(j,:),Steps,options_,M_,oo_); oo_ = prior_analysis('conditional decomposition', var_list_{i}, M_.exo_names{j}, Steps, options_, M_, oo_);
temp(i,j,:)=oo_.PriorTheoreticalMoments.dsge.ConditionalVarianceDecomposition.Mean.(deblank(var_list_(i,:))).(deblank(M_.exo_names(j,:))); temp(i,j,:) = oo_.PriorTheoreticalMoments.dsge.ConditionalVarianceDecomposition.Mean.(var_list_{i}).(M_.exo_names{j});
end end
end end
title='Prior mean conditional variance decomposition (in percent)'; title = 'Prior mean conditional variance decomposition (in percent)';
save_name_string='dsge_prior_mean_var_decomp_cond_h'; save_name_string = 'dsge_prior_mean_var_decomp_cond_h';
end end
for step_iter=1:length(Steps) for step_iter=1:length(Steps)
title_print=[title, ' Period ' int2str(Steps(step_iter))]; title_print=[title, ' Period ' int2str(Steps(step_iter))];
headers = M_.exo_names; headers = M_.exo_names;
headers(M_.exo_names_orig_ord,:) = headers; headers(M_.exo_names_orig_ord) = headers;
headers = char(' ',headers); headers = vertcat(' ', headers);
lh = size(deblank(var_list_),2)+2; lh = cellofchararraymaxlength(var_list_)+2;
dyntable(options_,title_print,headers,deblank(var_list_),100* ... dyntable(options_,title_print,headers, var_list_,100* ...
temp(:,:,step_iter),lh,8,2); temp(:,:,step_iter),lh,8,2);
if options_.TeX if options_.TeX
headers=M_.exo_names_tex; headers = M_.exo_names_tex;
headers = char(' ',headers); headers = vertcat(' ', headers);
labels = deblank(var_list_tex); labels = var_list_tex;
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyn_latex_table(M_,options_,title_print,[save_name_string,int2str(Steps(step_iter))],headers,labels,100*temp(:,:,step_iter),lh,8,2); dyn_latex_table(M_, options_, title_print, [save_name_string, int2str(Steps(step_iter))], headers, labels, 100*temp(:,:,step_iter), lh, 8, 2);
end end
end end
skipline(); skipline();
if ~all(M_.H==0) if ~all(M_.H==0)
if ~isempty(observable_name_requested_vars) if ~isempty(observable_name_requested_vars)
NumberOfObservedEndogenousVariables=length(observable_name_requested_vars); NumberOfObservedEndogenousVariables = length(observable_name_requested_vars);
temp=NaN(NumberOfObservedEndogenousVariables,NumberOfExogenousVariables+1,length(Steps)); temp=NaN(NumberOfObservedEndogenousVariables,NumberOfExogenousVariables+1,length(Steps));
if posterior if posterior
for i=1:NumberOfObservedEndogenousVariables for i=1:NumberOfObservedEndogenousVariables
for j=1:NumberOfExogenousVariables for j=1:NumberOfExogenousVariables
temp(i,j,:)=oo_.PosteriorTheoreticalMoments.dsge.ConditionalVarianceDecompositionME.Mean.(deblank(observable_name_requested_vars{i,1})).(deblank(M_.exo_names(j,:))); temp(i,j,:) = oo_.PosteriorTheoreticalMoments.dsge.ConditionalVarianceDecompositionME.Mean.(observable_name_requested_vars{i}).(M_.exo_names{j});
end end
endo_index_varlist=strmatch(deblank(observable_name_requested_vars{i,1}),var_list_,'exact'); endo_index_varlist = strmatch(observable_name_requested_vars{i}, var_list_, 'exact');
oo_ = posterior_analysis('conditional decomposition',endo_index_varlist,'ME',Steps,options_,M_,oo_); oo_ = posterior_analysis('conditional decomposition', var_list_{endo_index_varlist}, 'ME', Steps, options_, M_, oo_);
temp(i,j+1,:)=oo_.PosteriorTheoreticalMoments.dsge.ConditionalVarianceDecompositionME.Mean.(deblank(observable_name_requested_vars{i,1})).('ME'); temp(i,j+1,:) = oo_.PosteriorTheoreticalMoments.dsge.ConditionalVarianceDecompositionME.Mean.(observable_name_requested_vars{i}).('ME');
end end
title='Posterior mean conditional variance decomposition (in percent) with measurement error'; title = 'Posterior mean conditional variance decomposition (in percent) with measurement error';
save_name_string='dsge_post_mean_var_decomp_ME_cond_h'; save_name_string = 'dsge_post_mean_var_decomp_ME_cond_h';
else else
for i=1:NumberOfObservedEndogenousVariables for i=1:NumberOfObservedEndogenousVariables
for j=1:NumberOfExogenousVariables for j=1:NumberOfExogenousVariables
temp(i,j,:)=oo_.PriorTheoreticalMoments.dsge.ConditionalVarianceDecompositionME.Mean.(deblank(observable_name_requested_vars(i,:))).(deblank(M_.exo_names(j,:))); temp(i,j,:) = oo_.PriorTheoreticalMoments.dsge.ConditionalVarianceDecompositionME.Mean.(observable_name_requested_vars{i}).(M_.exo_names{j});
end end
endo_index_varlist=strmatch(deblank(observable_name_requested_vars{i,1}),var_list_,'exact'); endo_index_varlist = strmatch(observable_name_requested_vars{i}, var_list_, 'exact');
oo_ = prior_analysis('conditional decomposition',endo_index_varlist,'ME',Steps,options_,M_,oo_); oo_ = prior_analysis('conditional decomposition', var_list_{endo_index_varlist}, 'ME', Steps, options_, M_, oo_);
temp(i,j+1,:)=oo_.PriorTheoreticalMoments.dsge.ConditionalVarianceDecompositionME.Mean.(deblank(observable_name_requested_vars{i,1})).('ME'); temp(i,j+1,:) = oo_.PriorTheoreticalMoments.dsge.ConditionalVarianceDecompositionME.Mean.(observable_name_requested_vars{i}).('ME');
end end
title='Prior mean conditional variance decomposition (in percent) with measurement error'; title = 'Prior mean conditional variance decomposition (in percent) with measurement error';
save_name_string='dsge_prior_mean_var_decomp_ME_cond_h'; save_name_string = 'dsge_prior_mean_var_decomp_ME_cond_h';
end end
for step_iter=1:length(Steps) for step_iter=1:length(Steps)
title_print=[title, ' Period ' int2str(Steps(step_iter))]; title_print = [title, ' Period ' int2str(Steps(step_iter))];
headers = M_.exo_names; headers = M_.exo_names;
headers(M_.exo_names_orig_ord,:) = headers; headers(M_.exo_names_orig_ord) = headers;
headers = char(' ',headers,'ME'); headers = vertcat(' ', headers, 'ME');
lh = size(deblank(var_list_),2)+2; lh = cellofchararraymaxlength(var_list_)+2;
dyntable(options_,title_print,headers,deblank(char(observable_name_requested_vars)),100* ... dyntable(options_, title_print, headers, observable_name_requested_vars, 100*temp(:,:,step_iter), lh, 8, 2);
temp(:,:,step_iter),lh,8,2);
if options_.TeX if options_.TeX
headers=M_.exo_names_tex; headers = M_.exo_names_tex;
headers = char(' ',headers,'ME'); headers = vertcat(' ', headers, 'ME');
labels = deblank(var_list_tex(varlist_pos,:)); labels = var_list_tex(varlist_pos);
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyn_latex_table(M_,options_,title_print,[save_name_string,int2str(Steps(step_iter))],headers,labels,100*temp(:,:,step_iter),lh,8,2); dyn_latex_table(M_, options_, title_print, [save_name_string, int2str(Steps(step_iter))], headers, labels, 100*temp(:,:,step_iter), lh, 8, 2);
end end
end end
skipline(); skipline();
end end
end end
end end
end end

View File

@ -1,5 +1,5 @@
function oo_ = ... function oo_ = ...
conditional_variance_decomposition_ME_mc_analysis(NumberOfSimulations, type, dname, fname, Steps, exonames, exo, var_list, endogenous_variable_index, mh_conf_sig, oo_,options_) conditional_variance_decomposition_ME_mc_analysis(NumberOfSimulations, type, dname, fname, Steps, exonames, exo, var_list, endo, mh_conf_sig, oo_,options_)
% This function analyses the (posterior or prior) distribution of the % This function analyses the (posterior or prior) distribution of the
% endogenous variables' conditional variance decomposition with measurement error. % endogenous variables' conditional variance decomposition with measurement error.
% %
@ -14,8 +14,7 @@ function oo_ = ...
% variable % variable
% var_list [string] (n_endo*char_length) character array with name % var_list [string] (n_endo*char_length) character array with name
% of endogenous variables % of endogenous variables
% endogenous_variable_index [integer] index of the current % endo [integer] Current endogenous variable
% endogenous variable
% mh_conf_sig [double] 2 by 1 vector with upper % mh_conf_sig [double] 2 by 1 vector with upper
% and lower bound of HPD intervals % and lower bound of HPD intervals
% oo_ [structure] Dynare structure where the results are saved. % oo_ [structure] Dynare structure where the results are saved.
@ -23,7 +22,7 @@ function oo_ = ...
% OUTPUTS % OUTPUTS
% oo_ [structure] Dynare structure where the results are saved. % oo_ [structure] Dynare structure where the results are saved.
% Copyright (C) 2017 Dynare Team % Copyright (C) 2017-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -48,16 +47,16 @@ else
PATH = [dname '/prior/moments/']; PATH = [dname '/prior/moments/'];
end end
% $$$ indx = check_name(vartan,var); endogenous_variable_index = check_name(var_list, endo);
% $$$ if isempty(indx) if isempty(endogenous_variable_index)
% $$$ disp([ type '_analysis:: ' var ' is not a stationary endogenous variable!']) disp([ type '_analysis:: Can''t find ' endo '!'])
% $$$ return return
% $$$ end end
% $$$ endogenous_variable_index = sum(1:indx);
exogenous_variable_index = check_name(exonames,exo); exogenous_variable_index = check_name(exonames,exo);
if isempty(exogenous_variable_index) if isempty(exogenous_variable_index)
if isequal(exo,'ME') if isequal(exo,'ME')
exogenous_variable_index=size(exonames,1)+1; exogenous_variable_index=length(exonames)+1;
else else
disp([ type '_analysis:: ' exo ' is not a declared exogenous variable!']) disp([ type '_analysis:: ' exo ' is not a declared exogenous variable!'])
return return
@ -65,9 +64,9 @@ if isempty(exogenous_variable_index)
end end
[observable_pos_requested_vars,index_subset,index_observables]=intersect(var_list,options_.varobs,'stable'); [observable_pos_requested_vars,index_subset,index_observables]=intersect(var_list,options_.varobs,'stable');
matrix_pos=strmatch(var_list(endogenous_variable_index,:),var_list(index_subset,:),'exact'); matrix_pos=strmatch(endo, var_list(index_subset),'exact');
name_1 = deblank(var_list(endogenous_variable_index,:)); name_1 = endo;
name_2 = deblank(exo); name_2 = exo;
name = [ name_1 '.' name_2 ]; name = [ name_1 '.' name_2 ];
if isfield(oo_, [ TYPE 'TheoreticalMoments' ]) if isfield(oo_, [ TYPE 'TheoreticalMoments' ])

View File

@ -1,5 +1,5 @@
function oo_ = ... function oo_ = ...
conditional_variance_decomposition_mc_analysis(NumberOfSimulations, type, dname, fname, Steps, exonames, exo, var_list, endogenous_variable_index, mh_conf_sig, oo_,options_) conditional_variance_decomposition_mc_analysis(NumberOfSimulations, type, dname, fname, Steps, exonames, exo, var_list, endo, mh_conf_sig, oo_,options_)
% This function analyses the (posterior or prior) distribution of the % This function analyses the (posterior or prior) distribution of the
% endogenous variables' conditional variance decomposition. % endogenous variables' conditional variance decomposition.
% %
@ -23,7 +23,7 @@ function oo_ = ...
% OUTPUTS % OUTPUTS
% oo_ [structure] Dynare structure where the results are saved. % oo_ [structure] Dynare structure where the results are saved.
% Copyright (C) 2009-2017 Dynare Team % Copyright (C) 2009-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -48,12 +48,6 @@ else
PATH = [dname '/prior/moments/']; PATH = [dname '/prior/moments/'];
end end
% $$$ indx = check_name(vartan,var);
% $$$ if isempty(indx)
% $$$ disp([ type '_analysis:: ' var ' is not a stationary endogenous variable!'])
% $$$ return
% $$$ end
% $$$ endogenous_variable_index = sum(1:indx);
exogenous_variable_index = check_name(exonames,exo); exogenous_variable_index = check_name(exonames,exo);
if isempty(exogenous_variable_index) if isempty(exogenous_variable_index)
if ~isequal(exo,'ME') if ~isequal(exo,'ME')
@ -62,8 +56,14 @@ if isempty(exogenous_variable_index)
return return
end end
name_1 = deblank(var_list(endogenous_variable_index,:)); endogenous_variable_index = check_name(var_list, endo);
name_2 = deblank(exo); if isempty(endogenous_variable_index)
disp([ type '_analysis:: Can''t find ' endo '!'])
return
end
name_1 = endo;
name_2 = exo;
name = [ name_1 '.' name_2 ]; name = [ name_1 '.' name_2 ];
if isfield(oo_, [ TYPE 'TheoreticalMoments' ]) if isfield(oo_, [ TYPE 'TheoreticalMoments' ])

View File

@ -16,7 +16,7 @@ function oo_ = McMCDiagnostics(options_, estim_params_, M_, oo_)
% PARALLEL CONTEXT % PARALLEL CONTEXT
% See the comment in posterior_sampler.m funtion. % See the comment in posterior_sampler.m funtion.
% Copyright (C) 2005-2017 Dynare Team % Copyright (C) 2005-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -77,41 +77,42 @@ TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
FirstMhFile = record.KeepedDraws.FirstMhFile; FirstMhFile = record.KeepedDraws.FirstMhFile;
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws); NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
param_name=[]; param_name = {};
param_name_tex=[]; param_name_tex = {};
for jj=1:npar
for jj = 1:npar
if options_.TeX if options_.TeX
[par_name_temp,par_name_tex_temp]=get_the_name(jj,options_.TeX,M_,estim_params_,options_); [par_name_temp, par_name_tex_temp] = get_the_name(jj, options_.TeX, M_,estim_params_, options_);
param_name = strvcat(param_name,par_name_temp); param_name = vertcat(param_name, par_name_temp);
par_name_tex_temp = strrep(par_name_tex_temp,'$',''); par_name_tex_temp = strrep(par_name_tex_temp,'$','');
param_name_tex = strvcat(param_name_tex,par_name_tex_temp); param_name_tex = vertcat(param_name_tex, par_name_tex_temp);
else else
[par_name_temp]=get_the_name(jj,options_.TeX,M_,estim_params_,options_); par_name_temp = get_the_name(jj, options_.TeX, M_, estim_params_, options_);
param_name = strvcat(param_name,par_name_temp); param_name = vertcat(param_name, par_name_temp);
end end
Draws = GetAllPosteriorDraws(jj,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws); Draws = GetAllPosteriorDraws(jj, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws);
Draws = reshape(Draws,[NumberOfDraws nblck]); Draws = reshape(Draws, [NumberOfDraws nblck]);
Nc = min(1000, NumberOfDraws/2); Nc = min(1000, NumberOfDraws/2);
for ll=1:nblck for ll = 1:nblck
Ifac(ll,jj) = mcmc_ifac(Draws(:,ll), Nc); Ifac(ll,jj) = mcmc_ifac(Draws(:,ll), Nc);
end end
tmp = num2cell(Ifac(:,jj)); tmp = num2cell(Ifac(:,jj));
end end
my_title='MCMC Inefficiency factors per block'; my_title='MCMC Inefficiency factors per block';
IFAC_header='Parameter'; IFAC_header = {'Parameter'};
IFAC_header_tex='Parameter'; IFAC_header_tex = {'Parameter'};
for j=1:nblck for j = 1:nblck
IFAC_header = char(IFAC_header,['Block ' int2str(j)]); IFAC_header = vertcat(IFAC_header, ['Block ' int2str(j)]);
IFAC_header_tex = char(IFAC_header_tex,['Block~' int2str(j)]); IFAC_header_tex = vertcat(IFAC_header_tex, ['Block~' int2str(j)]);
end end
lh = size(param_name,2)+2; lh = cellofchararraymaxlength(param_name)+2;
dyntable(options_,my_title,IFAC_header,param_name,Ifac',lh,12,3); dyntable(options_, my_title, IFAC_header, param_name, Ifac', lh, 12, 3);
skipline() skipline()
if options_.TeX if options_.TeX
dyn_latex_table(M_,options_,my_title,'MCMC_inefficiency_factors',IFAC_header_tex,param_name_tex,Ifac',lh,12,3); dyn_latex_table(M_, options_, my_title, 'MCMC_inefficiency_factors', IFAC_header_tex, param_name_tex, Ifac', lh, 12, 3);
end end
record.InefficiencyFactorsPerBlock = Ifac; record.InefficiencyFactorsPerBlock = Ifac;
update_last_mh_history_file(MetropolisFolder, ModelName, record); update_last_mh_history_file(MetropolisFolder, ModelName, record);
@ -137,25 +138,25 @@ if nblck == 1 % Brooks and Gelman tests need more than one block
first_obs_begin_sample = max(1,ceil(options_.mh_drop*NumberOfDraws)); first_obs_begin_sample = max(1,ceil(options_.mh_drop*NumberOfDraws));
last_obs_begin_sample = first_obs_begin_sample+round(options_.convergence.geweke.geweke_interval(1)*NumberOfDraws*(1-options_.mh_drop)); last_obs_begin_sample = first_obs_begin_sample+round(options_.convergence.geweke.geweke_interval(1)*NumberOfDraws*(1-options_.mh_drop));
first_obs_end_sample = first_obs_begin_sample+round(options_.convergence.geweke.geweke_interval(2)*NumberOfDraws*(1-options_.mh_drop)); first_obs_end_sample = first_obs_begin_sample+round(options_.convergence.geweke.geweke_interval(2)*NumberOfDraws*(1-options_.mh_drop));
param_name=[]; param_name = {};
if options_.TeX if options_.TeX
param_name_tex=[]; param_name_tex = {};
end end
for jj=1:npar for jj=1:npar
if options_.TeX if options_.TeX
[param_name_temp, param_name_tex_temp]= get_the_name(jj,options_.TeX,M_,estim_params_,options_); [param_name_temp, param_name_tex_temp] = get_the_name(jj, options_.TeX, M_, estim_params_, options_);
param_name_tex = strvcat(param_name_tex,strrep(param_name_tex_temp,'$','')); param_name_tex = vertcat(param_name_tex, strrep(param_name_tex_temp, '$',''));
param_name = strvcat(param_name,param_name_temp); param_name = vertcat(param_name, param_name_temp);
else else
param_name_temp = get_the_name(jj,options_.TeX,M_,estim_params_,options_); param_name_temp = get_the_name(jj, options_.TeX, M_,estim_params_, options_);
param_name = strvcat(param_name,param_name_temp); param_name = vertcat(param_name, param_name_temp);
end end
end end
fprintf('\nGeweke (1992) Convergence Tests, based on means of draws %d to %d vs %d to %d.\n',first_obs_begin_sample,last_obs_begin_sample,first_obs_end_sample,NumberOfDraws); fprintf('\nGeweke (1992) Convergence Tests, based on means of draws %d to %d vs %d to %d.\n',first_obs_begin_sample,last_obs_begin_sample,first_obs_end_sample,NumberOfDraws);
fprintf('p-values are for Chi2-test for equality of means.\n'); fprintf('p-values are for Chi2-test for equality of means.\n');
Geweke_header=char('Parameter', 'Post. Mean', 'Post. Std', 'p-val No Taper'); Geweke_header = {'Parameter'; 'Post. Mean'; 'Post. Std'; 'p-val No Taper'};
for ii=1:length(options_.convergence.geweke.taper_steps) for ii = 1:length(options_.convergence.geweke.taper_steps)
Geweke_header=char(Geweke_header,['p-val ' num2str(options_.convergence.geweke.taper_steps(ii)),'% Taper']); Geweke_header = vertcat(Geweke_header, ['p-val ' num2str(options_.convergence.geweke.taper_steps(ii)),'% Taper']);
end end
datamat=NaN(npar,3+length(options_.convergence.geweke.taper_steps)); datamat=NaN(npar,3+length(options_.convergence.geweke.taper_steps));
for jj=1:npar for jj=1:npar
@ -175,22 +176,22 @@ if nblck == 1 % Brooks and Gelman tests need more than one block
[results_vec2] = geweke_moments(param_draws2,options_); [results_vec2] = geweke_moments(param_draws2,options_);
results_struct = geweke_chi2_test(results_vec1,results_vec2,results_struct,options_); results_struct = geweke_chi2_test(results_vec1,results_vec2,results_struct,options_);
eval(['oo_.convergence.geweke.',param_name(jj,:),'=results_struct;']) oo_.convergence.geweke.(param_name{jj}) = results_struct;
datamat(jj,:)=[results_struct.posteriormean,results_struct.posteriorstd,results_struct.prob_chi2_test]; datamat(jj,:)=[results_struct.posteriormean,results_struct.posteriorstd,results_struct.prob_chi2_test];
end end
lh = size(param_name,2)+2; lh = size(param_name,2)+2;
dyntable(options_,'',Geweke_header,param_name,datamat,lh,12,3); dyntable(options_, '', Geweke_header, param_name, datamat, lh, 12, 3);
if options_.TeX if options_.TeX
Geweke_tex_header=char('Parameter', 'Mean', 'Std', 'No\ Taper'); Geweke_tex_header = {'Parameter'; 'Mean'; 'Std'; 'No\ Taper'};
additional_header={[' & \multicolumn{2}{c}{Posterior} & \multicolumn{',num2str(1+length(options_.convergence.geweke.taper_steps)),'}{c}{p-values} \\'], additional_header = {[' & \multicolumn{2}{c}{Posterior} & \multicolumn{',num2str(1+length(options_.convergence.geweke.taper_steps)),'}{c}{p-values} \\'],
['\cmidrule(r{.75em}){2-3} \cmidrule(r{.75em}){4-',num2str(4+length(options_.convergence.geweke.taper_steps)),'}']}; ['\cmidrule(r{.75em}){2-3} \cmidrule(r{.75em}){4-',num2str(4+length(options_.convergence.geweke.taper_steps)),'}']};
for ii=1:length(options_.convergence.geweke.taper_steps) for ii=1:length(options_.convergence.geweke.taper_steps)
Geweke_tex_header=char(Geweke_tex_header,[num2str(options_.convergence.geweke.taper_steps(ii)),'\%%\ Taper']); Geweke_tex_header = vertcat(Geweke_tex_header, [num2str(options_.convergence.geweke.taper_steps(ii)),'\%%\ Taper']);
end end
headers = char(Geweke_tex_header); headers = Geweke_tex_header;
lh = size(param_name_tex,2)+2; lh = cellofchararraymaxlength(param_name_tex)+2;
my_title=sprintf('Geweke (1992) Convergence Tests, based on means of draws %d to %d vs %d to %d. p-values are for $\\\\chi^2$-test for equality of means.',first_obs_begin_sample,last_obs_begin_sample,first_obs_end_sample,NumberOfDraws); my_title=sprintf('Geweke (1992) Convergence Tests, based on means of draws %d to %d vs %d to %d. p-values are for $\\\\chi^2$-test for equality of means.',first_obs_begin_sample,last_obs_begin_sample,first_obs_end_sample,NumberOfDraws);
dyn_latex_table(M_,options_,my_title,'geweke',headers,param_name_tex,datamat,lh,12,4,additional_header); dyn_latex_table(M_, options_, my_title, 'geweke', headers, param_name_tex, datamat, lh, 12, 4, additional_header);
end end
skipline(2); skipline(2);
@ -206,17 +207,16 @@ if nblck == 1 % Brooks and Gelman tests need more than one block
oo_.Raftery_Lewis = raftery_lewis(x2,Raftery_Lewis_q,Raftery_Lewis_r,Raftery_Lewis_s); oo_.Raftery_Lewis = raftery_lewis(x2,Raftery_Lewis_q,Raftery_Lewis_r,Raftery_Lewis_s);
oo_.Raftery_Lewis.parameter_names=param_name; oo_.Raftery_Lewis.parameter_names=param_name;
my_title=sprintf('Raftery/Lewis (1992) Convergence Diagnostics, based on quantile q=%4.3f with precision r=%4.3f with probability s=%4.3f.',Raftery_Lewis_q,Raftery_Lewis_r,Raftery_Lewis_s); my_title=sprintf('Raftery/Lewis (1992) Convergence Diagnostics, based on quantile q=%4.3f with precision r=%4.3f with probability s=%4.3f.',Raftery_Lewis_q,Raftery_Lewis_r,Raftery_Lewis_s);
headers = char('Variables','M (burn-in)','N (req. draws)','N+M (total draws)','k (thinning)'); headers = {'Variables'; 'M (burn-in)'; 'N (req. draws)'; 'N+M (total draws)'; 'k (thinning)'};
raftery_data_mat=[oo_.Raftery_Lewis.M_burn,oo_.Raftery_Lewis.N_prec,oo_.Raftery_Lewis.N_total,oo_.Raftery_Lewis.k_thin]; raftery_data_mat=[oo_.Raftery_Lewis.M_burn,oo_.Raftery_Lewis.N_prec,oo_.Raftery_Lewis.N_total,oo_.Raftery_Lewis.k_thin];
raftery_data_mat=[raftery_data_mat;max(raftery_data_mat)]; raftery_data_mat=[raftery_data_mat;max(raftery_data_mat)];
labels_Raftery_Lewis=char(param_name,'Maximum'); labels_Raftery_Lewis = vertcat(param_name, 'Maximum');
lh = size(labels_Raftery_Lewis,2)+2; lh = cellofchararraymaxlength(labels_Raftery_Lewis)+2;
dyntable(options_,my_title,headers,labels_Raftery_Lewis,raftery_data_mat,lh,10,0); dyntable(options_, my_title, headers, labels_Raftery_Lewis, raftery_data_mat, lh, 10, 0);
if options_.TeX if options_.TeX
labels_Raftery_Lewis_tex=char(param_name_tex,'Maximum'); labels_Raftery_Lewis_tex = vertcat(param_name_tex, 'Maximum');
lh = size(labels_Raftery_Lewis_tex,2)+2; lh = cellofchararraymaxlength(labels_Raftery_Lewis_tex)+2;
dyn_latex_table(M_,options_,my_title,'raftery_lewis',headers,labels_Raftery_Lewis_tex,raftery_data_mat,lh,10,0); dyn_latex_table(M_, options_, my_title, 'raftery_lewis', headers, labels_Raftery_Lewis_tex, raftery_data_mat, lh, 10, 0);
end end
end end

View File

@ -17,7 +17,7 @@ function datatomfile (s, var_list, names)
% provided, all the variables as defined in M_.endo_names will be saved in % provided, all the variables as defined in M_.endo_names will be saved in
% the generated m file. % the generated m file.
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -40,24 +40,28 @@ global M_ oo_
sm=[s,'.m']; sm=[s,'.m'];
fid=fopen(sm,'w') ; fid=fopen(sm,'w') ;
if nargin < 2 || size(var_list,1) == 0 if nargin < 2 || isempty(var_list)
var_list = M_.endo_names(1:M_.orig_endo_nbr,:); var_list = M_.endo_names(1:M_.orig_endo_nbr);
end end
n = size(var_list,1); n = length(var_list);
ivar=zeros(n,1);
if nargin==3 if nargin==3
if ~isequal(size(var_list,1),n) names = cellstr(names);
n = length(names);
if ~isequal(length(var_list), n)
error('datatomfile:: Second and third arguments must have the same number of rows (variables)!') error('datatomfile:: Second and third arguments must have the same number of rows (variables)!')
end end
else else
names = var_list; names = var_list;
n = length(names);
end end
ivar=zeros(n, 1);
% Get indices for the endogenous variables. % Get indices for the endogenous variables.
for i=1:n for i=1:n
i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact'); i_tmp = strmatch(var_list{i}, M_.endo_names, 'exact');
if isempty(i_tmp) if isempty(i_tmp)
error (['One of the specified variables does not exist']) ; error (['One of the specified variables does not exist']) ;
else else
@ -69,7 +73,7 @@ fprintf(fid,'%% Dataset generated by %s.\n',stack(2).file);
fprintf(fid,['%% ' datestr(now,0) '\n']); fprintf(fid,['%% ' datestr(now,0) '\n']);
% Save the selected data. % Save the selected data.
for i = 1:n for i = 1:n
fprintf(fid,[strtrim(names(i,:)), ' = ['],'\n') ; fprintf(fid,[names{i}, ' = ['],'\n') ;
fprintf(fid,'\n') ; fprintf(fid,'\n') ;
fprintf(fid,'%15.8g\n',oo_.endo_simul(ivar(i),:)') ; fprintf(fid,'%15.8g\n',oo_.endo_simul(ivar(i),:)') ;
fprintf(fid,'];\n') ; fprintf(fid,'];\n') ;

View File

@ -1,6 +1,6 @@
function info = discretionary_policy(var_list) function info = discretionary_policy(var_list)
% Copyright (C) 2007-2015 Dynare Team % Copyright (C) 2007-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -27,9 +27,8 @@ info = stoch_simul(var_list);
if options_.noprint == 0 if options_.noprint == 0
disp_steady_state(M_,oo_) disp_steady_state(M_,oo_)
for i=M_.orig_endo_nbr:M_.endo_nbr for i=M_.orig_endo_nbr:M_.endo_nbr
if strmatch('mult_',M_.endo_names(i,:)) if strmatch('mult_', M_.endo_names{i})
disp(sprintf('%s \t\t %g',M_.endo_names(i,:), ... disp(sprintf('%s \t\t %g', M_.endo_names{i}, oo_.dr.ys(i)));
oo_.dr.ys(i)));
end end
end end
end end

View File

@ -1,6 +1,6 @@
function [dr,ys,info]=discretionary_policy_1(oo_,Instruments) function [dr,ys,info]=discretionary_policy_1(oo_,Instruments)
% Copyright (C) 2007-2017 Dynare Team % Copyright (C) 2007-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -42,7 +42,7 @@ else
M_.orig_model = M_; M_.orig_model = M_;
end end
beta = get_optimal_policy_discount_factor(M_.params,M_.param_names); beta = get_optimal_policy_discount_factor(M_.params, M_.param_names);
exo_nbr = M_.exo_nbr; exo_nbr = M_.exo_nbr;
if isfield(M_,'orig_model') if isfield(M_,'orig_model')
@ -70,7 +70,7 @@ end
if any(any(Uy~=0)) if any(any(Uy~=0))
non_zero_derivs=find(any(Uy~=0)); non_zero_derivs=find(any(Uy~=0));
for ii=1:length(non_zero_derivs) for ii=1:length(non_zero_derivs)
non_zero_deriv_names{ii,1}=deblank(M_.endo_names(non_zero_derivs(ii),:)); non_zero_deriv_names{ii,1} = M_.endo_names{non_zero_derivs(ii)};
end end
disp_string=[non_zero_deriv_names{1,:}]; disp_string=[non_zero_deriv_names{1,:}];
for ii=2:size(non_zero_deriv_names,1) for ii=2:size(non_zero_deriv_names,1)
@ -116,7 +116,7 @@ end
instr_id=nan(instr_nbr,1); instr_id=nan(instr_nbr,1);
for j=1:instr_nbr for j=1:instr_nbr
vj=deblank(Instruments(j,:)); vj=deblank(Instruments(j,:));
vj_id=strmatch(vj,endo_names,'exact'); vj_id=strmatch(vj, endo_names, 'exact');
if ~isempty(vj_id) if ~isempty(vj_id)
instr_id(j)=vj_id; instr_id(j)=vj_id;
else else

View File

@ -8,7 +8,7 @@ function disp_dr(dr,order,var_list)
% var_list [char array]: list of endogenous variables for which the % var_list [char array]: list of endogenous variables for which the
% decision rules should be printed % decision rules should be printed
% %
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -43,17 +43,17 @@ else
k1 = dr.order_var; k1 = dr.order_var;
end end
if size(var_list,1) == 0 if isempty(var_list)
var_list = M_.endo_names(1:M_.orig_endo_nbr, :); var_list = M_.endo_names(1:M_.orig_endo_nbr);
end end
nvar = size(var_list,1); nvar = length(var_list);
ivar=zeros(nvar,1); ivar=zeros(nvar,1);
for i=1:nvar for i=1:nvar
i_tmp = strmatch(var_list(i,:),M_.endo_names(k1,:),'exact'); i_tmp = strmatch(var_list{i}, M_.endo_names(k1), 'exact');
if isempty(i_tmp) if isempty(i_tmp)
disp(var_list(i,:)); disp(var_list{i});
error (['One of the variable specified does not exist']) ; error (['One of the variable specified does not exist']) ;
else else
ivar(i) = i_tmp; ivar(i) = i_tmp;
@ -63,7 +63,7 @@ end
% get length of display strings % get length of display strings
header_label_length=16; %default header_label_length=16; %default
for ii=1:length(ivar) for ii=1:length(ivar)
header_label_length=max(header_label_length,length(deblank(M_.endo_names(k1(ivar(ii)),:)))+2); header_label_length = max(header_label_length,length(M_.endo_names{k1(ivar(ii))})+2);
end end
header_label_format = sprintf('%%%ds',header_label_length); header_label_format = sprintf('%%%ds',header_label_length);
value_format_float = sprintf('%%%d.6f',header_label_length); value_format_float = sprintf('%%%d.6f',header_label_length);
@ -81,7 +81,7 @@ else
aux_var_additional_characters=0; aux_var_additional_characters=0;
end end
var_name_width=max([max(size(deblank(M_.endo_names(k1(ivar),:)),2)),max(size(deblank(M_.exo_names),2))]); var_name_width = max([cellofchararraymaxlength(M_.endo_names(k1(ivar))), cellofchararraymaxlength(M_.exo_names)]);
%deal with covariances %deal with covariances
if order > 1 if order > 1
@ -97,7 +97,7 @@ disp('POLICY AND TRANSITION FUNCTIONS')
% variable names % variable names
str = char(32*ones(1,var_name_width)); str = char(32*ones(1,var_name_width));
for i=1:nvar for i=1:nvar
str = [str sprintf(header_label_format,deblank(M_.endo_names(k1(ivar(i)),:)))]; str = [str sprintf(header_label_format, M_.endo_names{k1(ivar(i))})];
end end
disp(str); disp(str);
% %
@ -150,10 +150,10 @@ end
% %
for k=1:nu for k=1:nu
flag = 0; flag = 0;
str = sprintf(label_format,M_.exo_names(k,:)); str = sprintf(label_format, M_.exo_names{k});
for i=1:nvar for i=1:nvar
x = dr.ghu(ivar(i),k); x = dr.ghu(ivar(i),k);
[str,flag]=get_print_string(str,x,value_format_zero,value_format_float,flag,options_); [str,flag] = get_print_string(str, x, value_format_zero, value_format_float, flag, options_);
end end
if flag if flag
disp(str) disp(str)
@ -167,7 +167,7 @@ if order > 1
flag = 0; flag = 0;
str1 = sprintf('%s,%s',subst_auxvar(k1(klag(k,1)),klag(k,2)-M_.maximum_lag-2), ... str1 = sprintf('%s,%s',subst_auxvar(k1(klag(k,1)),klag(k,2)-M_.maximum_lag-2), ...
subst_auxvar(k1(klag(j,1)),klag(j,2)-M_.maximum_lag-2)); subst_auxvar(k1(klag(j,1)),klag(j,2)-M_.maximum_lag-2));
str = sprintf(label_format,str1); str = sprintf(label_format, str1);
for i=1:nvar for i=1:nvar
if k == j if k == j
x = dr.ghxx(ivar(i),(k-1)*nx+j)/2; x = dr.ghxx(ivar(i),(k-1)*nx+j)/2;
@ -187,14 +187,14 @@ if order > 1
for k = 1:nu for k = 1:nu
for j = 1:k for j = 1:k
flag = 0; flag = 0;
str = sprintf(label_format,[deblank(M_.exo_names(k,:)) ',' deblank(M_.exo_names(j,:))] ); str = sprintf(label_format, [M_.exo_names{k} ',' M_.exo_names{j}]);
for i=1:nvar for i=1:nvar
if k == j if k == j
x = dr.ghuu(ivar(i),(k-1)*nu+j)/2; x = dr.ghuu(ivar(i),(k-1)*nu+j)/2;
else else
x = dr.ghuu(ivar(i),(k-1)*nu+j); x = dr.ghuu(ivar(i),(k-1)*nu+j);
end end
[str,flag]=get_print_string(str,x,value_format_zero,value_format_float,flag,options_); [str,flag]=get_print_string(str, x, value_format_zero, value_format_float, flag, options_);
end end
if flag if flag
disp(str) disp(str)
@ -207,8 +207,7 @@ if order > 1
for k = 1:nx for k = 1:nx
for j = 1:nu for j = 1:nu
flag = 0; flag = 0;
str1 = sprintf('%s,%s',subst_auxvar(k1(klag(k,1)),klag(k,2)-M_.maximum_lag-2), ... str1 = sprintf('%s,%s',subst_auxvar(k1(klag(k,1)),klag(k,2)-M_.maximum_lag-2), M_.exo_names{j});
deblank(M_.exo_names(j,:)));
str = sprintf(label_format,str1); str = sprintf(label_format,str1);
for i=1:nvar for i=1:nvar
x = dr.ghxu(ivar(i),(k-1)*nu+j); x = dr.ghxu(ivar(i),(k-1)*nu+j);
@ -230,41 +229,40 @@ function str = subst_auxvar(aux_index, aux_lead_lag)
global M_ global M_
if aux_index <= M_.orig_endo_nbr if aux_index <= M_.orig_endo_nbr
str = sprintf('%s(%d)', deblank(M_.endo_names(aux_index,:)), aux_lead_lag); str = sprintf('%s(%d)', M_.endo_names{aux_index}, aux_lead_lag);
return return
end end
for i = 1:length(M_.aux_vars) for i = 1:length(M_.aux_vars)
if M_.aux_vars(i).endo_index == aux_index if M_.aux_vars(i).endo_index == aux_index
switch M_.aux_vars(i).type switch M_.aux_vars(i).type
case 0 case 0
str = sprintf('%s(%d)',deblank(M_.endo_names(aux_index,:)),aux_lead_lag); str = sprintf('%s(%d)', M_.endo_names{aux_index}, aux_lead_lag);
return return
case 1 case 1
orig_name = deblank(M_.endo_names(M_.aux_vars(i).orig_index, :)); orig_name = M_.endo_names{M_.aux_vars(i).orig_index};
case 3 case 3
orig_name = deblank(M_.exo_names(M_.aux_vars(i).orig_index, :)); orig_name = M_.exo_names{M_.aux_vars(i).orig_index};
case 4 case 4
str = sprintf('EXPECTATION(%d)(...)', aux_lead_lag); str = sprintf('EXPECTATION(%d)(...)', aux_lead_lag);
return return
case 6 case 6
str = sprintf('%s(%d)', ... str = sprintf('%s(%d)', M_.endo_names{M_.aux_vars(i).endo_index}, aux_lead_lag);
deblank(M_.endo_names(M_.aux_vars(i).endo_index, :)),aux_lead_lag);
return return
otherwise otherwise
error(sprintf('Invalid auxiliary type: %s', M_.endo_names(aux_index, :))) error(sprintf('Invalid auxiliary type: %s', M_.endo_names{aux_index}))
end end
str = sprintf('%s(%d)', orig_name, M_.aux_vars(i).orig_lead_lag+aux_lead_lag); str = sprintf('%s(%d)', orig_name, M_.aux_vars(i).orig_lead_lag+aux_lead_lag);
return return
end end
end end
error(sprintf('Could not find aux var: %s', M_.endo_names(aux_index, :))) error(sprintf('Could not find aux var: %s', M_.endo_names{aux_index}))
end end
function [str,flag]=get_print_string(str,x,value_format_zero,value_format_float,flag,options_) function [str,flag]=get_print_string(str, x, value_format_zero, value_format_float, flag, options_)
if abs(x) >= options_.dr_display_tol if abs(x) >= options_.dr_display_tol
flag = 1; flag = 1;
str = [str sprintf(value_format_float,x)]; str = [str sprintf(value_format_float, x)];
else else
str = [str sprintf(value_format_zero,0)]; str = [str sprintf(value_format_zero, 0)];
end end
end end

View File

@ -8,7 +8,7 @@ function disp_model_summary(M,dr,options)
% dr [matlab structure] Decision rules % dr [matlab structure] Decision rules
% options [matlab structure] Options % options [matlab structure] Options
% %
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -36,7 +36,7 @@ disp([' Number of jumpers: ' ...
int2str(length(find(dr.kstate(:,2) == M.maximum_lag+2)))]) int2str(length(find(dr.kstate(:,2) == M.maximum_lag+2)))])
disp([' Number of static variables: ' int2str(M.nstatic)]) disp([' Number of static variables: ' int2str(M.nstatic)])
my_title='MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS'; my_title='MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS';
labels = deblank(M.exo_names); labels = M.exo_names;
headers = char('Variables',labels); headers = vertcat('Variables', labels);
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyntable(options,my_title,headers,labels,M.Sigma_e,lh,10,6); dyntable(options, my_title, headers, labels, M.Sigma_e, lh, 10, 6);

View File

@ -11,7 +11,7 @@ function oo_=disp_moments(y,var_list,M_,options_,oo_)
% OUTPUTS % OUTPUTS
% oo_ [structure] Dynare's results structure, % oo_ [structure] Dynare's results structure,
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -31,16 +31,16 @@ function oo_=disp_moments(y,var_list,M_,options_,oo_)
warning_old_state = warning; warning_old_state = warning;
warning off warning off
if size(var_list,1) == 0 if isempty(var_list)
var_list = M_.endo_names(1:M_.orig_endo_nbr, :); var_list = M_.endo_names(1:M_.orig_endo_nbr);
end end
nvar = size(var_list,1); nvar = length(var_list);
ivar=zeros(nvar,1); ivar=zeros(nvar,1);
for i=1:nvar for i=1:nvar
i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact'); i_tmp = strmatch(var_list{i}, M_.endo_names, 'exact');
if isempty(i_tmp) if isempty(i_tmp)
error (['One of the variable specified does not exist']) ; error ('One of the variable specified does not exist') ;
else else
ivar(i) = i_tmp; ivar(i) = i_tmp;
end end
@ -50,7 +50,7 @@ y = y(ivar,options_.drop+1:end)';
ME_present=0; ME_present=0;
if ~all(M_.H==0) if ~all(M_.H==0)
[observable_pos_requested_vars,index_subset,index_observables]=intersect(ivar,options_.varobs_id,'stable'); [observable_pos_requested_vars, index_subset, index_observables] = intersect(ivar, options_.varobs_id, 'stable');
if ~isempty(observable_pos_requested_vars) if ~isempty(observable_pos_requested_vars)
ME_present=1; ME_present=1;
i_ME = setdiff([1:size(M_.H,1)],find(diag(M_.H) == 0)); % find ME with 0 variance i_ME = setdiff([1:size(M_.H,1)],find(diag(M_.H) == 0)); % find ME with 0 variance
@ -79,20 +79,17 @@ oo_.var = y'*y/size(y,1);
oo_.skewness = (mean(y.^3)./s2.^1.5)'; oo_.skewness = (mean(y.^3)./s2.^1.5)';
oo_.kurtosis = (mean(y.^4)./(s2.*s2)-3)'; oo_.kurtosis = (mean(y.^4)./(s2.*s2)-3)';
labels = deblank(M_.endo_names(ivar,:)); labels = M_.endo_names(ivar);
labels_TeX = deblank(M_.endo_names_tex(ivar,:)); labels_TeX = M_.endo_names_tex(ivar);
if options_.nomoments == 0 if options_.nomoments == 0
z = [ m' s' s2' (mean(y.^3)./s2.^1.5)' (mean(y.^4)./(s2.*s2)-3)' ]; z = [ m' s' s2' (mean(y.^3)./s2.^1.5)' (mean(y.^4)./(s2.*s2)-3)' ];
title='MOMENTS OF SIMULATED VARIABLES'; title='MOMENTS OF SIMULATED VARIABLES';
title=add_filter_subtitle(title, options_);
title=add_filter_subtitle(title,options_); headers = {'VARIABLE'; 'MEAN'; 'STD. DEV.'; 'VARIANCE'; 'SKEWNESS'; 'KURTOSIS'};
dyntable(options_, title, headers, labels, z, cellofchararraymaxlength(labels)+2, 16, 6);
headers=char('VARIABLE','MEAN','STD. DEV.','VARIANCE','SKEWNESS', ...
'KURTOSIS');
dyntable(options_,title,headers,labels,z,size(labels,2)+2,16,6);
if options_.TeX if options_.TeX
dyn_latex_table(M_,options_,title,'sim_moments',headers,labels_TeX,z,size(labels,2)+2,16,6); dyn_latex_table(M_, options_, title, 'sim_moments', headers, labels_TeX, z, cellofchararraymaxlength(labels)+2, 16, 6);
end end
end end
@ -103,15 +100,13 @@ if options_.nocorr == 0
end end
if options_.noprint == 0 if options_.noprint == 0
title = 'CORRELATION OF SIMULATED VARIABLES'; title = 'CORRELATION OF SIMULATED VARIABLES';
title=add_filter_subtitle(title,options_); title=add_filter_subtitle(title,options_);
headers = vertcat('VARIABLE', M_.endo_names(ivar));
headers = char('VARIABLE',M_.endo_names(ivar,:)); dyntable(options_, title, headers, labels, corr, cellofchararraymaxlength(labels)+2, 8, 4);
dyntable(options_,title,headers,labels,corr,size(labels,2)+2,8,4);
if options_.TeX if options_.TeX
headers = char('VARIABLE',M_.endo_names_tex(ivar,:)); headers = vertcat('VARIABLE', M_.endo_names_tex(ivar));
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyn_latex_table(M_,options_,title,'sim_corr_matrix',headers,labels_TeX,corr,size(labels,2)+2,8,4); dyn_latex_table(M_, options_, title, 'sim_corr_matrix', headers, labels_TeX, corr, lh, 8,4);
end end
end end
end end
@ -130,12 +125,12 @@ if ar > 0
if options_.noprint == 0 if options_.noprint == 0
title = 'AUTOCORRELATION OF SIMULATED VARIABLES'; title = 'AUTOCORRELATION OF SIMULATED VARIABLES';
title=add_filter_subtitle(title,options_); title=add_filter_subtitle(title,options_);
headers = char('VARIABLE',int2str([1:ar]')); headers = vertcat('VARIABLE', cellstr(int2str([1:ar]')));
dyntable(options_,title,headers,labels,autocorr,size(labels,2)+2,8,4); dyntable(options_, title, headers, labels, autocorr, cellofchararraymaxlength(labels)+2, 8, 4);
if options_.TeX if options_.TeX
headers = char('VARIABLE',int2str([1:ar]')); headers = vertcat('VARIABLE', cellstr(int2str([1:ar]')));
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyn_latex_table(M_,options_,title,'sim_autocorr_matrix',headers,labels_TeX,autocorr,size(labels_TeX,2)+2,8,4); dyn_latex_table(M_, options_, title, 'sim_autocorr_matrix', headers, labels_TeX, autocorr, cellofchararraymaxlength(labels_TeX)+2, 8, 4);
end end
end end
@ -180,28 +175,31 @@ if ~options_.nodecomposition
if ~options_.noprint %options_.nomoments == 0 if ~options_.noprint %options_.nomoments == 0
skipline() skipline()
title='VARIANCE DECOMPOSITION SIMULATING ONE SHOCK AT A TIME (in percent)'; title='VARIANCE DECOMPOSITION SIMULATING ONE SHOCK AT A TIME (in percent)';
title=add_filter_subtitle(title,options_); title=add_filter_subtitle(title,options_);
headers = M_.exo_names; headers = M_.exo_names;
headers(M_.exo_names_orig_ord,:) = headers; headers(M_.exo_names_orig_ord) = headers;
headers = char(' ',headers); headers = vertcat(' ', headers);
lh = size(deblank(M_.endo_names(ivar,:)),2)+2; lh = cellofchararraymaxlength(M_.endo_names(ivar))+2;
dyntable(options_,title,char(headers,'Tot. lin. contr.'),deblank(M_.endo_names(ivar,:)),[oo_.variance_decomposition sum(oo_.variance_decomposition,2)],lh,8,2); dyntable(options_, title, vertcat(headers, 'Tot. lin. contr.'), ...
M_.endo_names(ivar), [oo_.variance_decomposition sum(oo_.variance_decomposition,2)], lh, 8, 2);
if ME_present if ME_present
headers_ME=char(headers,'ME'); headers_ME = vertcat(headers, 'ME');
dyntable(options_,[title,' WITH MEASUREMENT ERROR'],char(headers_ME,'Tot. lin. contr.'),deblank(M_.endo_names(ivar(index_subset), ... dyntable(options_, [title,' WITH MEASUREMENT ERROR'], vertcat(headers_ME, 'Tot. lin. contr.'), M_.endo_names(ivar(index_subset)), ...
:)),[oo_.variance_decomposition_ME sum(oo_.variance_decomposition_ME,2)],lh,8,2); [oo_.variance_decomposition_ME sum(oo_.variance_decomposition_ME, 2)], lh, 8, 2);
end end
if options_.TeX if options_.TeX
headers=M_.exo_names_tex; headers = M_.exo_names_tex;
headers = char(' ',headers); headers = vertcat(' ', headers);
labels = deblank(M_.endo_names_tex(ivar,:)); labels = M_.endo_names_tex(ivar);
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyn_latex_table(M_,options_,title,'sim_var_decomp',char(headers,'Tot. lin. contr.'),labels_TeX,[oo_.variance_decomposition sum(oo_.variance_decomposition,2)],lh,8,2); dyn_latex_table(M_, options_, title, 'sim_var_decomp', vertcat(headers, 'Tot. lin. contr.'), ...
labels_TeX, [oo_.variance_decomposition sum(oo_.variance_decomposition, 2)], lh, 8, 2);
if ME_present if ME_present
headers_ME=char(headers,'ME'); headers_ME = vertcat(headers, 'ME');
dyn_latex_table(M_,options_,[title,' WITH MEASUREMENT ERROR'],'sim_var_decomp_ME',char(headers_ME,'Tot. lin. contr.'),labels_TeX(ivar(index_subset),:),[oo_.variance_decomposition_ME sum(oo_.variance_decomposition_ME,2)],lh,8,2); dyn_latex_table(M_, options_, [title, ' WITH MEASUREMENT ERROR'], 'sim_var_decomp_ME', ...
vertcat(headers_ME, 'Tot. lin. contr.'), ...
labels_TeX(ivar(index_subset)), ...
[oo_.variance_decomposition_ME sum(oo_.variance_decomposition_ME, 2)], lh, 8, 2);
end end
end end
@ -218,7 +216,7 @@ end
warning(warning_old_state); warning(warning_old_state);
end end
function y=get_filtered_time_series(y,m,options_) function y = get_filtered_time_series(y, m, options_)
if options_.hp_filter && ~options_.one_sided_hp_filter && ~options_.bandpass.indicator if options_.hp_filter && ~options_.one_sided_hp_filter && ~options_.bandpass.indicator
[hptrend,y] = sample_hp_filter(y,options_.hp_filter); [hptrend,y] = sample_hp_filter(y,options_.hp_filter);

View File

@ -12,7 +12,7 @@ function disp_steady_state(M,oo)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -34,6 +34,7 @@ disp('STEADY-STATE RESULTS:')
skipline() skipline()
endo_names = M.endo_names; endo_names = M.endo_names;
steady_state = oo.steady_state; steady_state = oo.steady_state;
for i=1:M.orig_endo_nbr
disp(sprintf('%s \t\t %g',endo_names(i,:),steady_state(i))); for i = 1:M.orig_endo_nbr
disp(sprintf('%s \t\t %g', endo_names{i}, steady_state(i)));
end end

View File

@ -1,7 +1,8 @@
function oo_=disp_th_moments(dr,var_list,M_,options_,oo_) function oo_ = disp_th_moments(dr, var_list, M_, options_, oo_)
% Display theoretical moments of variables % Display theoretical moments of variables
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -22,21 +23,21 @@ nodecomposition = options_.nodecomposition;
if options_.one_sided_hp_filter if options_.one_sided_hp_filter
error(['disp_th_moments:: theoretical moments incompatible with one-sided HP filter. Use simulated moments instead']) error(['disp_th_moments:: theoretical moments incompatible with one-sided HP filter. Use simulated moments instead'])
end end
if size(var_list,1) == 0 if isempty(var_list)
var_list = M_.endo_names(1:M_.orig_endo_nbr, :); var_list = M_.endo_names(1:M_.orig_endo_nbr);
end end
nvar = size(var_list,1); nvar = length(var_list);
ivar=zeros(nvar,1); ivar=zeros(nvar,1);
for i=1:nvar for i=1:nvar
i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact'); i_tmp = strmatch(var_list{i}, M_.endo_names, 'exact');
if isempty(i_tmp) if isempty(i_tmp)
error (['One of the variable specified does not exist']) ; error ('One of the variable specified does not exist');
else else
ivar(i) = i_tmp; ivar(i) = i_tmp;
end end
end end
[oo_.gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_,options_, nodecomposition); [oo_.gamma_y,stationary_vars] = th_autocovariances(dr, ivar, M_, options_, nodecomposition);
m = dr.ys(ivar); m = dr.ys(ivar);
non_stationary_vars = setdiff(1:length(ivar),stationary_vars); non_stationary_vars = setdiff(1:length(ivar),stationary_vars);
m(non_stationary_vars) = NaN; m(non_stationary_vars) = NaN;
@ -71,75 +72,73 @@ if size(stationary_vars, 1) > 0
end end
if ~options_.noprint %options_.nomoments == 0 if ~options_.noprint %options_.nomoments == 0
if options_.order == 2 if options_.order == 2
title='APPROXIMATED THEORETICAL MOMENTS'; title = 'APPROXIMATED THEORETICAL MOMENTS';
else else
title='THEORETICAL MOMENTS'; title = 'THEORETICAL MOMENTS';
end end
title=add_filter_subtitle(title,options_); title = add_filter_subtitle(title, options_);
headers=char('VARIABLE','MEAN','STD. DEV.','VARIANCE'); headers = {'VARIABLE';'MEAN';'STD. DEV.';'VARIANCE'};
labels = deblank(M_.endo_names(ivar,:)); labels = M_.endo_names(ivar);
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyntable(options_,title,headers,labels,z,lh,11,4); dyntable(options_, title, headers, labels, z, lh, 11, 4);
if options_.TeX if options_.TeX
labels = deblank(M_.endo_names_tex(ivar,:)); labels = M_.endo_names_tex(ivar);
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyn_latex_table(M_,options_,title,'th_moments',headers,labels,z,lh,11,4); dyn_latex_table(M_, options_, title, 'th_moments', headers, labels, z, lh, 11, 4);
end end
if M_.exo_nbr > 1 && ~nodecomposition if M_.exo_nbr > 1 && ~nodecomposition
skipline() skipline()
if options_.order == 2 if options_.order == 2
title='APPROXIMATED VARIANCE DECOMPOSITION (in percent)'; title = 'APPROXIMATED VARIANCE DECOMPOSITION (in percent)';
else else
title='VARIANCE DECOMPOSITION (in percent)'; title = 'VARIANCE DECOMPOSITION (in percent)';
end end
title=add_filter_subtitle(title,options_); title = add_filter_subtitle(title, options_);
headers = M_.exo_names; headers = M_.exo_names;
headers(M_.exo_names_orig_ord,:) = headers; headers(M_.exo_names_orig_ord) = headers;
headers = char(' ',headers); headers = vertcat(' ', headers);
lh = size(deblank(M_.endo_names(ivar(stationary_vars),:)),2)+2; lh = cellofchararraymaxlength(M_.endo_names(ivar(stationary_vars)))+2;
dyntable(options_,title,headers,deblank(M_.endo_names(ivar(stationary_vars), ... dyntable(options_, title, headers, M_.endo_names(ivar(stationary_vars)), 100*oo_.gamma_y{options_.ar+2}(stationary_vars,:), lh, 8, 2);
:)),100* ...
oo_.gamma_y{options_.ar+2}(stationary_vars,:),lh,8,2);
if ME_present if ME_present
[stationary_observables,pos_index_subset]=intersect(index_subset,stationary_vars,'stable'); [stationary_observables, pos_index_subset] = intersect(index_subset, stationary_vars, 'stable');
headers_ME=char(headers,'ME'); headers_ME = vertcat(headers, 'ME');
dyntable(options_,[title,' WITH MEASUREMENT ERROR'],headers_ME,deblank(M_.endo_names(ivar(stationary_observables), ... dyntable(options_, [title,' WITH MEASUREMENT ERROR'], headers_ME, M_.endo_names(ivar(stationary_observables)), ...
:)),oo_.variance_decomposition_ME(pos_index_subset,:),lh,8,2); oo_.variance_decomposition_ME(pos_index_subset,:), lh, 8, 2);
end end
if options_.TeX if options_.TeX
headers=M_.exo_names_tex; headers = M_.exo_names_tex;
headers = char(' ',headers); headers = vertcat(' ', headers);
labels = deblank(M_.endo_names_tex(ivar(stationary_vars),:)); labels = M_.endo_names_tex(ivar(stationary_vars));
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyn_latex_table(M_,options_,title,'th_var_decomp_uncond',headers,labels,100*oo_.gamma_y{options_.ar+2}(stationary_vars,:),lh,8,2); dyn_latex_table(M_, options_, title, 'th_var_decomp_uncond', headers, labels, 100*oo_.gamma_y{options_.ar+2}(stationary_vars,:), lh, 8, 2);
if ME_present if ME_present
headers_ME=char(headers,'ME'); headers_ME = vertcat(headers, 'ME');
dyn_latex_table(M_,options_,[title,' WITH MEASUREMENT ERROR'],'th_var_decomp_uncond_ME',headers_ME,labels,oo_.variance_decomposition_ME(pos_index_subset,:),lh,8,2); dyn_latex_table(M_, options_, [title,' WITH MEASUREMENT ERROR'], ...
'th_var_decomp_uncond_ME', headers_ME, labels, oo_.variance_decomposition_ME(pos_index_subset,:), lh, 8, 2);
end end
end end
end end
end end
conditional_variance_steps = options_.conditional_variance_decomposition; conditional_variance_steps = options_.conditional_variance_decomposition;
if length(conditional_variance_steps) if length(conditional_variance_steps)
StateSpaceModel.number_of_state_equations = M_.endo_nbr; StateSpaceModel.number_of_state_equations = M_.endo_nbr;
StateSpaceModel.number_of_state_innovations = M_.exo_nbr; StateSpaceModel.number_of_state_innovations = M_.exo_nbr;
StateSpaceModel.sigma_e_is_diagonal = M_.sigma_e_is_diagonal; StateSpaceModel.sigma_e_is_diagonal = M_.sigma_e_is_diagonal;
[StateSpaceModel.transition_matrix,StateSpaceModel.impulse_matrix] = kalman_transition_matrix(dr,(1:M_.endo_nbr)',M_.nstatic+(1:M_.nspred)',M_.exo_nbr); [StateSpaceModel.transition_matrix, StateSpaceModel.impulse_matrix] = ...
kalman_transition_matrix(dr,(1:M_.endo_nbr)',M_.nstatic+(1:M_.nspred)',M_.exo_nbr);
StateSpaceModel.state_innovations_covariance_matrix = M_.Sigma_e; StateSpaceModel.state_innovations_covariance_matrix = M_.Sigma_e;
StateSpaceModel.order_var = dr.order_var; StateSpaceModel.order_var = dr.order_var;
StateSpaceModel.measurement_error=M_.H; StateSpaceModel.measurement_error = M_.H;
StateSpaceModel.observable_pos=options_.varobs_id; StateSpaceModel.observable_pos = options_.varobs_id;
[oo_.conditional_variance_decomposition, oo_.conditional_variance_decomposition_ME]= conditional_variance_decomposition(StateSpaceModel,conditional_variance_steps,ivar); [oo_.conditional_variance_decomposition, oo_.conditional_variance_decomposition_ME] = ...
conditional_variance_decomposition(StateSpaceModel, conditional_variance_steps, ivar);
if options_.noprint == 0 if options_.noprint == 0
display_conditional_variance_decomposition(oo_.conditional_variance_decomposition,conditional_variance_steps,... display_conditional_variance_decomposition(oo_.conditional_variance_decomposition, conditional_variance_steps, ivar, M_, options_);
ivar,M_,options_);
if ME_present if ME_present
display_conditional_variance_decomposition(oo_.conditional_variance_decomposition_ME,conditional_variance_steps,... display_conditional_variance_decomposition(oo_.conditional_variance_decomposition_ME, conditional_variance_steps, ...
observable_pos_requested_vars,M_,options_); observable_pos_requested_vars, M_, options_);
end end
end end
end end
end end
@ -151,32 +150,33 @@ if length(i1) == 0
return return
end end
if options_.nocorr == 0 && size(stationary_vars, 1) > 0 if options_.nocorr == 0 && size(stationary_vars, 1)>0
corr=NaN(size(oo_.gamma_y{1})); corr = NaN(size(oo_.gamma_y{1}));
corr(i1,i1) = oo_.gamma_y{1}(i1,i1)./(sd(i1)*sd(i1)'); corr(i1,i1) = oo_.gamma_y{1}(i1,i1)./(sd(i1)*sd(i1)');
if options_.contemporaneous_correlation if options_.contemporaneous_correlation
oo_.contemporaneous_correlation = corr; oo_.contemporaneous_correlation = corr;
end end
if ~options_.noprint if ~options_.noprint
skipline() skipline()
if options_.order == 2 if options_.order==2
title='APPROXIMATED MATRIX OF CORRELATIONS'; title = 'APPROXIMATED MATRIX OF CORRELATIONS';
else else
title='MATRIX OF CORRELATIONS'; title = 'MATRIX OF CORRELATIONS';
end end
title=add_filter_subtitle(title,options_); title = add_filter_subtitle(title, options_);
labels = deblank(M_.endo_names(ivar(i1),:)); labels = M_.endo_names(ivar(i1));
headers = char('Variables',labels); headers = vertcat('Variables', labels);
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyntable(options_,title,headers,labels,corr(i1,i1),lh,8,4); dyntable(options_, title, headers, labels, corr(i1,i1), lh, 8, 4);
if options_.TeX if options_.TeX
labels = deblank(M_.endo_names_tex(ivar(i1),:)); labels = M_.endo_names_tex(ivar(i1));
headers=char('Variables',labels); headers = vertcat('Variables', labels);
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyn_latex_table(M_,options_,title,'th_corr_matrix',headers,labels,corr(i1,i1),lh,8,4); dyn_latex_table(M_, options_, title, 'th_corr_matrix', headers, labels, corr(i1,i1), lh, 8, 4);
end end
end end
end end
if options_.ar > 0 && size(stationary_vars, 1) > 0 if options_.ar > 0 && size(stationary_vars, 1) > 0
z=[]; z=[];
for i=1:options_.ar for i=1:options_.ar
@ -186,20 +186,20 @@ if options_.ar > 0 && size(stationary_vars, 1) > 0
if ~options_.noprint if ~options_.noprint
skipline() skipline()
if options_.order == 2 if options_.order == 2
title='APPROXIMATED COEFFICIENTS OF AUTOCORRELATION'; title = 'APPROXIMATED COEFFICIENTS OF AUTOCORRELATION';
else else
title='COEFFICIENTS OF AUTOCORRELATION'; title = 'COEFFICIENTS OF AUTOCORRELATION';
end end
title=add_filter_subtitle(title,options_); title = add_filter_subtitle(title, options_);
labels = deblank(M_.endo_names(ivar(i1),:)); labels = M_.endo_names(ivar(i1));
headers = char('Order ',int2str([1:options_.ar]')); headers = vertcat('Order ', cellstr(int2str([1:options_.ar]')));
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyntable(options_,title,headers,labels,z,lh,8,4); dyntable(options_, title, headers, labels, z, lh, 8, 4);
if options_.TeX if options_.TeX
labels = deblank(M_.endo_names_tex(ivar(i1),:)); labels = M_.endo_names_tex(ivar(i1));
headers=char('Order ',int2str([1:options_.ar]')); headers = vertcat('Order ', cellstr(int2str([1:options_.ar]')));
lh = size(labels,2)+2; lh = cellofchararraymaxlength(labels)+2;
dyn_latex_table(M_,options_,title,'th_autocorr_matrix',headers,labels,z,lh,8,4); dyn_latex_table(M_, options_, title, 'th_autocorr_matrix', headers, labels, z, lh, 8, 4);
end end
end end
end end

View File

@ -13,7 +13,7 @@ function display_conditional_variance_decomposition(conditional_decomposition_ar
% OUTPUTS % OUTPUTS
% none % none
% %
% Copyright (C) 2010-2017 Dynare Team % Copyright (C) 2010-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -33,18 +33,19 @@ function display_conditional_variance_decomposition(conditional_decomposition_ar
if size(conditional_decomposition_array,3)==M_.exo_nbr %no ME input if size(conditional_decomposition_array,3)==M_.exo_nbr %no ME input
shock_number=M_.exo_nbr; shock_number=M_.exo_nbr;
headers = M_.exo_names; headers = M_.exo_names;
headers(M_.exo_names_orig_ord,:) = headers; headers(M_.exo_names_orig_ord) = headers;
if options_.TeX if options_.TeX
headers_TeX=char('',deblank(M_.exo_names_tex)); headers_TeX = vertcat(' ', M_.exo_names_tex);
end end
title_addon=''; title_addon='';
elseif size(conditional_decomposition_array,3)==M_.exo_nbr+1 %ME input elseif size(conditional_decomposition_array,3)==M_.exo_nbr+1 %ME input
shock_number=M_.exo_nbr+1; shock_number=M_.exo_nbr+1;
headers = M_.exo_names; headers = M_.exo_names;
headers(M_.exo_names_orig_ord,:) = headers; headers(M_.exo_names_orig_ord) = headers;
headers=char(headers,'ME'); headers = vertcat(headers, 'ME');
if options_.TeX if options_.TeX
headers_TeX=char('',deblank(strvcat(M_.exo_names_tex,'ME'))); headers_TeX = vertcat(M_.exo_names_tex, 'ME');
headers_TeX = vertcat(' ', headers_TeX);
end end
title_addon=' - WITH MEASUREMENT ERROR'; title_addon=' - WITH MEASUREMENT ERROR';
else else
@ -61,25 +62,22 @@ else
disp(title) disp(title)
end end
headers = char(' ',headers); headers = vertcat(' ', headers);
lh = size(deblank(M_.endo_names(SubsetOfVariables,:)),2)+2; lh = cellofchararraymaxlength(M_.endo_names(SubsetOfVariables))+2;
if options_.TeX if options_.TeX
labels_TeX = deblank(M_.endo_names_tex(SubsetOfVariables,:)); labels_TeX = M_.endo_names_tex(SubsetOfVariables);
lh = size(labels_TeX,2)+2; lh = cellofchararraymaxlength(labels_TeX)+2;
end end
vardec_i = zeros(length(SubsetOfVariables),shock_number); vardec_i = zeros(length(SubsetOfVariables), shock_number);
for i=1:length(Steps) for i=1:length(Steps)
disp(['Period ' int2str(Steps(i)) ':']) disp(['Period ' int2str(Steps(i)) ':'])
for j=1:shock_number for j=1:shock_number
vardec_i(:,j) = 100*conditional_decomposition_array(:, ... vardec_i(:,j) = 100*conditional_decomposition_array(:,i,j);
i,j);
end end
dyntable(options_,'',headers,... dyntable(options_, '', headers, M_.endo_names(SubsetOfVariables), vardec_i, lh, 8, 2);
deblank(M_.endo_names(SubsetOfVariables,:)),...
vardec_i,lh,8,2);
if options_.TeX if options_.TeX
dyn_latex_table(M_,options_,[title,'; Period ' int2str(Steps(i))],['th_var_decomp_cond_h',int2str(Steps(i))],headers_TeX,labels_TeX,vardec_i,lh,8,2); dyn_latex_table(M_, options_, [title, '; Period ' int2str(Steps(i))], ['th_var_decomp_cond_h', int2str(Steps(i))], headers_TeX, labels_TeX, vardec_i, lh, 8, 2);
end end
end end

View File

@ -10,7 +10,7 @@ function oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_par
% o options_ Matlab's structure describing the options (initialized by dynare, see @ref{options_}). % o options_ Matlab's structure describing the options (initialized by dynare, see @ref{options_}).
% o bayestopt_ Matlab's structure describing the priors (initialized by dynare, see @ref{bayesopt_}). % o bayestopt_ Matlab's structure describing the priors (initialized by dynare, see @ref{bayesopt_}).
% o oo_ Matlab's structure gathering the results (initialized by dynare, see @ref{oo_}). % o oo_ Matlab's structure gathering the results (initialized by dynare, see @ref{oo_}).
% o pnames [string] Character Array storing the names for prior distributions % o pnames [string] Cell of strings storing the names for prior distributions
% o table_title [string] Title of the Table % o table_title [string] Title of the Table
% o field_name [string] String storing the name of the fields for oo_ where the parameters are stored % o field_name [string] String storing the name of the fields for oo_ where the parameters are stored
% %
@ -20,7 +20,7 @@ function oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_par
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% None. % None.
% Copyright (C) 2014-2017 Dynare Team % Copyright (C) 2014-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -49,12 +49,12 @@ disp(['RESULTS FROM ' upper(table_title) ' ESTIMATION'])
LaTeXtitle=strrep(table_title,' ','_'); LaTeXtitle=strrep(table_title,' ','_');
tstath = abs(xparam1)./stdh; tstath = abs(xparam1)./stdh;
header_width = row_header_width(M_,estim_params_,bayestopt_); header_width = row_header_width(M_, estim_params_, bayestopt_);
if strcmp(field_name,'posterior') if strcmp(field_name,'posterior')
tit1 = sprintf('%-*s %7s %8s %7s %4s %6s\n',header_width-2,' ','prior mean', ... tit1 = sprintf('%-*s %7s %8s %7s %4s %6s\n', header_width-2, ' ', 'prior mean', ...
'mode','s.d.','prior','pstdev'); 'mode', 's.d.', 'prior', 'pstdev');
else else
tit1 = sprintf('%-*s %10s %7s %6s\n',header_width-2,' ','Estimate','s.d.','t-stat'); tit1 = sprintf('%-*s %10s %7s %6s\n', header_width-2, ' ', 'Estimate', 's.d.', 't-stat');
end end
if np if np
ip = nvx+nvn+ncx+ncn+1; ip = nvx+nvn+ncx+ncn+1;
@ -66,11 +66,11 @@ if np
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ... fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
header_width,name, ... header_width,name, ...
bayestopt_.p1(ip),xparam1(ip),stdh(ip), ... bayestopt_.p1(ip),xparam1(ip),stdh(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), ... pnames{bayestopt_.pshape(ip)+1}, ...
bayestopt_.p2(ip)); bayestopt_.p2(ip));
else else
fprintf('%-*s %8.4f %7.4f %7.4f \n', ... fprintf('%-*s %8.4f %7.4f %7.4f \n', ...
header_width,name,xparam1(ip),stdh(ip),tstath(ip)); header_width, name, xparam1(ip), stdh(ip), tstath(ip));
end end
eval(['oo_.' field_name '_mode.parameters.' name ' = xparam1(ip);']); eval(['oo_.' field_name '_mode.parameters.' name ' = xparam1(ip);']);
eval(['oo_.' field_name '_std_at_mode.parameters.' name ' = stdh(ip);']); eval(['oo_.' field_name '_std_at_mode.parameters.' name ' = stdh(ip);']);
@ -84,14 +84,14 @@ if nvx
disp(tit1) disp(tit1)
for i=1:nvx for i=1:nvx
k = estim_params_.var_exo(i,1); k = estim_params_.var_exo(i,1);
name = deblank(M_.exo_names(k,:)); name = M_.exo_names{k};
if strcmp(field_name,'posterior') if strcmp(field_name,'posterior')
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ... fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
header_width,name,bayestopt_.p1(ip),xparam1(ip), ... header_width, name, bayestopt_.p1(ip), xparam1(ip), ...
stdh(ip),pnames(bayestopt_.pshape(ip)+1,:), ... stdh(ip), pnames{bayestopt_.pshape(ip)+1}, ...
bayestopt_.p2(ip)); bayestopt_.p2(ip));
else else
fprintf('%-*s %8.4f %7.4f %7.4f \n',header_width,name,xparam1(ip),stdh(ip),tstath(ip)); fprintf('%-*s %8.4f %7.4f %7.4f \n', header_width, name, xparam1(ip), stdh(ip), tstath(ip));
end end
M_.Sigma_e(k,k) = xparam1(ip)*xparam1(ip); M_.Sigma_e(k,k) = xparam1(ip)*xparam1(ip);
eval(['oo_.' field_name '_mode.shocks_std.' name ' = xparam1(ip);']); eval(['oo_.' field_name '_mode.shocks_std.' name ' = xparam1(ip);']);
@ -108,12 +108,13 @@ if nvn
name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)}; name = options_.varobs{estim_params_.nvn_observable_correspondence(i,1)};
if strcmp(field_name,'posterior') if strcmp(field_name,'posterior')
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ... fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
header_width,name,bayestopt_.p1(ip), ... header_width, name, bayestopt_.p1(ip), ...
xparam1(ip),stdh(ip), ... xparam1(ip), stdh(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), ... pnames{bayestopt_.pshape(ip)+1}, ...
bayestopt_.p2(ip)); bayestopt_.p2(ip));
else else
fprintf('%-*s %8.4f %7.4f %7.4f \n',header_width,name,xparam1(ip),stdh(ip),tstath(ip)) fprintf('%-*s %8.4f %7.4f %7.4f \n', header_width, name, xparam1(ip), ...
stdh(ip), tstath(ip))
end end
eval(['oo_.' field_name '_mode.measurement_errors_std.' name ' = xparam1(ip);']); eval(['oo_.' field_name '_mode.measurement_errors_std.' name ' = xparam1(ip);']);
eval(['oo_.' field_name '_std_at_mode.measurement_errors_std.' name ' = stdh(ip);']); eval(['oo_.' field_name '_std_at_mode.measurement_errors_std.' name ' = stdh(ip);']);
@ -129,14 +130,15 @@ if ncx
for i=1:ncx for i=1:ncx
k1 = estim_params_.corrx(i,1); k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2); k2 = estim_params_.corrx(i,2);
name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))]; name = sprintf('%s,%s', M_.exo_names{k1}, M_.exo_names{k2});
NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))]; NAME = sprintf('%s_%s', M_.exo_names{k1}, M_.exo_names{k2});
if strcmp(field_name,'posterior') if strcmp(field_name, 'posterior')
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ... fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
header_width,name,bayestopt_.p1(ip),xparam1(ip),stdh(ip), ... header_width, name, bayestopt_.p1(ip), xparam1(ip), stdh(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.p2(ip)); pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip));
else else
fprintf('%-*s %8.4f %7.4f %7.4f \n', header_width,name,xparam1(ip),stdh(ip),tstath(ip)); fprintf('%-*s %8.4f %7.4f %7.4f \n', header_width,name, xparam1(ip), ...
stdh(ip), tstath(ip));
end end
M_.Sigma_e(k1,k2) = xparam1(ip)*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2)); M_.Sigma_e(k1,k2) = xparam1(ip)*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2); M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
@ -154,14 +156,15 @@ if ncn
for i=1:ncn for i=1:ncn
k1 = estim_params_.corrn(i,1); k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2); k2 = estim_params_.corrn(i,2);
name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))]; name = sprintf('%s,%s', M_.endo_names{k1}, M_.endo_names{k2});
NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))]; NAME = sprintf('%s_%s', M_.endo_names{k1}, M_.endo_names{k2});
if strcmp(field_name,'posterior') if strcmp(field_name,'posterior')
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ... fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
header_width,name,bayestopt_.p1(ip),xparam1(ip),stdh(ip), ... header_width, name, bayestopt_.p1(ip), xparam1(ip), stdh(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.p2(ip)); pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip));
else else
fprintf('%-*s %8.4f %7.4f %7.4f \n',header_width,name,xparam1(ip),stdh(ip),tstath(ip)); fprintf('%-*s %8.4f %7.4f %7.4f \n',header_width, name, xparam1(ip), ...
stdh(ip), tstath(ip));
end end
eval(['oo_.' field_name '_mode.measurement_errors_corr.' NAME ' = xparam1(ip);']); eval(['oo_.' field_name '_mode.measurement_errors_corr.' NAME ' = xparam1(ip);']);
eval(['oo_.' field_name '_std_at_mode.measurement_errors_corr.' NAME ' = stdh(ip);']); eval(['oo_.' field_name '_std_at_mode.measurement_errors_corr.' NAME ' = stdh(ip);']);
@ -169,6 +172,7 @@ if ncn
end end
skipline() skipline()
end end
if any(xparam1(1:nvx+nvn)<0) if any(xparam1(1:nvx+nvn)<0)
warning('Some estimated standard deviations are negative. Dynare internally works with variances so that the sign does not matter. Nevertheless, it is recommended to impose either prior restrictions (Bayesian Estimation) or a lower bound (ML) to assure positive values.') warning('Some estimated standard deviations are negative. Dynare internally works with variances so that the sign does not matter. Nevertheless, it is recommended to impose either prior restrictions (Bayesian Estimation) or a lower bound (ML) to assure positive values.')
end end
@ -183,11 +187,11 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
ip = nvx+nvn+ncx+ncn+1; ip = nvx+nvn+ncx+ncn+1;
for i=1:np for i=1:np
fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',... fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
M_.param_names_tex(estim_params_.param_vals(i,1),:),... M_.param_names_tex{estim_params_.param_vals(i,1)}, ...
deblank(pnames(bayestopt_.pshape(ip)+1,:)),... pnames{bayestopt_.pshape(ip)+1}, ...
bayestopt_.p1(ip),... bayestopt_.p1(ip), ...
bayestopt_.p2(ip),... bayestopt_.p2(ip), ...
xparam1(ip),... xparam1(ip), ...
stdh(ip)); stdh(ip));
ip = ip + 1; ip = ip + 1;
end end
@ -201,8 +205,8 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
for i=1:nvx for i=1:nvx
k = estim_params_.var_exo(i,1); k = estim_params_.var_exo(i,1);
fprintf(fidTeX,[ '$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],... fprintf(fidTeX,[ '$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],...
deblank(M_.exo_names_tex(k,:)),... M_.exo_names_tex{k},...
deblank(pnames(bayestopt_.pshape(ip)+1,:)),... pnames{bayestopt_.pshape(ip)+1},...
bayestopt_.p1(ip),... bayestopt_.p1(ip),...
bayestopt_.p2(ip),... bayestopt_.p2(ip),...
xparam1(ip), ... xparam1(ip), ...
@ -217,10 +221,10 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
TeXBegin_Bayesian(fidTeX,3,'standard deviation of measurement errors') TeXBegin_Bayesian(fidTeX,3,'standard deviation of measurement errors')
ip = nvx+1; ip = nvx+1;
for i=1:nvn for i=1:nvn
idx = strmatch(options_.varobs{estim_params_.nvn_observable_correspondence(i,1)},M_.endo_names); idx = strmatch(options_.varobs{estim_params_.nvn_observable_correspondence(i,1)}, M_.endo_names);
fprintf(fidTeX,'$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',... fprintf(fidTeX,'$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
deblank(M_.endo_names_tex(idx,:)), ... M_.endo_names_tex{idx}, ...
deblank(pnames(bayestopt_.pshape(ip)+1,:)), ... pnames{bayestopt_.pshape(ip)+1}, ...
bayestopt_.p1(ip), ... bayestopt_.p1(ip), ...
bayestopt_.p2(ip),... bayestopt_.p2(ip),...
xparam1(ip),... xparam1(ip),...
@ -238,8 +242,8 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
k1 = estim_params_.corrx(i,1); k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2); k2 = estim_params_.corrx(i,2);
fprintf(fidTeX,[ '$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],... fprintf(fidTeX,[ '$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],...
[deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:))], ... [M_.exo_names_tex{k1} ',' M_.exo_names_tex{k2}], ...
deblank(pnames(bayestopt_.pshape(ip)+1,:)), ... pnames{bayestopt_.pshape(ip)+1}, ...
bayestopt_.p1(ip), ... bayestopt_.p1(ip), ...
bayestopt_.p2(ip), ... bayestopt_.p2(ip), ...
xparam1(ip), ... xparam1(ip), ...
@ -257,8 +261,8 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
k1 = estim_params_.corrn(i,1); k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2); k2 = estim_params_.corrn(i,2);
fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',... fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
[deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:))], ... [ M_.endo_names_tex{k1} ',' M_.endo_names_tex{k2}], ...
pnames(bayestopt_.pshape(ip)+1,:), ... pnames{bayestopt_.pshape(ip)+1}, ...
bayestopt_.p1(ip), ... bayestopt_.p1(ip), ...
bayestopt_.p2(ip), ... bayestopt_.p2(ip), ...
xparam1(ip), ... xparam1(ip), ...
@ -270,14 +274,14 @@ if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior
elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
if np if np
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_1.tex']; filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_1.tex'];
fidTeX = fopen(filename,'w'); fidTeX = fopen(filename, 'w');
TeXBegin_ML(fidTeX,1,'parameters',table_title,LaTeXtitle) TeXBegin_ML(fidTeX, 1, 'parameters', table_title, LaTeXtitle)
ip = nvx+nvn+ncx+ncn+1; ip = nvx+nvn+ncx+ncn+1;
for i=1:np for i=1:np
fprintf(fidTeX,'$%s$ & %8.4f & %7.4f & %7.4f\\\\ \n',... fprintf(fidTeX,'$%s$ & %8.4f & %7.4f & %7.4f\\\\ \n',...
M_.param_names_tex(estim_params_.param_vals(i,1),:),... M_.param_names_tex{estim_params_.param_vals(i,1)}, ...
xparam1(ip),... xparam1(ip), ...
stdh(ip),... stdh(ip), ...
tstath(ip)); tstath(ip));
ip = ip + 1; ip = ip + 1;
end end
@ -285,15 +289,15 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
end end
if nvx if nvx
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_2.tex']; filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_2.tex'];
fidTeX = fopen(filename,'w'); fidTeX = fopen(filename, 'w');
TeXBegin_ML(fidTeX,2,'standard deviation of structural shocks',table_title,LaTeXtitle) TeXBegin_ML(fidTeX, 2, 'standard deviation of structural shocks', table_title, LaTeXtitle)
ip = 1; ip = 1;
for i=1:nvx for i=1:nvx
k = estim_params_.var_exo(i,1); k = estim_params_.var_exo(i,1);
fprintf(fidTeX,[ '$%s$ & %8.4f & %7.4f & %7.4f\\\\ \n'],... fprintf(fidTeX,[ '$%s$ & %8.4f & %7.4f & %7.4f\\\\ \n'], ...
deblank(M_.exo_names_tex(k,:)),... M_.exo_names_tex{k}, ...
xparam1(ip), ... xparam1(ip), ...
stdh(ip),... stdh(ip), ...
tstath(ip)); tstath(ip));
ip = ip+1; ip = ip+1;
end end
@ -301,15 +305,15 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
end end
if nvn if nvn
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_3.tex']; filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_3.tex'];
fidTeX = fopen(filename,'w'); fidTeX = fopen(filename, 'w');
TeXBegin_ML(fidTeX,3,'standard deviation of measurement errors',table_title,LaTeXtitle) TeXBegin_ML(fidTeX, 3, 'standard deviation of measurement errors', table_title, LaTeXtitle)
ip = nvx+1; ip = nvx+1;
for i=1:nvn for i=1:nvn
idx = strmatch(options_.varobs{estim_params_.nvn_observable_correspondence(i,1)},M_.endo_names); idx = strmatch(options_.varobs{estim_params_.nvn_observable_correspondence(i,1)}, M_.endo_names);
fprintf(fidTeX,'$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n',... fprintf(fidTeX, '$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n', ...
deblank(M_.endo_names_tex(idx,:)), ... M_.endo_names_tex{idx}, ...
xparam1(ip),... xparam1(ip), ...
stdh(ip),... stdh(ip), ...
tstath(ip)); tstath(ip));
ip = ip+1; ip = ip+1;
end end
@ -317,16 +321,16 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
end end
if ncx if ncx
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_4.tex']; filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_4.tex'];
fidTeX = fopen(filename,'w'); fidTeX = fopen(filename, 'w');
TeXBegin_ML(fidTeX,4,'correlation of structural shocks',table_title,LaTeXtitle) TeXBegin_ML(fidTeX, 4, 'correlation of structural shocks', table_title,LaTeXtitle)
ip = nvx+nvn+1; ip = nvx+nvn+1;
for i=1:ncx for i=1:ncx
k1 = estim_params_.corrx(i,1); k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2); k2 = estim_params_.corrx(i,2);
fprintf(fidTeX,[ '$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n'],... fprintf(fidTeX,[ '$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n'], ...
[deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:))], ... [M_.exo_names_tex{k1} ',' M_.exo_names_tex{k2}], ...
xparam1(ip), ... xparam1(ip), ...
stdh(ip),... stdh(ip), ...
tstath(ip)); tstath(ip));
ip = ip+1; ip = ip+1;
end end
@ -334,16 +338,16 @@ elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
end end
if ncn if ncn
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_5.tex']; filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_5.tex'];
fidTeX = fopen(filename,'w'); fidTeX = fopen(filename, 'w');
TeXBegin_ML(fidTeX,5,'correlation of measurement errors',table_title,LaTeXtitle) TeXBegin_ML(fidTeX, 5, 'correlation of measurement errors', table_title, LaTeXtitle)
ip = nvx+nvn+ncx+1; ip = nvx+nvn+ncx+1;
for i=1:ncn for i=1:ncn
k1 = estim_params_.corrn(i,1); k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2); k2 = estim_params_.corrn(i,2);
fprintf(fidTeX,'$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n',... fprintf(fidTeX, '$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n', ...
[deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:))], ... [ M_.endo_names_tex{k1} ',' M_.endo_names_tex{k2}], ...
xparam1(ip), ... xparam1(ip), ...
stdh(ip),... stdh(ip), ...
tstath(ip)); tstath(ip));
ip = ip+1; ip = ip+1;
end end
@ -355,7 +359,7 @@ end
%% subfunctions: %% subfunctions:
% %
function TeXBegin_Bayesian(fid,fnum,title) function TeXBegin_Bayesian(fid, fnum, title)
fprintf(fid,'%% TeX-table generated by dynare_estimation (Dynare).\n'); fprintf(fid,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fid,['%% RESULTS FROM POSTERIOR MAXIMIZATION (' title ')\n']); fprintf(fid,['%% RESULTS FROM POSTERIOR MAXIMIZATION (' title ')\n']);
fprintf(fid,['%% ' datestr(now,0)]); fprintf(fid,['%% ' datestr(now,0)]);
@ -379,7 +383,7 @@ fprintf(fid,'\\midrule \\endhead \n');
fprintf(fid,'\\bottomrule \\multicolumn{6}{r}{(Continued on next page)}\\endfoot \n'); fprintf(fid,'\\bottomrule \\multicolumn{6}{r}{(Continued on next page)}\\endfoot \n');
fprintf(fid,'\\bottomrule\\endlastfoot \n'); fprintf(fid,'\\bottomrule\\endlastfoot \n');
function TeXBegin_ML(fid,fnum,title,table_title,LaTeXtitle) function TeXBegin_ML(fid, fnum, title, table_title, LaTeXtitle)
fprintf(fid,'%% TeX-table generated by dynare_estimation (Dynare).\n'); fprintf(fid,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fid,['%% RESULTS FROM ' table_title ' MAXIMIZATION (' title ')\n']); fprintf(fid,['%% RESULTS FROM ' table_title ' MAXIMIZATION (' title ')\n']);
fprintf(fid,['%% ' datestr(now,0)]); fprintf(fid,['%% ' datestr(now,0)]);

View File

@ -16,7 +16,7 @@ function []=display_problematic_vars_Jacobian(problemrow,problemcol,M_,x,type,ca
% none. % none.
% %
% Copyright (C) 2014-2017 Dynare Team % Copyright (C) 2014-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -55,84 +55,98 @@ if strcmp(type,'dynamic')
end end
if problemcol(ii)<=max(max(M_.lead_lag_incidence)) && var_index<=M_.orig_endo_nbr if problemcol(ii)<=max(max(M_.lead_lag_incidence)) && var_index<=M_.orig_endo_nbr
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=aux_eq_nbr
eq_nbr=problemrow(ii); eq_nbr = problemrow(ii);
fprintf('Derivative of Auxiliary Equation %d with respect to %s Variable %s (initial value of %s: %g) \n',eq_nbr,type_string,deblank(M_.endo_names(var_index,:)),deblank(M_.endo_names(var_index,:)),x(var_index)) fprintf('Derivative of Auxiliary Equation %d with respect to %s Variable %s (initial value of %s: %g) \n', ...
eq_nbr, type_string, M_.endo_names{var_index}, M_.endo_names{var_index}, x(var_index));
else else
eq_nbr=problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-aux_eq_nbr;
fprintf('Derivative of Equation %d with respect to %s Variable %s (initial value of %s: %g) \n',eq_nbr,type_string,deblank(M_.endo_names(var_index,:)),deblank(M_.endo_names(var_index,:)),x(var_index)) fprintf('Derivative of Equation %d with respect to %s Variable %s (initial value of %s: %g) \n', ...
eq_nbr, type_string, M_.endo_names{var_index}, M_.endo_names{var_index}, x(var_index));
end end
elseif problemcol(ii)<=max(max(M_.lead_lag_incidence)) && var_index>M_.orig_endo_nbr %auxiliary vars elseif problemcol(ii)<=max(max(M_.lead_lag_incidence)) && var_index>M_.orig_endo_nbr % auxiliary vars
if M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).type ==6 %Ramsey Lagrange Multiplier if M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).type==6 %Ramsey Lagrange Multiplier
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=aux_eq_nbr
eq_nbr=problemrow(ii); eq_nbr = problemrow(ii);
fprintf('Derivative of Auxiliary Equation %d with respect to %s of Langrange multiplier of equation %s (initial value: %g) \n',eq_nbr,type_string,M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr,x(problemcol(ii))) fprintf('Derivative of Auxiliary Equation %d with respect to %s of Langrange multiplier of equation %s (initial value: %g) \n', ...
eq_nbr, type_string, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
else
eq_nbr = problemrow(ii)-aux_eq_nbr;
fprintf('Derivative of Equation %d with respect to %s of Langrange multiplier of equation %s (initial value: %g) \n', ...
eq_nbr, type_string, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
end
else else
eq_nbr=problemrow(ii)-aux_eq_nbr; if problemrow(ii)<=aux_eq_nbr
fprintf('Derivative of Equation %d with respect to %s of Langrange multiplier of equation %s (initial value: %g) \n',eq_nbr,type_string,M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr,x(problemcol(ii))) eq_nbr = problemrow(ii);
orig_var_index = M_.aux_vars(1,var_index-M_.orig_endo_nbr).orig_index;
fprintf('Derivative of Auxiliary Equation %d with respect to %s Variable %s (initial value of %s: %g) \n', ...
eq_nbr, type_string, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(orig_var_index));
else
eq_nbr = problemrow(ii)-aux_eq_nbr;
orig_var_index = M_.aux_vars(1,var_index-M_.orig_endo_nbr).orig_index;
fprintf('Derivative of Equation %d with respect to %s Variable %s (initial value of %s: %g) \n', ...
eq_nbr, type_string, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(orig_var_index));
end
end end
else
if problemrow(ii)<=aux_eq_nbr
eq_nbr=problemrow(ii);
orig_var_index=M_.aux_vars(1,var_index-M_.orig_endo_nbr).orig_index;
fprintf('Derivative of Auxiliary Equation %d with respect to %s Variable %s (initial value of %s: %g) \n',eq_nbr,type_string,deblank(M_.endo_names(orig_var_index,:)),deblank(M_.endo_names(orig_var_index,:)),x(orig_var_index))
else
eq_nbr=problemrow(ii)-aux_eq_nbr;
orig_var_index=M_.aux_vars(1,var_index-M_.orig_endo_nbr).orig_index;
fprintf('Derivative of Equation %d with respect to %s Variable %s (initial value of %s: %g) \n',eq_nbr,type_string,deblank(M_.endo_names(orig_var_index,:)),deblank(M_.endo_names(orig_var_index,:)),x(orig_var_index))
end
end
elseif problemcol(ii)>max(max(M_.lead_lag_incidence)) && var_index<=M_.exo_nbr elseif problemcol(ii)>max(max(M_.lead_lag_incidence)) && var_index<=M_.exo_nbr
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=aux_eq_nbr
eq_nbr=problemrow(ii); eq_nbr = problemrow(ii);
fprintf('Derivative of Auxiliary Equation %d with respect to %s shock %s \n',eq_nbr,type_string,deblank(M_.exo_names(var_index,:))); fprintf('Derivative of Auxiliary Equation %d with respect to %s shock %s \n', ...
eq_nbr, type_string, M_.exo_names{var_index});
else else
eq_nbr=problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-aux_eq_nbr;
fprintf('Derivative of Equation %d with respect to %s shock %s \n',eq_nbr,type_string,deblank(M_.exo_names(var_index,:))); fprintf('Derivative of Equation %d with respect to %s shock %s \n', ...
eq_nbr, type_string, M_.exo_names{var_index});
end end
else else
error('display_problematic_vars_Jacobian:: The error should not happen. Please contact the developers') error('display_problematic_vars_Jacobian:: The error should not happen. Please contact the developers')
end end
end end
fprintf('\n%s The problem most often occurs, because a variable with\n',caller_string) fprintf('\n%s The problem most often occurs, because a variable with\n', caller_string)
fprintf('%s exponent smaller than 1 has been initialized to 0. Taking the derivative\n',caller_string) fprintf('%s exponent smaller than 1 has been initialized to 0. Taking the derivative\n', caller_string)
fprintf('%s and evaluating it at the steady state then results in a division by 0.\n',caller_string) fprintf('%s and evaluating it at the steady state then results in a division by 0.\n', caller_string)
fprintf('%s If you are using model-local variables (# operator), check their values as well.\n',caller_string) fprintf('%s If you are using model-local variables (# operator), check their values as well.\n', caller_string)
elseif strcmp(type,'static') elseif strcmp(type, 'static')
for ii=1:length(problemrow) for ii=1:length(problemrow)
if problemcol(ii)<=M_.orig_endo_nbr if problemcol(ii)<=M_.orig_endo_nbr
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=aux_eq_nbr
eq_nbr=problemrow(ii); eq_nbr = problemrow(ii);
fprintf('Derivative of Auxiliary Equation %d with respect to Variable %s (initial value of %s: %g) \n',eq_nbr,deblank(M_.endo_names(problemcol(ii),:)),deblank(M_.endo_names(problemcol(ii),:)),x(problemcol(ii))) fprintf('Derivative of Auxiliary Equation %d with respect to Variable %s (initial value of %s: %g) \n', ...
eq_nbr, M_.endo_names{problemcol(ii)}, M_.endo_names{problemcol(ii)}, x(problemcol(ii)));
else else
eq_nbr=problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-aux_eq_nbr;
fprintf('Derivative of Equation %d with respect to Variable %s (initial value of %s: %g) \n',eq_nbr,deblank(M_.endo_names(problemcol(ii),:)),deblank(M_.endo_names(problemcol(ii),:)),x(problemcol(ii))) fprintf('Derivative of Equation %d with respect to Variable %s (initial value of %s: %g) \n', ...
eq_nbr, M_.endo_names{problemcol(ii)}, M_.endo_names{problemcol(ii)}, x(problemcol(ii)));
end end
else %auxiliary vars else %auxiliary vars
if M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).type ==6 %Ramsey Lagrange Multiplier if M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).type ==6 %Ramsey Lagrange Multiplier
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=aux_eq_nbr
eq_nbr=problemrow(ii); eq_nbr = problemrow(ii);
fprintf('Derivative of Auxiliary Equation %d with respect to Lagrange multiplier of equation %d (initial value: %g) \n',eq_nbr,M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr,x(problemcol(ii))) fprintf('Derivative of Auxiliary Equation %d with respect to Lagrange multiplier of equation %d (initial value: %g) \n', ...
eq_nbr, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
else else
eq_nbr=problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-aux_eq_nbr;
fprintf('Derivative of Equation %d with respect to Lagrange multiplier of equation %d (initial value: %g) \n',eq_nbr,M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr,x(problemcol(ii))) fprintf('Derivative of Equation %d with respect to Lagrange multiplier of equation %d (initial value: %g) \n', ...
eq_nbr, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
end end
else else
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=aux_eq_nbr
eq_nbr=problemrow(ii); eq_nbr = problemrow(ii);
orig_var_index=M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).orig_index; orig_var_index = M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).orig_index;
fprintf('Derivative of Auxiliary Equation %d with respect to Variable %s (initial value of %s: %g) \n',eq_nbr,deblank(M_.endo_names(orig_var_index,:)),deblank(M_.endo_names(orig_var_index,:)),x(problemcol(ii))) fprintf('Derivative of Auxiliary Equation %d with respect to Variable %s (initial value of %s: %g) \n', ...
eq_nbr, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(problemcol(ii)));
else else
eq_nbr=problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-aux_eq_nbr;
orig_var_index=M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).orig_index; orig_var_index = M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).orig_index;
fprintf('Derivative of Equation %d with respect to Variable %s (initial value of %s: %g) \n',eq_nbr,deblank(M_.endo_names(orig_var_index,:)),deblank(M_.endo_names(orig_var_index,:)),x(problemcol(ii))) fprintf('Derivative of Equation %d with respect to Variable %s (initial value of %s: %g) \n', ...
eq_nbr, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(problemcol(ii)));
end end
end end
end end
end end
fprintf('\n%s The problem most often occurs, because a variable with\n',caller_string) fprintf('\n%s The problem most often occurs, because a variable with\n', caller_string)
fprintf('%s exponent smaller than 1 has been initialized to 0. Taking the derivative\n',caller_string) fprintf('%s exponent smaller than 1 has been initialized to 0. Taking the derivative\n', caller_string)
fprintf('%s and evaluating it at the steady state then results in a division by 0.\n',caller_string) fprintf('%s and evaluating it at the steady state then results in a division by 0.\n', caller_string)
fprintf('%s If you are using model-local variables (# operator), check their values as well.\n',caller_string) fprintf('%s If you are using model-local variables (# operator), check their values as well.\n', caller_string)
else else
error('Unknown Type') error('Unknown Type')
end end

View File

@ -37,7 +37,7 @@ function [fval,info,exit_flag,grad,hess,SteadyState,trend_coeff,PHI_tilde,SIGMA_
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% None. % None.
% Copyright (C) 2006-2017 Dynare Team % Copyright (C) 2006-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -73,7 +73,7 @@ xparam1 = xparam1(:);
% Initialization of of the index for parameter dsge_prior_weight in Model.params. % Initialization of of the index for parameter dsge_prior_weight in Model.params.
if isempty(dsge_prior_weight_idx) if isempty(dsge_prior_weight_idx)
dsge_prior_weight_idx = strmatch('dsge_prior_weight',Model.param_names); dsge_prior_weight_idx = strmatch('dsge_prior_weight', Model.param_names);
end end
% Get the number of estimated (dsge) parameters. % Get the number of estimated (dsge) parameters.

View File

@ -14,7 +14,7 @@ function [z,zss]=dyn2vec(s1,s2)
% none % none
% %
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -46,15 +46,15 @@ if nargin == 0
error(t); error(t);
end end
for i=1:size(oo_.endo_simul,1) for i=1:size(oo_.endo_simul,1)
assignin('base',deblank(M_.endo_names(i,:)),oo_.endo_simul(i,k)'); assignin('base', M_.endo_names{i}, oo_.endo_simul(i,k)');
end end
return return
else else
j = strmatch(s1,M_.endo_names,'exact'); j = strmatch(s1, M_.endo_names, 'exact');
if ~ isempty(j) if ~ isempty(j)
z = oo_.endo_simul(j,k)'; z = oo_.endo_simul(j,k)';
else else
j = strmatch(s1,M_.exo_names,'exact'); j = strmatch(s1, M_.exo_names, 'exact');
if ~ isempty(j) if ~ isempty(j)
if options_.smpl == 0 if options_.smpl == 0
z = oo_.exo_simul(:,j); z = oo_.exo_simul(:,j);

View File

@ -21,7 +21,7 @@ function [forecast,info] = dyn_forecast(var_list,M,options,oo,task,dataset_info)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -52,13 +52,13 @@ maximum_lag = M.maximum_lag;
endo_names = M.endo_names; endo_names = M.endo_names;
if isempty(var_list) if isempty(var_list)
var_list = endo_names(1:M.orig_endo_nbr, :); var_list = endo_names(1:M.orig_endo_nbr);
end end
i_var = []; i_var = [];
for i = 1:size(var_list) for i = 1:length(var_list)
tmp = strmatch(var_list(i,:),endo_names,'exact'); tmp = strmatch(var_list{i}, endo_names, 'exact');
if isempty(tmp) if isempty(tmp)
error([var_list(i,:) ' isn''t an endogenous variable']) error([var_list{i} ' isn''t an endogenous variable'])
end end
i_var = [i_var; tmp]; i_var = [i_var; tmp];
end end
@ -90,7 +90,7 @@ switch task
y_smoothed = oo.SmoothedVariables; y_smoothed = oo.SmoothedVariables;
y0 = zeros(M.endo_nbr,maximum_lag); y0 = zeros(M.endo_nbr,maximum_lag);
for i = 1:M.endo_nbr for i = 1:M.endo_nbr
v_name = deblank(M.endo_names(i,:)); v_name = M.endo_names{i};
y0(i,:) = y_smoothed.(v_name)(end-maximum_lag+1:end); %includes steady state or mean, but simult_ will subtract only steady state y0(i,:) = y_smoothed.(v_name)(end-maximum_lag+1:end); %includes steady state or mean, but simult_ will subtract only steady state
% 2. Subtract mean/steady state and add steady state; takes care of prefiltering % 2. Subtract mean/steady state and add steady state; takes care of prefiltering
if isfield(oo.Smoother,'Constant') && isfield(oo.Smoother.Constant,v_name) if isfield(oo.Smoother,'Constant') && isfield(oo.Smoother.Constant,v_name)
@ -98,7 +98,7 @@ switch task
if options.loglinear if options.loglinear
y0(i,:)=y0(i,:)+log_variable(i,oo.dr.ys,M); y0(i,:)=y0(i,:)+log_variable(i,oo.dr.ys,M);
else else
y0(i,:)=y0(i,:)+oo.dr.ys(strmatch(v_name,deblank(M.endo_names),'exact')); y0(i,:)=y0(i,:)+oo.dr.ys(strmatch(v_name, M.endo_names, 'exact'));
end end
end end
% 2. Subtract trend % 2. Subtract trend
@ -114,8 +114,8 @@ switch task
i_var_obs = []; i_var_obs = [];
trend_coeffs = []; trend_coeffs = [];
for i=1:length(var_obs) for i=1:length(var_obs)
tmp = strmatch(var_obs{i},endo_names(i_var,:),'exact'); tmp = strmatch(var_obs{i}, endo_names(i_var), 'exact');
trend_var_index=strmatch(var_obs{i},M.endo_names,'exact'); trend_var_index = strmatch(var_obs{i}, M.endo_names, 'exact');
if ~isempty(tmp) if ~isempty(tmp)
i_var_obs = [ i_var_obs; tmp]; i_var_obs = [ i_var_obs; tmp];
trend_coeffs = [trend_coeffs; oo.Smoother.TrendCoeffs(trend_var_index)]; trend_coeffs = [trend_coeffs; oo.Smoother.TrendCoeffs(trend_var_index)];
@ -175,21 +175,21 @@ else
end end
for i=1:n_var for i=1:n_var
vname = deblank(var_list(i,:)); vname = var_list{i};
forecast.Mean.(vname) = yf(i,maximum_lag+(1:horizon))'; forecast.Mean.(vname) = yf(i,maximum_lag+(1:horizon))';
forecast.HPDinf.(vname)= yf(i,maximum_lag+(1:horizon))' - int_width(1:horizon,i); forecast.HPDinf.(vname)= yf(i,maximum_lag+(1:horizon))' - int_width(1:horizon,i);
forecast.HPDsup.(vname) = yf(i,maximum_lag+(1:horizon))' + int_width(1:horizon,i); forecast.HPDsup.(vname) = yf(i,maximum_lag+(1:horizon))' + int_width(1:horizon,i);
if ~isequal(M.H,0) && ismember(var_list(i,:),options.varobs) if ~isequal(M.H,0) && ismember(var_list{i},options.varobs)
forecast.HPDinf_ME.(vname)= yf(i,maximum_lag+(1:horizon))' - int_width_ME(1:horizon,i); forecast.HPDinf_ME.(vname)= yf(i,maximum_lag+(1:horizon))' - int_width_ME(1:horizon,i);
forecast.HPDsup_ME.(vname) = yf(i,maximum_lag+(1:horizon))' + int_width_ME(1:horizon,i); forecast.HPDsup_ME.(vname) = yf(i,maximum_lag+(1:horizon))' + int_width_ME(1:horizon,i);
end end
end end
for i=1:M.exo_det_nbr for i=1:M.exo_det_nbr
forecast.Exogenous.(deblank(M.exo_det_names(i,:))) = oo.exo_det_simul(maximum_lag+(1:horizon),i); forecast.Exogenous.(M.exo_det_names{i}) = oo.exo_det_simul(maximum_lag+(1:horizon),i);
end end
if options.nograph == 0 if options.nograph == 0
oo.forecast = forecast; oo.forecast = forecast;
forecast_graphs(var_list,M, oo,options) forecast_graphs(var_list, M, oo, options)
end end

View File

@ -1,7 +1,8 @@
function dyn_latex_table(M_,options_,title,LaTeXtitle,headers,labels,values,label_width,val_width,val_precis,optional_header) function dyn_latex_table(M_, options_, title, LaTeXtitle, headers, labels, values, label_width, val_width, val_precis, optional_header)
%function dyn_latex_table(M_,options_,title,LaTeXtitle,headers,labels,values,label_width,val_width,val_precis,optional_header) %function dyn_latex_table(M_,options_,title,LaTeXtitle,headers,labels,values,label_width,val_width,val_precis,optional_header)
% Copyright (C) 2015-2017 Dynare Team % Copyright (C) 2015-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -24,16 +25,15 @@ end
OutputDirectoryName = CheckPath('Output',M_.dname); OutputDirectoryName = CheckPath('Output',M_.dname);
%% get width of label column % Set width of label column
if ~isempty(label_width) if isempty(label_width)
label_width = max(size(deblank(char(headers(1,:),labels)),2)+2, ... label_width = cellofchararraymaxlength(vertcat(headers{1}, labels))+2;
label_width); else
else %use default length label_width = max(cellofchararraymaxlength(vertcat(headers{1}, labels))+2, label_width);
label_width = max(size(deblank(char(headers(1,:),labels)),2))+2;
end end
label_format_leftbound = sprintf('$%%-%ds$',label_width); label_format_leftbound = sprintf('$%%-%ds$', label_width);
%% get width of label column % Set width of other columns
if all(~isfinite(values)) if all(~isfinite(values))
values_length = 4; values_length = 4;
else else
@ -42,66 +42,64 @@ end
if any(values) < 0 %add one character for minus sign if any(values) < 0 %add one character for minus sign
values_length = values_length+1; values_length = values_length+1;
end end
headers_length = cellofchararraymaxlength(headers(2:end));
%% get width of header strings if isempty(val_width)
headers_length = max(size(deblank(headers(2:end,:)),2)); val_width = max(headers_length, values_length)+4;
if ~isempty(val_width)
val_width = max(max(headers_length,values_length)+4,val_width);
else else
val_width = max(headers_length,values_length)+4; val_width = max(max(headers_length, values_length)+4, val_width);
end end
value_format = sprintf('%%%d.%df',val_width,val_precis); value_format = sprintf('%%%d.%df', val_width, val_precis);
header_string_format = sprintf('$%%%ds$',val_width); header_string_format = sprintf('$%%%ds$', val_width);
%Create and print header string % Create and print header string
if length(headers) > 0 if length(headers)>0
header_string = sprintf(label_format_leftbound ,strrep(deblank(headers(1,:)),'\','\\')); header_string = sprintf(label_format_leftbound, strrep(headers{1}, '\', '\\'));
header_code_string='l'; header_code_string = 'l';
for i=2:size(headers,1) for i=2:length(headers)
header_string = [header_string '\t & \t ' sprintf(header_string_format,strrep(deblank(headers(i,:)),'\','\\'))]; header_string = [header_string '\t & \t ' sprintf(header_string_format, strrep(headers{i},'\','\\'))];
header_code_string= [header_code_string 'c']; header_code_string = [header_code_string 'c'];
end end
end end
header_string=[header_string '\\\\\n']; header_string = [header_string '\\\\\n'];
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '.tex']; filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '.tex'];
fidTeX = fopen(filename,'w'); fidTeX = fopen(filename,'w');
stack = dbstack; stack = dbstack;
fprintf(fidTeX,['%% ' datestr(now,0) ', created by ' stack(2).file]); fprintf(fidTeX, ['%% ' datestr(now,0) ', created by ' stack(2).file]);
fprintf(fidTeX,' \n'); fprintf(fidTeX, ' \n');
fprintf(fidTeX,' \n'); fprintf(fidTeX, ' \n');
fprintf(fidTeX,'\\begin{center}\n'); fprintf(fidTeX, '\\begin{center}\n');
fprintf(fidTeX,['\\begin{longtable}{%s} \n'],header_code_string); fprintf(fidTeX, ['\\begin{longtable}{%s} \n'], header_code_string);
fprintf(fidTeX,['\\caption{',title,'}\\\\\n ']); fprintf(fidTeX, ['\\caption{',title,'}\\\\\n ']);
fprintf(fidTeX,['\\label{Table:',LaTeXtitle,'}\\\\\n']); fprintf(fidTeX, ['\\label{Table:',LaTeXtitle,'}\\\\\n']);
fprintf(fidTeX,'\\toprule \n'); fprintf(fidTeX, '\\toprule \n');
if nargin==11 if nargin==11
for ii=1:size(optional_header,1) for ii = 1:length(optional_header)
fprintf(fidTeX,'%s\n',optional_header{ii}); fprintf(fidTeX,'%s\n',optional_header{ii});
end end
end end
fprintf(fidTeX,header_string); fprintf(fidTeX, header_string);
fprintf(fidTeX,'\\midrule \\endfirsthead \n'); fprintf(fidTeX, '\\midrule \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\\\\\n '); fprintf(fidTeX, '\\caption{(continued)}\\\\\n ');
fprintf(fidTeX,'\\toprule \\\\ \n'); fprintf(fidTeX, '\\toprule \\\\ \n');
if nargin==11 if nargin==11
for ii=1:size(optional_header,1) for ii = 1:length(optional_header)
fprintf(fidTeX,'%s\n',optional_header{ii}); fprintf(fidTeX, '%s\n', optional_header{ii});
end end
end end
fprintf(fidTeX,header_string); fprintf(fidTeX, header_string);
fprintf(fidTeX,'\\midrule \\endhead \n'); fprintf(fidTeX, '\\midrule \\endhead \n');
fprintf(fidTeX,['\\midrule \\multicolumn{',num2str(size(headers,1)),'}{r}{(Continued on next page)} \\\\ \\bottomrule \\endfoot \n']); fprintf(fidTeX, ['\\midrule \\multicolumn{',num2str(size(headers,1)),'}{r}{(Continued on next page)} \\\\ \\bottomrule \\endfoot \n']);
fprintf(fidTeX,'\\bottomrule \\endlastfoot \n'); fprintf(fidTeX, '\\bottomrule \\endlastfoot \n');
for i=1:size(values,1) for i = 1:size(values,1)
fprintf(fidTeX,label_format_leftbound,deblank(labels(i,:))); fprintf(fidTeX, label_format_leftbound, labels{i});
fprintf(fidTeX,['\t & \t' value_format],values(i,:)); fprintf(fidTeX, ['\t & \t' value_format], values(i,:));
fprintf(fidTeX,' \\\\ \n'); fprintf(fidTeX, ' \\\\ \n');
end end
fprintf(fidTeX,'\\end{longtable}\n '); fprintf(fidTeX, '\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n'); fprintf(fidTeX, '\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n'); fprintf(fidTeX, '%% End of TeX file.\n');
fclose(fidTeX); fclose(fidTeX);

View File

@ -18,7 +18,7 @@ function [steady_state,params,check] = dyn_ramsey_static(ys_init,M,options_,oo)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -50,8 +50,7 @@ elseif options_.steadystate_flag
k_inst = []; k_inst = [];
inst_nbr = size(options_.instruments,1); inst_nbr = size(options_.instruments,1);
for i = 1:inst_nbr for i = 1:inst_nbr
k_inst = [k_inst; strmatch(options_.instruments(i,:), ... k_inst = [k_inst; strmatch(options_.instruments(i,:), M.endo_names, 'exact')];
M.endo_names,'exact')];
end end
if inst_nbr == 1 if inst_nbr == 1
%solve for instrument, using univariate solver, starting at initial value for instrument %solve for instrument, using univariate solver, starting at initial value for instrument
@ -113,8 +112,7 @@ if options_.steadystate_flag
k_inst = []; k_inst = [];
instruments = options_.instruments; instruments = options_.instruments;
for i = 1:size(instruments,1) for i = 1:size(instruments,1)
k_inst = [k_inst; strmatch(instruments(i,:), ... k_inst = [k_inst; strmatch(instruments(i,:), endo_names, 'exact')];
endo_names,'exact')];
end end
ys_init=zeros(size(oo.steady_state)); %create starting vector for steady state computation as only instrument value is handed over ys_init=zeros(size(oo.steady_state)); %create starting vector for steady state computation as only instrument value is handed over
ys_init(k_inst) = x; %set instrument, the only value required for steady state computation, to current value ys_init(k_inst) = x; %set instrument, the only value required for steady state computation, to current value

View File

@ -62,7 +62,7 @@ function [dr,info] = dyn_risky_steadystate_solver(ys0,M, ...
%! @end deftypefn %! @end deftypefn
%@eod: %@eod:
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -86,7 +86,7 @@ order_var = dr.order_var;
endo_nbr = M.endo_nbr; endo_nbr = M.endo_nbr;
exo_nbr = M.exo_nbr; exo_nbr = M.exo_nbr;
M.var_order_endo_names = M.endo_names(dr.order_var,:); M.var_order_endo_names = M.endo_names(dr.order_var);
[junk,dr.i_fwrd_g,i_fwrd_f] = find(lead_lag_incidence(3,order_var)); [junk,dr.i_fwrd_g,i_fwrd_f] = find(lead_lag_incidence(3,order_var));
dr.i_fwrd_f = i_fwrd_f; dr.i_fwrd_f = i_fwrd_f;
@ -138,10 +138,10 @@ dr.ghs2 = zeros(M.endo_nbr,1);
for i=1:M.endo_nbr for i=1:M.endo_nbr
if isfield(options,'portfolio') && options.portfolio == 1 if isfield(options,'portfolio') && options.portfolio == 1
disp(sprintf('%16s %12.6f %12.6f',M.endo_names(i,:),ys1(i), ... disp(sprintf('%16s %12.6f %12.6f', M.endo_names{i}, ys1(i), ...
ys(i))) ys(i)))
else else
disp(sprintf('%16s %12.6f %12.6f',M.endo_names(i,:),ys(i))) disp(sprintf('%16s %12.6f %12.6f', M.endo_names{i}, ys(i)))
end end
end end
@ -500,11 +500,11 @@ M_np = M;
M_np.lead_lag_incidence = lead_lag_incidence_np; M_np.lead_lag_incidence = lead_lag_incidence_np;
M_np.lead_lag_incidence = lead_lag_incidence_np; M_np.lead_lag_incidence = lead_lag_incidence_np;
M_np.endo_nbr = length(v_np); M_np.endo_nbr = length(v_np);
M_np.endo_names = M.endo_names(v_np,:); M_np.endo_names = M.endo_names(v_np);
dr_np = struct(); dr_np = struct();
dr_np = set_state_space(dr_np,M_np,options); dr_np = set_state_space(dr_np,M_np,options);
pm.dr_np = dr_np; pm.dr_np = dr_np;
M_np.var_order_endo_names = M_np.endo_names(dr_np.order_var,:); M_np.var_order_endo_names = M_np.endo_names(dr_np.order_var);
pm.M_np = M_np; pm.M_np = M_np;
pm.i_fwrd_g = find(lead_lag_incidence_np(lead_index,dr_np.order_var)'); pm.i_fwrd_g = find(lead_lag_incidence_np(lead_index,dr_np.order_var)');

View File

@ -1,5 +1,5 @@
function dynareroot = dynare_config(path_to_dynare,verbose) function dynareroot = dynare_config(path_to_dynare, verbose)
%function dynareroot = dynare_config(path_to_dynare)
% This function tests the existence of valid mex files (for qz % This function tests the existence of valid mex files (for qz
% decomposition, solution to sylvester equation and kronecker % decomposition, solution to sylvester equation and kronecker
% products...) and, if needed, add paths to the matlab versions % products...) and, if needed, add paths to the matlab versions
@ -15,7 +15,7 @@ function dynareroot = dynare_config(path_to_dynare,verbose)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %

View File

@ -12,7 +12,7 @@ function oo_recursive_=dynare_estimation(var_list,dname)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -117,16 +117,16 @@ if nnobs > 1 && horizon > 0
if isempty(var_list) if isempty(var_list)
var_list = endo_names; var_list = endo_names;
nvar = size(endo_names,1); nvar = length(endo_names);
SelecVariables = transpose(1:nvar); SelecVariables = transpose(1:nvar);
else else
nvar = size(var_list,1); nvar = length(var_list);
SelecVariables = []; SelecVariables = [];
for i=1:nvar for i=1:nvar
if ~isempty(strmatch(var_list(i,:),endo_names,'exact')) if ~isempty(strmatch(var_list{i}, endo_names, 'exact'))
SelecVariables = [SelecVariables;strmatch(var_list(i,:),endo_names, 'exact')]; SelecVariables = [SelecVariables; strmatch(var_list{i}, endo_names, 'exact')];
else else
error(['Estimation:: ' var_list(i,:) ' isn''t an endogenous variable']) error(['Estimation:: ' var_list{i} ' isn''t an endogenous variable'])
end end
end end
end end
@ -148,7 +148,7 @@ if nnobs > 1 && horizon > 0
m = 1; m = 1;
plot_index=0; plot_index=0;
OutputDirectoryName = CheckPath('graphs',M_.fname); OutputDirectoryName = CheckPath('graphs',M_.fname);
for i = 1:size(var_list,1) for i = 1:length(var_list)
if mod(i,nstar) == 1 if mod(i,nstar) == 1
plot_index=plot_index+1; plot_index=plot_index+1;
hfig = dyn_figure(options_.nodisplay,'Name',['Out of sample forecasts (',num2str(plot_index),')']); hfig = dyn_figure(options_.nodisplay,'Name',['Out of sample forecasts (',num2str(plot_index),')']);
@ -163,7 +163,7 @@ if nnobs > 1 && horizon > 0
else else
offsetx = 0; offsetx = 0;
end end
vname = deblank(var_list(i,:)); vname = var_list{i};
for j=1:nnobs for j=1:nnobs
if mh_replic > 0 if mh_replic > 0
oo_.RecursiveForecast.Mean.(vname)(j,:) = ... oo_.RecursiveForecast.Mean.(vname)(j,:) = ...
@ -207,7 +207,7 @@ if nnobs > 1 && horizon > 0
hold off hold off
xlim([nobs(1)-offsetx nobs(end)+horizon]) xlim([nobs(1)-offsetx nobs(end)+horizon])
m = m + 1; m = m + 1;
if mod(i+1,nstar) == 1 || i ==size(var_list,1) if mod(i+1,nstar) == 1 || i==length(var_list)
dyn_saveas(hfig,[M_.fname,filesep,'graphs',filesep M_.fname '_RecursiveForecasts_' int2str(plot_index)],options_.nodisplay,options_.graph_format); dyn_saveas(hfig,[M_.fname,filesep,'graphs',filesep M_.fname '_RecursiveForecasts_' int2str(plot_index)],options_.nodisplay,options_.graph_format);
end end
end end

View File

@ -12,7 +12,7 @@ function dynare_estimation_1(var_list_,dname)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -141,8 +141,10 @@ missing_value = dataset_info.missing.state;
% Set number of observations % Set number of observations
gend = dataset_.nobs; gend = dataset_.nobs;
% Set the number of observed variables. % Set the number of observed variables.
n_varobs = length(options_.varobs); n_varobs = length(options_.varobs);
% Get the number of parameters to be estimated. % Get the number of parameters to be estimated.
nvx = estim_params_.nvx; % Variance of the structural innovations (number of parameters). nvx = estim_params_.nvx; % Variance of the structural innovations (number of parameters).
nvn = estim_params_.nvn; % Variance of the measurement innovations (number of parameters). nvn = estim_params_.nvn; % Variance of the measurement innovations (number of parameters).
@ -150,8 +152,9 @@ ncx = estim_params_.ncx; % Covariance of the structural innovations (number of
ncn = estim_params_.ncn; % Covariance of the measurement innovations (number of parameters). ncn = estim_params_.ncn; % Covariance of the measurement innovations (number of parameters).
np = estim_params_.np ; % Number of deep parameters. np = estim_params_.np ; % Number of deep parameters.
nx = nvx+nvn+ncx+ncn+np; % Total number of parameters to be estimated. nx = nvx+nvn+ncx+ncn+np; % Total number of parameters to be estimated.
%% Set the names of the priors.
pnames = [' '; 'beta '; 'gamm '; 'norm '; 'invg '; 'unif '; 'invg2'; ' '; 'weibl']; % Set the names of the priors.
pnames = {''; 'beta'; 'gamm'; 'norm'; 'invg'; 'unif'; 'invg2'; ''; 'weibl'};
dr = oo_.dr; dr = oo_.dr;
@ -358,7 +361,7 @@ end
if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
% display results table and store parameter estimates and standard errors in results % display results table and store parameter estimates and standard errors in results
oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_params_,bayestopt_,oo_,pnames,'Posterior','posterior'); oo_ = display_estimation_results_table(xparam1, stdh, M_, options_, estim_params_, bayestopt_, oo_, pnames, 'Posterior', 'posterior');
% Laplace approximation to the marginal log density: % Laplace approximation to the marginal log density:
if options_.cova_compute if options_.cova_compute
estim_params_nbr = size(xparam1,1); estim_params_nbr = size(xparam1,1);
@ -376,7 +379,7 @@ if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
end end
elseif ~any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation elseif ~any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_params_,bayestopt_,oo_,pnames,'Maximum Likelihood','mle'); oo_=display_estimation_results_table(xparam1, stdh, M_, options_, estim_params_, bayestopt_, oo_, pnames, 'Maximum Likelihood', 'mle');
end end
if np > 0 if np > 0
@ -563,7 +566,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
hold on hold on
plot(1:gend,innov(k,:),marker_string{2,1},'linewidth',1) plot(1:gend,innov(k,:),marker_string{2,1},'linewidth',1)
hold off hold off
name = deblank(M_.exo_names(k,:)); name = M_.exo_names{k};
if isempty(NAMES) if isempty(NAMES)
NAMES = name; NAMES = name;
else else
@ -577,7 +580,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
xlim([1 gend]) xlim([1 gend])
end end
if options_.TeX if options_.TeX
texname = M_.exo_names_tex(k,:); texname = M_.exo_names_tex{k};
if isempty(TeXNAMES) if isempty(TeXNAMES)
TeXNAMES = ['$ ' deblank(texname) ' $']; TeXNAMES = ['$ ' deblank(texname) ' $'];
else else
@ -656,12 +659,12 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
set(gca,'XTickLabel',options_.XTickLabel) set(gca,'XTickLabel',options_.XTickLabel)
end end
if options_.TeX if options_.TeX
idx = strmatch(options_.varobs{index(k)},M_.endo_names,'exact'); idx = strmatch(options_.varobs{index(k)}, M_.endo_names, 'exact');
texname = M_.endo_names_tex(idx,:); texname = M_.endo_names_tex{idx};
if isempty(TeXNAMES) if isempty(TeXNAMES)
TeXNAMES = ['$ ' deblank(texname) ' $']; TeXNAMES = ['$ ' texname ' $'];
else else
TeXNAMES = char(TeXNAMES,['$ ' deblank(texname) ' $']); TeXNAMES = char(TeXNAMES,['$ ' texname ' $']);
end end
end end
title(name,'Interpreter','none') title(name,'Interpreter','none')
@ -731,12 +734,12 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
xlim([1 gend]) xlim([1 gend])
end end
if options_.TeX if options_.TeX
idx = strmatch(options_.varobs{k},M_.endo_names,'exact'); idx = strmatch(options_.varobs{k}, M_.endo_names,'exact');
texname = M_.endo_names_tex(idx,:); texname = M_.endo_names_tex{idx};
if isempty(TeXNAMES) if isempty(TeXNAMES)
TeXNAMES = ['$ ' deblank(texname) ' $']; TeXNAMES = ['$ ' texname ' $'];
else else
TeXNAMES = char(TeXNAMES,['$ ' deblank(texname) ' $']); TeXNAMES = char(TeXNAMES,['$ ' texname ' $']);
end end
end end
title(name,'Interpreter','none') title(name,'Interpreter','none')

View File

@ -32,7 +32,7 @@ function [dataset_, dataset_info, xparam1, hh, M_, options_, oo_, estim_params_,
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -56,7 +56,7 @@ if isempty(gsa_flag)
gsa_flag = false; gsa_flag = false;
else else
% Decide if a DSGE or DSGE-VAR has to be estimated. % Decide if a DSGE or DSGE-VAR has to be estimated.
if ~isempty(strmatch('dsge_prior_weight',M_.param_names)) if ~isempty(strmatch('dsge_prior_weight', M_.param_names))
options_.dsge_var = 1; options_.dsge_var = 1;
end end
if isempty(var_list_) if isempty(var_list_)
@ -425,8 +425,8 @@ nspred = M_.nspred; % Number of predetermined variables in the state
var_obs_index_dr = []; var_obs_index_dr = [];
k1 = []; k1 = [];
for i=1:options_.number_of_observed_variables for i=1:options_.number_of_observed_variables
var_obs_index_dr = [var_obs_index_dr; strmatch(options_.varobs{i},M_.endo_names(dr.order_var,:),'exact')]; var_obs_index_dr = [var_obs_index_dr; strmatch(options_.varobs{i}, M_.endo_names(dr.order_var), 'exact')];
k1 = [k1; strmatch(options_.varobs{i},M_.endo_names, 'exact')]; k1 = [k1; strmatch(options_.varobs{i}, M_.endo_names, 'exact')];
end end
k3 = []; k3 = [];
@ -437,9 +437,9 @@ if options_.selected_variables_only
k3 = (1:M_.endo_nbr)'; k3 = (1:M_.endo_nbr)';
k3p = (1:M_.endo_nbr)'; k3p = (1:M_.endo_nbr)';
else else
for i=1:size(var_list_,1) for i=1:length(var_list_)
k3 = [k3; strmatch(var_list_(i,:),M_.endo_names(dr.order_var,:), 'exact')]; k3 = [k3; strmatch(var_list_{i}, M_.endo_names(dr.order_var), 'exact')];
k3p = [k3; strmatch(var_list_(i,:),M_.endo_names, 'exact')]; k3p = [k3; strmatch(var_list_{i}, M_.endo_names, 'exact')];
end end
end end
else else
@ -513,11 +513,11 @@ if options_.analytic_derivation
skipline() skipline()
if any(isnan(params)) if any(isnan(params))
disp('After computing the steadystate, the following parameters are still NaN: '), disp('After computing the steadystate, the following parameters are still NaN: '),
disp(M.param_names(isnan(params),:)) disp(char(M.param_names(isnan(params))))
end end
if any(find(params(~isnan(params))-M.params(~isnan(params)))) if any(find(params(~isnan(params))-M.params(~isnan(params))))
disp('The steadystate file changed the values for the following parameters: '), disp('The steadystate file changed the values for the following parameters: '),
disp(M.param_names(find(params(~isnan(params))-M.params(~isnan(params))),:)) disp(char(M.param_names(find(params(~isnan(params))-M.params(~isnan(params))))))
end end
disp('The derivatives of jacobian and steady-state will be computed numerically'), disp('The derivatives of jacobian and steady-state will be computed numerically'),
disp('(re-set options_.analytic_derivation_mode= -2)'), disp('(re-set options_.analytic_derivation_mode= -2)'),

View File

@ -17,9 +17,7 @@ function [pdraws, TAU, GAM, LRE, gp, H, JJ] = dynare_identification(options_iden
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% None % None
% main % Copyright (C) 2010-2018 Dynare Team
%
% Copyright (C) 2010-2017 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -147,8 +145,9 @@ options_ = set_default_option(options_,'datafile','');
options_.mode_compute = 0; options_.mode_compute = 0;
options_.plot_priors = 0; options_.plot_priors = 0;
options_.smoother=1; options_.smoother=1;
[dataset_,dataset_info,xparam1,hh, M_, options_, oo_, estim_params_,bayestopt_,bounds]=dynare_estimation_init(M_.endo_names,fname_,1, M_, options_, oo_, estim_params_, bayestopt_); [dataset_, dataset_info, xparam1, hh, M_, options_, oo_, estim_params_, bayestopt_, bounds] = ...
options_ident = set_default_option(options_ident,'analytic_derivation_mode',options_.analytic_derivation_mode); % if not set by user, inherit default global one dynare_estimation_init(M_.endo_names, fname_,1, M_, options_, oo_, estim_params_, bayestopt_);
options_ident = set_default_option(options_ident,'analytic_derivation_mode', options_.analytic_derivation_mode); % if not set by user, inherit default global one
if prior_exist if prior_exist
if any(bayestopt_.pshape > 0) if any(bayestopt_.pshape > 0)
@ -206,7 +205,7 @@ if prior_exist
end end
end end
if options_.TeX if options_.TeX
name_tex=char(name_tex); name_tex=name_tex;
end end
else else
indx = [1:M_.param_nbr]; indx = [1:M_.param_nbr];
@ -214,8 +213,10 @@ else
offset = M_.exo_nbr; offset = M_.exo_nbr;
np = M_.param_nbr; np = M_.param_nbr;
nparam = np+offset; nparam = np+offset;
name = [cellstr([repmat('SE_',size(M_.exo_names_tex)),M_.exo_names_tex]); cellstr(M_.param_names)]; name = cellfun(@(x) horzcat('SE_', x), M_.exo_names, 'UniformOutput', false);
name_tex = [cellstr([repmat('$ SE_',size(M_.exo_names_tex)),M_.exo_names_tex,repmat('}$',size(M_.exo_names_tex))]); cellstr(M_.param_names_tex)]; name = vertcat(name, M_.param_names);
name_tex = cellfun(@(x) horzcat('$ SE_{', x, '} $'), M_.exo_names, 'UniformOutput', false);
name_tex = vertcat(name_tex, M_.param_names_tex);
if ~isequal(M_.H,0) if ~isequal(M_.H,0)
fprintf('\ndynare_identification:: Identification does not support measurement errors and will ignore them in the following. To test their identifiability, instead define them explicitly in measurement equations in the model definition.\n') fprintf('\ndynare_identification:: Identification does not support measurement errors and will ignore them in the following. To test their identifiability, instead define them explicitly in measurement equations in the model definition.\n')
end end

View File

@ -4,7 +4,7 @@ function x0=dynare_sensitivity(options_gsa)
% Reference: % Reference:
% M. Ratto, Global Sensitivity Analysis for Macroeconomic models, MIMEO, 2006. % M. Ratto, Global Sensitivity Analysis for Macroeconomic models, MIMEO, 2006.
% Copyright (C) 2008-2017 Dynare Team % Copyright (C) 2008-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -124,7 +124,8 @@ if ~isempty(options_gsa.datafile) || isempty(bayestopt_) || options_gsa.rmse
options_.mode_compute = 0; options_.mode_compute = 0;
options_.filtered_vars = 1; options_.filtered_vars = 1;
options_.plot_priors = 0; options_.plot_priors = 0;
[dataset_,dataset_info,xparam1,hh, M_, options_, oo_, estim_params_,bayestopt_]=dynare_estimation_init(M_.endo_names,fname_,1, M_, options_, oo_, estim_params_, bayestopt_); [dataset_,dataset_info,xparam1,hh, M_, options_, oo_, estim_params_, bayestopt_] = ...
dynare_estimation_init(M_.endo_names, fname_, 1, M_, options_, oo_, estim_params_, bayestopt_);
% computes a first linear solution to set up various variables % computes a first linear solution to set up various variables
else else
if isempty(options_.qz_criterium) if isempty(options_.qz_criterium)
@ -186,23 +187,23 @@ options_gsa = set_default_option(options_gsa,'logtrans_redform',0);
options_gsa = set_default_option(options_gsa,'threshold_redform',[]); options_gsa = set_default_option(options_gsa,'threshold_redform',[]);
options_gsa = set_default_option(options_gsa,'ksstat_redform',0.001); options_gsa = set_default_option(options_gsa,'ksstat_redform',0.001);
options_gsa = set_default_option(options_gsa,'alpha2_redform',1.e-5); options_gsa = set_default_option(options_gsa,'alpha2_redform',1.e-5);
options_gsa = set_default_option(options_gsa,'namendo',[]); options_gsa = set_default_option(options_gsa,'namendo',{});
options_gsa = set_default_option(options_gsa,'namlagendo',[]); options_gsa = set_default_option(options_gsa,'namlagendo',[]);
options_gsa = set_default_option(options_gsa,'namexo',[]); options_gsa = set_default_option(options_gsa,'namexo',{});
% RMSE mapping % RMSE mapping
options_gsa = set_default_option(options_gsa,'load_rmse',0); options_gsa = set_default_option(options_gsa,'load_rmse',0);
options_gsa = set_default_option(options_gsa,'lik_only',0); options_gsa = set_default_option(options_gsa,'lik_only',0);
options_gsa = set_default_option(options_gsa,'var_rmse',char(options_.varobs)); options_gsa = set_default_option(options_gsa,'var_rmse', options_.varobs);
%get corresponding TeX-names; %get corresponding TeX-names;
options_gsa.var_rmse_tex=''; options_gsa.var_rmse_tex={};
for ii=1:size(options_gsa.var_rmse,1) for ii=1:length(options_gsa.var_rmse)
temp_name=M_.endo_names_tex(strmatch(deblank(options_gsa.var_rmse(ii,:)),M_.endo_names,'exact'),:); temp_name = M_.endo_names_tex{strmatch(options_gsa.var_rmse{ii}, M_.endo_names, 'exact')};
options_gsa.var_rmse_tex=strvcat(options_gsa.var_rmse_tex,temp_name); options_gsa.var_rmse_tex = vertcat(options_gsa.var_rmse_tex, temp_name);
end end
options_gsa = set_default_option(options_gsa,'pfilt_rmse',0.1); options_gsa = set_default_option(options_gsa,'pfilt_rmse', 0.1);
options_gsa = set_default_option(options_gsa,'istart_rmse',options_.presample+1); options_gsa = set_default_option(options_gsa,'istart_rmse', options_.presample+1);
options_gsa = set_default_option(options_gsa,'alpha_rmse',0.001); options_gsa = set_default_option(options_gsa,'alpha_rmse', 0.001);
options_gsa = set_default_option(options_gsa,'alpha2_rmse',1.e-5); options_gsa = set_default_option(options_gsa,'alpha2_rmse', 1.e-5);
if options_gsa.neighborhood_width if options_gsa.neighborhood_width
options_gsa.pprior=0; options_gsa.pprior=0;
@ -324,13 +325,13 @@ if options_gsa.redform && ~isempty(options_gsa.namendo)
x0 = stab_map_(OutputDirectoryName,options_gsa); x0 = stab_map_(OutputDirectoryName,options_gsa);
end end
if strmatch(':',options_gsa.namendo,'exact') if strmatch(':',options_gsa.namendo,'exact')
options_gsa.namendo=M_.endo_names(1:M_.orig_endo_nbr,:); options_gsa.namendo = M_.endo_names(1:M_.orig_endo_nbr);
end end
if strmatch(':',options_gsa.namexo,'exact') if strmatch(':',options_gsa.namexo,'exact')
options_gsa.namexo=M_.exo_names; options_gsa.namexo = M_.exo_names;
end end
if strmatch(':',options_gsa.namlagendo,'exact') if strmatch(':',options_gsa.namlagendo,'exact')
options_gsa.namlagendo=M_.endo_names(1:M_.orig_endo_nbr,:); options_gsa.namlagendo = M_.endo_names(1:M_.orig_endo_nbr);
end end
% options_.opt_gsa = options_gsa; % options_.opt_gsa = options_gsa;
if options_gsa.morris==1 if options_gsa.morris==1
@ -345,7 +346,6 @@ if options_gsa.redform && ~isempty(options_gsa.namendo)
fprintf('After obtaining the files, you need to unpack them and set a Matlab Path to those files.\n') fprintf('After obtaining the files, you need to unpack them and set a Matlab Path to those files.\n')
error('SS-ANOVA-R Toolbox missing!') error('SS-ANOVA-R Toolbox missing!')
end end
redform_map(OutputDirectoryName,options_gsa); redform_map(OutputDirectoryName,options_gsa);
end end
end end
@ -462,7 +462,7 @@ if options_gsa.glue
Obs.name{j} = options_.varobs{j}; Obs.name{j} = options_.varobs{j};
vj = options_.varobs{j}; vj = options_.varobs{j};
jxj = strmatch(vj,lgy_(dr_.order_var,:),'exact'); jxj = strmatch(vj,lgy_(dr_.order_var),'exact');
js = strmatch(vj,lgy_,'exact'); js = strmatch(vj,lgy_,'exact');
if ~options_gsa.ppost if ~options_gsa.ppost
% y0=zeros(gend+1,nruns); % y0=zeros(gend+1,nruns);
@ -502,7 +502,7 @@ if options_gsa.glue
for j=1:M_.endo_nbr for j=1:M_.endo_nbr
if ~ismember(j,ismoo) if ~ismember(j,ismoo)
jsmoo=jsmoo+1; jsmoo=jsmoo+1;
vj=deblank(M_.endo_names(dr_.order_var(j),:)); vj = M_.endo_names{dr_.order_var(j)};
if ~options_gsa.ppost if ~options_gsa.ppost
% y0 = squeeze(stock_smooth(:,j,:)) + ... % y0 = squeeze(stock_smooth(:,j,:)) + ...
% kron(stock_ys(j,:),ones(size(stock_smooth,1),1)); % kron(stock_ys(j,:),ones(size(stock_smooth,1),1));
@ -518,9 +518,9 @@ if options_gsa.glue
Out1(jsmoo).ini = 'yes'; Out1(jsmoo).ini = 'yes';
end end
end end
tit(M_.exo_names_orig_ord,:) = M_.exo_names; tit(M_.exo_names_orig_ord) = M_.exo_names;
for j=1:M_.exo_nbr for j=1:M_.exo_nbr
Exo(j).name = deblank(tit(j,:)); Exo(j).name = tit{j};
end end
if ~options_gsa.ppost if ~options_gsa.ppost
Lik(length(options_.varobs)+1).name = 'logpo'; Lik(length(options_.varobs)+1).name = 'logpo';

View File

@ -1,4 +1,4 @@
function dynasave(s,var_list) function dynasave(s, var_list)
% function dynasave(s,var_list) % function dynasave(s,var_list)
% This optional command saves the simulation results in a .MAT file. % This optional command saves the simulation results in a .MAT file.
% %
@ -12,7 +12,7 @@ function dynasave(s,var_list)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2001-2015 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -31,28 +31,28 @@ function dynasave(s,var_list)
global M_ oo_ global M_ oo_
if size(var_list,1) == 0 if isempty(var_list)
var_list = M_.endo_names(1:M_.orig_endo_nbr, :); var_list = M_.endo_names(1:M_.orig_endo_nbr);
end end
if ~isfield(oo_,'endo_simul') || isempty(oo_.endo_simul) if ~isfield(oo_, 'endo_simul') || isempty(oo_.endo_simul)
error('dynasave:: The results structure does not contain simulated series. Maybe the periods option has not been set.') error('dynasave:: The results structure does not contain simulated series. Maybe the periods option has not been set.')
end end
n = size(var_list,1); n = length(var_list);
ivar=zeros(n,1); ivar = zeros(n, 1);
for i=1:n for i=1:n
i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact'); i_tmp = strmatch(var_list{i}, M_.endo_names, 'exact');
if isempty(i_tmp) if isempty(i_tmp)
error (['One of the specified variables does not exist']) ; error ('One of the specified variables does not exist') ;
else else
ivar(i) = i_tmp; ivar(i) = i_tmp;
end end
end end
eval([var_list(1,:) '=oo_.endo_simul(ivar(1),:)'';']) eval([var_list{1} ' = oo_.endo_simul(ivar(1),:)'';'])
eval(['save ' s ' ' var_list(1,:) ' -mat']) eval(['save ' s ' ' var_list{1} ' -mat'])
for dynare__i_ = 2:n for dynare__i_ = 2:n
eval([var_list(dynare__i_,:) '=oo_.endo_simul(ivar(dynare__i_),:)'';']) eval([var_list{dynare__i_} ' = oo_.endo_simul(ivar(dynare__i_),:)'';'])
eval(['save ' s ' ' var_list(dynare__i_,:) ' -append -mat']) eval(['save ' s ' ' var_list{dynare__i_} ' -append -mat'])
end end

View File

@ -13,7 +13,7 @@ function dynatype (s,var_list)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -34,23 +34,24 @@ global M_ oo_
fid=fopen(s,'w') ; fid=fopen(s,'w') ;
if size(var_list,1) == 0 if isempty(var_list)
var_list = M_.endo_names(1:M_.orig_endo_nbr,:); var_list = M_.endo_names(1:M_.orig_endo_nbr);
end end
n = size(var_list,1); n = length(var_list);
ivar=zeros(n,1); ivar = zeros(n,1);
for i=1:n for i=1:n
i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact'); i_tmp = strmatch(var_list{i}, M_.endo_names, 'exact');
if isempty(i_tmp) if isempty(i_tmp)
error (['One of the specified variables does not exist']) ; error ('One of the specified variables does not exist') ;
else else
ivar(i) = i_tmp; ivar(i) = i_tmp;
end end
end end
for i = 1:n for i = 1:n
fprintf(fid,M_.endo_names(ivar(i),:),'\n') ; fprintf(fid,M_.endo_names{ivar(i)},'\n') ;
fprintf(fid,'\n') ; fprintf(fid,'\n') ;
fprintf(fid,'%15.8g\n',oo_.endo_simul(ivar(i),:)') ; fprintf(fid,'%15.8g\n',oo_.endo_simul(ivar(i),:)') ;
end end

View File

@ -1,17 +1,21 @@
function dyntable(options_,title,headers,labels,values,label_width,val_width,val_precis,optional_header) function dyntable(options_, title, headers, labels, values, label_width, val_width, val_precis, optional_header)
% function dyntable(title,headers,labels,values,label_width,val_width,val_precis)
% Inputs: % Prints a table of results in main command window.
% options_ [structure] Dynare options structure
% title [string] Table title
% headers [n by nchar] character array of labels for header row
% labels [n by nchar] character array of labels for label column
% values [matrix] matrix of values to display
% label_width [scalar] Width of the label
% val_width [scalar] Width of value column
% val_precis [integer] precision of displayed values
% %
% INPUTS
% - options_ [structure] Dynare options structure
% - title [string] Table title
% - headers [cell] labels for header row (each element is a row characater array)
% - labels [cell] labels for label column (each element is a row characater array)
% - values [double] matrix of values to display
% - label_width [integer] scalar, width of the label
% - val_width [integer] scalar, width of value column
% - val_precis [integer] scalar, precision of displayed values
% %
% Copyright (C) 2002-2017 Dynare Team % OUTPUTS
% none
% Copyright (C) 2002-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -32,16 +36,16 @@ if options_.noprint
return return
end end
%% get width of label column % Set width of label column
if ~isempty(label_width) if isempty(label_width)
label_width = max(size(deblank(char(headers(1,:),labels)),2)+2, ... label_width = cellofchararraymaxlength(vertcat(headers{1}, labels))+2;
label_width); else
else %use default length label_width = max(cellofchararraymaxlength(vertcat(headers{1}, labels))+2, label_width);
label_width = max(size(deblank(char(headers(1,:),labels)),2))+2;
end end
label_format_leftbound = sprintf('%%-%ds',label_width); label_format_leftbound = sprintf('%%-%ds', label_width);
%% get width of label column
% Set width of other columns
if all(~isfinite(values)) if all(~isfinite(values))
values_length = 4; values_length = 4;
else else
@ -50,32 +54,32 @@ end
if any(values) < 0 %add one character for minus sign if any(values) < 0 %add one character for minus sign
values_length = values_length+1; values_length = values_length+1;
end end
headers_length = cellofchararraymaxlength(headers(2:end));
%% get width of header strings if isempty(val_width)
headers_length = max(size(deblank(headers(2:end,:)),2)); val_width = max(headers_length, values_length)+2;
if ~isempty(val_width)
val_width = max(max(headers_length,values_length)+2,val_width);
else else
val_width = max(headers_length,values_length)+2; val_width = max(max(headers_length, values_length)+2, val_width);
end end
value_format = sprintf('%%%d.%df',val_width,val_precis); value_format = sprintf('%%%d.%df', val_width, val_precis);
header_string_format = sprintf('%%%ds',val_width); header_string_format = sprintf('%%%ds', val_width);
if length(title) > 0 if length(title) > 0
fprintf('\n\n%s\n',title); fprintf('\n\n%s\n',title);
end end
%Create and print header string
% Create and print header string
if nargin==9 if nargin==9
disp(optional_header) disp(optional_header)
end end
if length(headers) > 0 if length(headers) > 0
hh = sprintf(label_format_leftbound ,deblank(headers(1,:))); hh = sprintf(label_format_leftbound , headers{1});
for i=2:size(headers,1) for i=2:length(headers)
hh = [hh sprintf(header_string_format,deblank(headers(i,:)))]; hh = [hh sprintf(header_string_format, headers{i})];
end end
disp(hh); disp(hh)
end end
for i=1:size(values,1) for i=1:size(values,1)
disp([sprintf(label_format_leftbound ,deblank(labels(i,:))) sprintf(value_format ,values(i,:))]); disp([sprintf(label_format_leftbound, labels{i}) sprintf(value_format, values(i,:))])
end end

View File

@ -15,7 +15,7 @@ function [info, info_irf, info_moment, data_irf, data_moment] = endogenous_prior
% info_moment [double] array of test checks for all individual moment restrictions % info_moment [double] array of test checks for all individual moment restrictions
% %
% Copyright (C) 2013-2017 Dynare Team % Copyright (C) 2013-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -47,22 +47,22 @@ if ~isempty(endo_prior_restrictions.irf)
error('The algorithm for prior (sign) restrictions on irf''s is currently restricted to first-order decision rules') error('The algorithm for prior (sign) restrictions on irf''s is currently restricted to first-order decision rules')
return return
end end
varlist=Model.endo_names(DynareResults.dr.order_var,:); varlist = Model.endo_names(DynareResults.dr.order_var);
if isempty(T) if isempty(T)
[T,R,SteadyState,infox,Model,DynareOptions,DynareResults] = dynare_resolve(Model,DynareOptions,DynareResults); [T,R,SteadyState,infox,Model,DynareOptions,DynareResults] = dynare_resolve(Model,DynareOptions,DynareResults);
else % check if T and R are given in the restricted form!!! else % check if T and R are given in the restricted form!!!
if size(T,1)<size(varlist,1) if size(T,1)<length(varlist)
varlist=varlist(DynareResults.dr.restrict_var_list,:); varlist = varlist(DynareResults.dr.restrict_var_list);
end end
% check if endo_prior_restrictions.irf{:,1} variables are in varlist % check if endo_prior_restrictions.irf{:,1} variables are in varlist
varlistok=1; varlistok=1;
for j=1:size(endo_prior_restrictions.irf,1) for j=1:size(endo_prior_restrictions.irf,1)
if isempty(strmatch(endo_prior_restrictions.irf{j,1},varlist,'exact')) if isempty(strmatch(endo_prior_restrictions.irf{j,1}, varlist, 'exact'))
varlistok=0; varlistok=0;
end end
end end
if ~varlistok if ~varlistok
varlist=Model.endo_names(DynareResults.dr.order_var,:); varlist = Model.endo_names(DynareResults.dr.order_var);
[T,R,SteadyState,infox,Model,DynareOptions,DynareResults] = dynare_resolve(Model,DynareOptions,DynareResults); [T,R,SteadyState,infox,Model,DynareOptions,DynareResults] = dynare_resolve(Model,DynareOptions,DynareResults);
end end
end end
@ -81,8 +81,8 @@ if ~isempty(endo_prior_restrictions.irf)
if endo_prior_restrictions.irf{j,3}~=t if endo_prior_restrictions.irf{j,3}~=t
continue continue
end end
iendo=strmatch(endo_prior_restrictions.irf{j,1},varlist,'exact'); iendo=strmatch(endo_prior_restrictions.irf{j,1}, varlist, 'exact');
iexo=strmatch(endo_prior_restrictions.irf{j,2},Model.exo_names,'exact'); iexo=strmatch(endo_prior_restrictions.irf{j,2}, Model.exo_names, 'exact');
data_irf{j}=[data_irf{j}; [t RR(iendo,iexo)]]; data_irf{j}=[data_irf{j}; [t RR(iendo,iexo)]];
if (RR(iendo,iexo)>endo_prior_restrictions.irf{j,4}(1)) && (RR(iendo,iexo)<endo_prior_restrictions.irf{j,4}(2)) if (RR(iendo,iexo)>endo_prior_restrictions.irf{j,4}(1)) && (RR(iendo,iexo)<endo_prior_restrictions.irf{j,4}(2))
info_irf(j,:)=info_irf(j,:).*[0, 0]; info_irf(j,:)=info_irf(j,:).*[0, 0];
@ -108,7 +108,7 @@ if ~isempty(endo_prior_restrictions.moment)
return return
end end
data_moment=cell(size(endo_prior_restrictions.moment,1),1); data_moment=cell(size(endo_prior_restrictions.moment,1),1);
var_list_=endo_prior_restrictions.moment{1,1}; var_list_ = endo_prior_restrictions.moment{1,1};
for j=1:size(endo_prior_restrictions.moment,1) for j=1:size(endo_prior_restrictions.moment,1)
tmp=endo_prior_restrictions.moment{j,1}; tmp=endo_prior_restrictions.moment{j,1};
if ~ismember(tmp,cellstr(var_list_)) if ~ismember(tmp,cellstr(var_list_))
@ -129,7 +129,7 @@ if ~isempty(endo_prior_restrictions.moment)
nvar = size(var_list_,1); nvar = size(var_list_,1);
ivar=zeros(nvar,1); ivar=zeros(nvar,1);
for i=1:nvar for i=1:nvar
i_tmp = strmatch(var_list_(i,:),Model.endo_names,'exact'); i_tmp = strmatch(var_list_(i,:), Model.endo_names, 'exact');
if isempty(i_tmp) if isempty(i_tmp)
error (['One of the variable specified does not exist']) error (['One of the variable specified does not exist'])
else else

View File

@ -19,7 +19,7 @@ function [ts, DynareResults] = extended_path(initialconditions, samplesize, exog
% %
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% Copyright (C) 2009-2017 Dynare Team % Copyright (C) 2009-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -98,7 +98,7 @@ if any(isnan(endogenous_variables_paths(:)))
nn = size(endogenous_variables_paths, 1); nn = size(endogenous_variables_paths, 1);
endogenous_variables_paths = reshape(endogenous_variables_paths(sl), nn, length(sl)/nn); endogenous_variables_paths = reshape(endogenous_variables_paths(sl), nn, length(sl)/nn);
end end
ts = dseries(transpose(endogenous_variables_paths), initial_period, cellstr(DynareModel.endo_names)); ts = dseries(transpose(endogenous_variables_paths), initial_period, DynareModel.endo_names);
DynareResults.endo_simul = transpose(ts.data); DynareResults.endo_simul = transpose(ts.data);
assignin('base', 'Simulated_time_series', ts); assignin('base', 'Simulated_time_series', ts);

View File

@ -11,7 +11,7 @@ function planner_objective_value = evaluate_planner_objective(M,options,oo)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2007-2017 Dynare Team % Copyright (C) 2007-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -39,7 +39,7 @@ if nspred > 180
planner_objective_value = NaN; planner_objective_value = NaN;
return return
end end
beta = get_optimal_policy_discount_factor(M.params,M.param_names); beta = get_optimal_policy_discount_factor(M.params, M.param_names);
Gy = dr.ghx(nstatic+(1:nspred),:); Gy = dr.ghx(nstatic+(1:nspred),:);
Gu = dr.ghu(nstatic+(1:nspred),:); Gu = dr.ghu(nstatic+(1:nspred),:);

View File

@ -22,7 +22,7 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -124,14 +124,14 @@ if options.ramsey_policy
if ~isempty(infrow) if ~isempty(infrow)
fprintf('\nevaluate_steady_state: The initial values for the steady state of the following variables are Inf:\n'); fprintf('\nevaluate_steady_state: The initial values for the steady state of the following variables are Inf:\n');
for iter=1:length(infrow) for iter=1:length(infrow)
fprintf('%s\n',M.endo_names(infrow(iter),:)); fprintf('%s\n',M.endo_names{infrow(iter)});
end end
end end
nanrow=find(isnan(ys_init)); nanrow=find(isnan(ys_init));
if ~isempty(nanrow) if ~isempty(nanrow)
fprintf('\nevaluate_steady_state: The initial values for the steady state of the following variables are NaN:\n'); fprintf('\nevaluate_steady_state: The initial values for the steady state of the following variables are NaN:\n');
for iter=1:length(nanrow) for iter=1:length(nanrow)
fprintf('%s\n',M.endo_names(nanrow(iter),:)); fprintf('%s\n',M.endo_names{nanrow(iter)});
end end
end end
end end

View File

@ -19,7 +19,7 @@ function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options,
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -117,19 +117,19 @@ if length(M.aux_vars) > 0 && ~options.ramsey_policy
ys3 = ys; ys3 = ys;
idx = find(abs(ys0-ys1)>0); idx = find(abs(ys0-ys1)>0);
if ~isempty(idx) if ~isempty(idx)
M.endo_names(idx,:) M.endo_names{idx}
else else
disp('1-invariant') disp('1-invariant')
end end
idx = find(abs(ys2-ys1)>0); idx = find(abs(ys2-ys1)>0);
if ~isempty(idx) if ~isempty(idx)
M.endo_names(idx,:) M.endo_names{idx}
else else
disp('2-invariant') disp('2-invariant')
end end
idx = find(abs(ys3-ys3)>0); idx = find(abs(ys3-ys3)>0);
if ~isempty(idx) if ~isempty(idx)
M.endo_names(idx,:) M.endo_names{idx}
else else
disp('3-invariant') disp('3-invariant')
end end
@ -160,9 +160,7 @@ elseif ~isempty(options.steadystate_partial)
nov = length(ssvar); nov = length(ssvar);
indv = zeros(nov,1); indv = zeros(nov,1);
for i = 1:nov for i = 1:nov
indv(i) = strmatch(ssvar(i),M.endo_names,'exact'); indv(i) = strmatch(ssvar(i), M.endo_names, 'exact');
end end
[ys,check] = dynare_solve('restricted_steadystate',... [ys,check] = dynare_solve('restricted_steadystate', ys(indv), options, exo_ss,indv);
ys(indv),...
options, exo_ss,indv);
end end

View File

@ -22,7 +22,7 @@ function [yf,int_width,int_width_ME]=forcst(dr,y0,horizon,var_list,M_,oo_,option
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -48,16 +48,16 @@ endo_nbr = M_.endo_nbr;
inv_order_var = dr.inv_order_var; inv_order_var = dr.inv_order_var;
[A,B] = kalman_transition_matrix(dr,nstatic+(1:nspred),1:nc,M_.exo_nbr); [A,B] = kalman_transition_matrix(dr,nstatic+(1:nspred),1:nc,M_.exo_nbr);
if size(var_list,1) == 0 if isempty(var_list)
var_list = M_.endo_names(1:M_.orig_endo_nbr,:); var_list = M_.endo_names(1:M_.orig_endo_nbr);
end end
nvar = size(var_list,1); nvar = length(var_list);
ivar=zeros(nvar,1); ivar = zeros(nvar, 1);
for i=1:nvar for i=1:nvar
i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact'); i_tmp = strmatch(var_list{i}, M_.endo_names, 'exact');
if isempty(i_tmp) if isempty(i_tmp)
disp(var_list(i,:)); disp(var_list{i});
error (['One of the variable specified does not exist']) ; error ('One of the variable specified does not exist') ;
else else
ivar(i) = i_tmp; ivar(i) = i_tmp;
end end
@ -71,8 +71,8 @@ sigma_u = B*M_.Sigma_e*B';
sigma_u1 = ghu1*M_.Sigma_e*ghu1'; sigma_u1 = ghu1*M_.Sigma_e*ghu1';
sigma_y = 0; %no uncertainty about the states sigma_y = 0; %no uncertainty about the states
var_yf=NaN(horizon,nvar); %initialize var_yf = NaN(horizon,nvar); %initialize
for i=1:horizon for i = 1:horizon
%map uncertainty about states into uncertainty about observables %map uncertainty about states into uncertainty about observables
sigma_y1 = ghx1*sigma_y*ghx1'+sigma_u1; sigma_y1 = ghx1*sigma_y*ghx1'+sigma_u1;
var_yf(i,:) = diag(sigma_y1)'; var_yf(i,:) = diag(sigma_y1)';
@ -85,18 +85,18 @@ for i=1:horizon
end end
if nargout==3 if nargout==3
var_yf_ME=var_yf; var_yf_ME=var_yf;
[loc_H,loc_varlist]=ismember(options_.varobs',options_.varlist); [loc_H, loc_varlist] = ismember(options_.varobs', options_.varlist);
loc_varlist(loc_varlist==0)=[]; loc_varlist(loc_varlist==0) = [];
if ~isempty(loc_varlist) if ~isempty(loc_varlist)
var_yf_ME(:,loc_varlist)=var_yf(:,loc_varlist)+ repmat(diag(M_.H(loc_H,loc_H))',horizon,1); var_yf_ME(:,loc_varlist) = var_yf(:,loc_varlist)+repmat(diag(M_.H(loc_H,loc_H))', horizon, 1);
end end
int_width_ME = zeros(horizon,nvar); int_width_ME = zeros(horizon, nvar);
end end
fact = norminv((1-options_.forecasts.conf_sig)/2,0,1); fact = norminv((1-options_.forecasts.conf_sig)/2, 0, 1);
int_width = zeros(horizon,nvar); int_width = zeros(horizon, nvar);
for i=1:nvar for i = 1:nvar
int_width(:,i) = -fact*sqrt(var_yf(:,i)); int_width(:,i) = -fact*sqrt(var_yf(:,i));
if nargout==3 if nargout==3
int_width_ME(:,i) = -fact*sqrt(var_yf_ME(:,i)); int_width_ME(:,i) = -fact*sqrt(var_yf_ME(:,i));

View File

@ -8,7 +8,7 @@ function forecast_graphs(var_list,M_, oo_,options_)
% o oo_ outputs structure % o oo_ outputs structure
% o options_ options structure % o options_ options structure
% Copyright (C) 2008-2017 Dynare Team % Copyright (C) 2008-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -35,13 +35,13 @@ yf = oo_.forecast.Mean;
hpdinf = oo_.forecast.HPDinf; hpdinf = oo_.forecast.HPDinf;
hpdsup = oo_.forecast.HPDsup; hpdsup = oo_.forecast.HPDsup;
if isempty(var_list) if isempty(var_list)
var_list = endo_names(1:M_.orig_endo_nbr,:); var_list = endo_names(1:M_.orig_endo_nbr);
end end
i_var = []; i_var = [];
for i = 1:size(var_list) for i = 1:length(var_list)
tmp = strmatch(var_list(i,:),endo_names,'exact'); tmp = strmatch(var_list{i}, endo_names, 'exact');
if isempty(tmp) if isempty(tmp)
error([var_list(i,:) ' isn''t an endogenous variable']) error([var_list{i} ' isn''t an endogenous variable'])
end end
i_var = [i_var; tmp]; i_var = [i_var; tmp];
end end
@ -55,17 +55,18 @@ if ~exist([dname '/graphs'],'dir')
mkdir(dname,'graphs'); mkdir(dname,'graphs');
end end
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) if options_.TeX && any(strcmp('eps', cellstr(options_.graph_format)))
fidTeX=write_LaTeX_header([M_.dname '/graphs/',fname,'_forcst.tex']); fidTeX = write_LaTeX_header([M_.dname '/graphs/', fname, '_forcst.tex']);
end end
m = 1; m = 1;
n_fig = 1; n_fig = 1;
hh=dyn_figure(options_.nodisplay,'Name','Forecasts (I)'); hh = dyn_figure(options_.nodisplay, 'Name', 'Forecasts (I)');
for j= 1:nvar for j= 1:nvar
if m > nc*nr if m > nc*nr
dyn_saveas(hh,[ dname '/graphs/forcst' int2str(n_fig)],options_.nodisplay,options_.graph_format); dyn_saveas(hh,[ dname '/graphs/forcst' int2str(n_fig)], options_.nodisplay, options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) if options_.TeX && any(strcmp('eps', cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n'); fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n'); fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/forcst%d}\n',dname,n_fig); fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/forcst%d}\n',dname,n_fig);
@ -78,16 +79,9 @@ for j= 1:nvar
eval(['hh=dyn_figure(options_.nodisplay,''Name'',''Forecasts (' int2str(n_fig) ')'');']); eval(['hh=dyn_figure(options_.nodisplay,''Name'',''Forecasts (' int2str(n_fig) ')'');']);
m = 1; m = 1;
end end
subplot(nr,nc,m); subplot(nr, nc, m);
vn = deblank(endo_names(i_var(j),:)); vn = endo_names{i_var(j)};
obs = 0; obs = 0;
% $$$ k = strmatch(vn,varobs,'exact');
% $$$ if ~isempty(k)
% $$$ yy = y.(vn)(end-9:end) + repmat(ys(i_var(j)),10,1)+trend(k,:)';
% $$$ plot(yy);
% $$$ hold on
% $$$ obs = 10;
% $$$ end
plot([NaN(obs,1); yf.(vn)],'b-'); plot([NaN(obs,1); yf.(vn)],'b-');
hold on hold on
plot([NaN(obs,1); hpdinf.(vn)],'b-'); plot([NaN(obs,1); hpdinf.(vn)],'b-');

View File

@ -11,7 +11,7 @@ function formdata(fname,date)
% SPECIAL REQUIREMENT % SPECIAL REQUIREMENT
% none % none
% Copyright (C) 2007-2017 Dynare Team % Copyright (C) 2007-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -31,11 +31,11 @@ function formdata(fname,date)
global M_ oo_ global M_ oo_
fid = fopen([fname '_endo.frm'],'w'); fid = fopen([fname '_endo.frm'],'w');
n=size(oo_.endo_simul,1); n = size(oo_.endo_simul, 1);
t=size(oo_.endo_simul,2); t = size(oo_.endo_simul, 2);
SN=upper(cellstr(M_.endo_names)); SN = upper(M_.endo_names);
for i=1:n for i = 1:n
str=char(SN(i)); str=SN{i};
fprintf(fid,'USER: x x DATAFILE: x %s\n',str); fprintf(fid,'USER: x x DATAFILE: x %s\n',str);
fprintf(fid,'PER: 1 YEAR: %s FRAC: 1 NOBS: %d CLINES: 0 DLINES: ???\n',date,t); fprintf(fid,'PER: 1 YEAR: %s FRAC: 1 NOBS: %d CLINES: 0 DLINES: ???\n',date,t);
fprintf(fid,'%10.5f %10.5f %10.5f %10.5f\n',reshape(oo_.endo_simul(i,1:floor(t/4)*4),floor(t/4),4)); fprintf(fid,'%10.5f %10.5f %10.5f %10.5f\n',reshape(oo_.endo_simul(i,1:floor(t/4)*4),floor(t/4),4));
@ -56,9 +56,9 @@ fclose(fid);
fid = fopen([fname '_exo.frm'],'w'); fid = fopen([fname '_exo.frm'],'w');
n=size(oo_.exo_simul,2); n=size(oo_.exo_simul,2);
t=size(oo_.exo_simul,1); t=size(oo_.exo_simul,1);
SN=upper(cellstr(M_.exo_names)); SN=upper(M_.exo_names);
for i=1:n for i=1:n
str=char(SN(i)); str = SN{i};
fprintf(fid,'USER: x x DATAFILE: x %s\n',str); fprintf(fid,'USER: x x DATAFILE: x %s\n',str);
fprintf(fid,'PER: 1 YEAR: %s FRAC: 1 NOBS: %d CLINES: 0 DLINES: ???\n',date,t); fprintf(fid,'PER: 1 YEAR: %s FRAC: 1 NOBS: %d CLINES: 0 DLINES: ???\n',date,t);
fprintf(fid,'%10.5f %10.5f %10.5f %10.5f\n',reshape(oo_.exo_simul(1:floor(t/4)*4,i),floor(t/4),4)); fprintf(fid,'%10.5f %10.5f %10.5f %10.5f\n',reshape(oo_.exo_simul(1:floor(t/4)*4,i),floor(t/4),4));

View File

@ -11,7 +11,7 @@ function generate_trace_plots(chain_number)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2016 Dynare Team % Copyright (C) 2016-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -32,37 +32,37 @@ global M_ options_ estim_params_
% Get informations about the posterior draws: % Get informations about the posterior draws:
MetropolisFolder = CheckPath('metropolis',M_.dname); MetropolisFolder = CheckPath('metropolis', M_.dname);
load_last_mh_history_file(MetropolisFolder, M_.fname); load_last_mh_history_file(MetropolisFolder, M_.fname);
if chain_number>record.Nblck if chain_number>record.Nblck
error('generate_trace_plots:: chain number is bigger than existing number of chains') error('generate_trace_plots:: chain number is bigger than existing number of chains')
end end
trace_plot(options_,M_,estim_params_,'PosteriorDensity',chain_number) trace_plot(options_, M_, estim_params_, 'PosteriorDensity', chain_number)
for ii=1:size(estim_params_.param_vals,1) for ii=1:size(estim_params_.param_vals, 1)
parameter_name=deblank(M_.param_names(estim_params_.param_vals(ii,1),:)); parameter_name = M_.param_names{estim_params_.param_vals(ii,1)};
trace_plot(options_,M_,estim_params_,'DeepParameter',chain_number,parameter_name) trace_plot(options_, M_, estim_params_, 'DeepParameter', chain_number, parameter_name)
end end
for ii=1:size(estim_params_.var_exo,1) for ii=1:size(estim_params_.var_exo, 1)
parameter_name=deblank(M_.exo_names(estim_params_.var_exo(ii,1),:)); parameter_name = M_.exo_names{estim_params_.var_exo(ii,1)};
trace_plot(options_,M_,estim_params_,'StructuralShock',chain_number,parameter_name) trace_plot(options_, M_, estim_params_, 'StructuralShock', chain_number, parameter_name)
end end
for ii=1:size(estim_params_.var_endo,1) for ii=1:size(estim_params_.var_endo, 1)
parameter_name=deblank(M_.endo_names(estim_params_.var_endo(ii,1),:)); parameter_name = M_.endo_names{estim_params_.var_endo(ii,1)};
trace_plot(options_,M_,estim_params_,'MeasurementError',chain_number,parameter_name) trace_plot(options_, M_, estim_params_, 'MeasurementError', chain_number, parameter_name)
end end
for ii=1:size(estim_params_.corrn,1) for ii=1:size(estim_params_.corrn, 1)
parameter_name_1=deblank(M_.endo_names(estim_params_.corrn(ii,1),:)); parameter_name_1 = M_.endo_names{estim_params_.corrn(ii,1)};
parameter_name_2=deblank(M_.endo_names(estim_params_.corrn(ii,2),:)); parameter_name_2 = M_.endo_names{estim_params_.corrn(ii,2)};
trace_plot(options_,M_,estim_params_,'MeasurementError',chain_number,parameter_name_1,parameter_name_2) trace_plot(options_, M_, estim_params_, 'MeasurementError', chain_number, parameter_name_1, parameter_name_2)
end end
for ii=1:size(estim_params_.corrx,1) for ii=1:size(estim_params_.corrx, 1)
parameter_name_1=deblank(M_.exo_names(estim_params_.corrx(ii,1),:)); parameter_name_1 = M_.exo_names{estim_params_.corrx(ii,1)};
parameter_name_2=deblank(M_.exo_names(estim_params_.corrx(ii,2),:)); parameter_name_2 = M_.exo_names{estim_params_.corrx(ii,2)};
trace_plot(options_,M_,estim_params_,'StructuralShock',chain_number,parameter_name_1,parameter_name_2) trace_plot(options_, M_, estim_params_, 'StructuralShock', chain_number, parameter_name_1, parameter_name_2)
end end

View File

@ -8,7 +8,7 @@ function irf_shocks_indx=getIrfShocksIndx()
% Outputs: % Outputs:
% irf_shocks_indx: [1 by n_irf_shocks] vector storing the indices % irf_shocks_indx: [1 by n_irf_shocks] vector storing the indices
% %
% Copyright (C) 2011-2017 Dynare Team % Copyright (C) 2011-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -32,7 +32,7 @@ if (isfield(options_,'irf_shocks')==0)
else else
irf_shocks_indx = zeros(1,size(options_.irf_shocks,1)); irf_shocks_indx = zeros(1,size(options_.irf_shocks,1));
for i=1:size(options_.irf_shocks,1) for i=1:size(options_.irf_shocks,1)
irf_shocks_indx(i) = find(strcmp(deblank(options_.irf_shocks(i,:)), cellstr(M_.exo_names))); irf_shocks_indx(i) = find(strcmp(deblank(options_.irf_shocks(i,:)), M_.exo_names));
end end
irf_shocks_indx_unique=unique(irf_shocks_indx); irf_shocks_indx_unique=unique(irf_shocks_indx);
if options_.debug && (length(irf_shocks_indx_unique) ~= length(irf_shocks_indx)) if options_.debug && (length(irf_shocks_indx_unique) ~= length(irf_shocks_indx))

View File

@ -13,7 +13,7 @@ function discount_factor=get_optimal_policy_discount_factor(params,param_names)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2007-2017 Dynare Team % Copyright (C) 2007-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -30,4 +30,4 @@ function discount_factor=get_optimal_policy_discount_factor(params,param_names)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
discount_factor = params(find(strcmp('optimal_policy_discount_factor',cellstr(param_names)))); discount_factor = params(find(strcmp('optimal_policy_discount_factor', param_names)));

View File

@ -15,7 +15,7 @@ function xparam = get_posterior_parameters(type,M_,estim_params_,oo_,options_,fi
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% None. % None.
% Copyright (C) 2006-2017 Dynare Team % Copyright (C) 2006-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -46,7 +46,7 @@ xparam = zeros(nvx+nvn+ncx+ncn+np,1);
m = 1; m = 1;
for i=1:nvx for i=1:nvx
k1 = estim_params_.var_exo(i,1); k1 = estim_params_.var_exo(i,1);
name1 = deblank(M_.exo_names(k1,:)); name1 = M_.exo_names{k1};
xparam(m) = oo_.([field1 type]).shocks_std.(name1); xparam(m) = oo_.([field1 type]).shocks_std.(name1);
m = m+1; m = m+1;
end end
@ -61,8 +61,8 @@ end
for i=1:ncx for i=1:ncx
k1 = estim_params_.corrx(i,1); k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2); k2 = estim_params_.corrx(i,2);
name1 = deblank(M_.exo_names(k1,:)); name1 = M_.exo_names{k1};
name2 = deblank(M_.exo_names(k2,:)); name2 = M_.exo_names{k2};
xparam(m) = oo_.([field1 type]).shocks_corr.([name1 '_' name2]); xparam(m) = oo_.([field1 type]).shocks_corr.([name1 '_' name2]);
m = m+1; m = m+1;
end end
@ -79,7 +79,7 @@ end
FirstDeep = m; FirstDeep = m;
for i=1:np for i=1:np
name1 = deblank(M_.param_names(estim_params_.param_vals(i,1),:)); name1 = M_.param_names{estim_params_.param_vals(i,1)};
xparam(m) = oo_.([field1 type]).parameters.(name1); xparam(m) = oo_.([field1 type]).parameters.(name1);
m = m+1; m = m+1;
end end

View File

@ -1,4 +1,4 @@
function [nam,texnam] = get_the_name(k,TeX,M_,estim_params_,options_) function [nam, texnam] = get_the_name(k, TeX, M_, estim_params_, options_)
%@info: %@info:
%! @deftypefn {Function File} {[@var{nam},@var{texnam}] =} get_the_name (@var{k},@var{TeX},@var{M_},@var{estim_params_},@var{options_}) %! @deftypefn {Function File} {[@var{nam},@var{texnam}] =} get_the_name (@var{k},@var{TeX},@var{M_},@var{estim_params_},@var{options_})
@ -40,7 +40,7 @@ function [nam,texnam] = get_the_name(k,TeX,M_,estim_params_,options_)
%! @end deftypefn %! @end deftypefn
%@eod: %@eod:
% Copyright (C) 2004-2013 Dynare Team % Copyright (C) 2004-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -66,44 +66,44 @@ ncx = estim_params_.ncx;
ncn = estim_params_.ncn; ncn = estim_params_.ncn;
if k <= nvx if k <= nvx
vname = deblank(M_.exo_names(estim_params_.var_exo(k,1),:)); vname = M_.exo_names{estim_params_.var_exo(k,1)};
nam = ['SE_',vname]; nam = sprintf('SE_%s', vname);
if TeX if TeX
tname = deblank(M_.exo_names_tex(estim_params_.var_exo(k,1),:)); tname = M_.exo_names_tex{estim_params_.var_exo(k,1)};
texnam = ['$ SE_{' tname '} $']; texnam = sprintf('$ SE_{%s} $', tname);
end end
elseif k <= (nvx+nvn) elseif k <= (nvx+nvn)
vname = options_.varobs{estim_params_.nvn_observable_correspondence(k-estim_params_.nvx,1)}; vname = options_.varobs{estim_params_.nvn_observable_correspondence(k-estim_params_.nvx,1)};
nam=['SE_EOBS_',vname]; nam = sprintf('SE_EOBS_%s', vname);
if TeX if TeX
tname = deblank(M_.endo_names_tex(estim_params_.var_endo(k-estim_params_.nvx,1),:)); tname = M_.endo_names_tex{estim_params_.var_endo(k-estim_params_.nvx,1)};
texnam = ['$ EOBS SE_{' tname '} $']; texnam = sprintf('$ EOBS SE_{%s} $', tname);
end end
elseif k <= (nvx+nvn+ncx) elseif k <= (nvx+nvn+ncx)
jj = k - (nvx+nvn); jj = k - (nvx+nvn);
k1 = estim_params_.corrx(jj,1); k1 = estim_params_.corrx(jj,1);
k2 = estim_params_.corrx(jj,2); k2 = estim_params_.corrx(jj,2);
vname = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))]; vname = sprintf('%s_%s', M_.exo_names{k1}, M_.exo_names{k2});
nam=['CC_',vname]; nam = sprintf('CC_%s', vname);
if TeX if TeX
tname = [deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:))]; tname = sprintf('%s,%s', M_.exo_names_tex{k1}, M_.exo_names_tex{k2});
texnam = ['$ CC_{' tname '} $']; texnam = sprintf('$ CC_{%s} $', tname);
end end
elseif k <= (nvx+nvn+ncx+ncn) elseif k <= (nvx+nvn+ncx+ncn)
jj = k - (nvx+nvn+ncx); jj = k - (nvx+nvn+ncx);
k1 = estim_params_.corrn(jj,1); k1 = estim_params_.corrn(jj,1);
k2 = estim_params_.corrn(jj,2); k2 = estim_params_.corrn(jj,2);
vname = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))]; vname = sprintf('%s_%s', M_.endo_names{k1}, M_.endo_names{k2});
nam=['CC_EOBS_' vname]; nam = sprintf('CC_EOBS_%s', vname);
if TeX if TeX
tname = [deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:))]; tname = sprintf('%s,%s', M_.endo_names_tex{k1}, M_.endo_names_tex{k2});
texnam =['$ EOBS CC_{' tname '} $']; texnam = sprintf('$ EOBS CC_{%s} $', tname);
end end
else else
jj = k - (nvx+nvn+ncx+ncn); jj = k - (nvx+nvn+ncx+ncn);
jj1 = estim_params_.param_vals(jj,1); jj1 = estim_params_.param_vals(jj,1);
nam = deblank(M_.param_names(jj1,:)); nam = M_.param_names{jj1};
if TeX if TeX
texnam = ['$ ' deblank(M_.param_names_tex(jj1,:)) ' $']; texnam = sprintf('$ %s $', M_.param_names_tex{jj1});
end end
end end

View File

@ -1,14 +1,16 @@
function [ivar,vartan,options_] = get_variables_list(options_,M_) function [ivar, vartan, options_] = get_variables_list(options_, M_)
% This function builds a vector of indices in varlist or varobs. % This function builds a vector of indices in varlist or varobs.
% %
% INPUTS % INPUTS
% o options_ [structure] Describes global options. % o options_ [structure] Describes global options.
% o M_ [structure] Describes the model. % o M_ [structure] Describes the model.
%
% OUTPUTS % OUTPUTS
% o ivar [integer] nvar*1 vector of indices (nvar is the number % o ivar [integer] nvar*1 vector of indices (nvar is the number
% of variables). % of variables).
% o vartan [char] array of characters (with nvar rows). % o vartan [cell of char arrays] array of characters (with nvar rows).
% o options_ [structure] Describes global options. % o options_ [structure] Describes global options.
% %
% ALGORITHM % ALGORITHM
% None. % None.
@ -16,7 +18,7 @@ function [ivar,vartan,options_] = get_variables_list(options_,M_)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% None. % None.
% Copyright (C) 2007-2017 Dynare Team % Copyright (C) 2007-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -35,13 +37,12 @@ function [ivar,vartan,options_] = get_variables_list(options_,M_)
varlist = options_.varlist; varlist = options_.varlist;
if isempty(varlist) if isempty(varlist)
varlist = char(options_.varobs); varlist = options_.varobs;
options_.varlist = varlist; options_.varlist = varlist;
end end
nvar = rows(varlist); nvar = length(varlist);
vartan = varlist; vartan = varlist;
nvar = size(vartan,1);
ivar = zeros(nvar,1); ivar = zeros(nvar,1);
for i = 1:nvar for i = 1:nvar
ivar(i) = strmatch(deblank(vartan(i,:)),M_.endo_names,'exact'); ivar(i) = strmatch(vartan{i}, M_.endo_names, 'exact');
end end

View File

@ -11,7 +11,7 @@ function global_initialization()
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -678,7 +678,7 @@ options_.particleswarm = particleswarm;
% prior analysis % prior analysis
options_.prior_mc = 20000; options_.prior_mc = 20000;
options_.prior_analysis_endo_var_list = []; options_.prior_analysis_endo_var_list = {};
% did model undergo block decomposition + minimum feedback set computation ? % did model undergo block decomposition + minimum feedback set computation ?
options_.block = 0; options_.block = 0;

View File

@ -11,7 +11,7 @@ function []=graph_decomp(z,shock_names,endo_names,i_var,initial_date,DynareModel
% DynareModel [structure] Dynare model structure % DynareModel [structure] Dynare model structure
% DynareOptions [structure] Dynare options structure % DynareOptions [structure] Dynare options structure
% Copyright (C) 2010-2017 Dynare Team % Copyright (C) 2010-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -109,7 +109,7 @@ for j=1:nvar
z1 = squeeze(z(i_var(j),:,:)); z1 = squeeze(z(i_var(j),:,:));
if screen_shocks if screen_shocks
[junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend'); [junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
labels = char(char(shock_names(isort(1:16),:)),'Others', 'Initial values'); labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
zres = sum(z1(isort(17:end),:),1); zres = sum(z1(isort(17:end),:),1);
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)]; z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
comp_nbr=18; comp_nbr=18;
@ -128,7 +128,7 @@ for j=1:nvar
if ymax-ymin < 1e-6 if ymax-ymin < 1e-6
continue continue
end end
fhandle = dyn_figure(DynareOptions.plot_shock_decomp.nodisplay,'Name',[preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': ' deblank(endo_names(i_var(j),:)) '.'], 'PaperPositionMode', 'auto','PaperOrientation','landscape','renderermode','auto'); fhandle = dyn_figure(DynareOptions.plot_shock_decomp.nodisplay,'Name',[preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': ' endo_names{i_var(j)} '.'], 'PaperPositionMode', 'auto','PaperOrientation','landscape','renderermode','auto');
set(fhandle,'position' ,[50 50 1500 750]) set(fhandle,'position' ,[50 50 1500 750])
ax=axes('Position',[0.1 0.1 0.6 0.8],'box','on'); ax=axes('Position',[0.1 0.1 0.6 0.8],'box','on');
% plot(ax,x(2:end),z1(end,:),'k-','LineWidth',2) % plot(ax,x(2:end),z1(end,:),'k-','LineWidth',2)
@ -213,13 +213,13 @@ for j=1:nvar
colormap(new_colormap) colormap(new_colormap)
end end
hold off hold off
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname,'_shock_decomposition_',deblank(endo_names(i_var(j),:)),fig_mode1,fig_name],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format); dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname,'_shock_decomposition_',endo_names{i_var(j)},fig_mode1,fig_name],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format))) if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n'); fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n'); fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[deblank(endo_names(i_var(j),:)) fig_mode1 fig_name]); fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[endo_names{i_var(j)} fig_mode1 fig_name]);
fprintf(fidTeX,'\\label{Fig:shock_decomp:%s}\n',[fig_mode deblank(endo_names(i_var(j),:)) fig_name]); fprintf(fidTeX,'\\label{Fig:shock_decomp:%s}\n',[fig_mode endo_names{i_var(j)} fig_name]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $.}\n'],deblank(DynareModel.endo_names_tex(i_var(j),:))); fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $.}\n'],DynareModel.endo_names_tex{i_var(j)});
fprintf(fidTeX,'\\end{figure}\n'); fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
end end

View File

@ -11,7 +11,7 @@ function []=graph_decomp_detail(z,shock_names,endo_names,i_var,initial_date,Dyna
% DynareModel [structure] Dynare model structure % DynareModel [structure] Dynare model structure
% DynareOptions [structure] Dynare options structure % DynareOptions [structure] Dynare options structure
% Copyright (C) 2010-2017 Dynare Team % Copyright (C) 2010-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -133,7 +133,7 @@ for j=1:nvar
z1 = squeeze(z(i_var(j),:,:)); z1 = squeeze(z(i_var(j),:,:));
if screen_shocks, if screen_shocks,
[junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend'); [junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
labels = char(char(shock_names(isort(1:16),:)),'Others', 'Initial values'); labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
zres = sum(z1(isort(17:end),:),1); zres = sum(z1(isort(17:end),:),1);
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)]; z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
comp_nbr=18; comp_nbr=18;
@ -151,7 +151,7 @@ for j=1:nvar
continue continue
end end
for jf = 1:nfigs for jf = 1:nfigs
fhandle = dyn_figure(DynareOptions.plot_shock_decomp.nodisplay,'Name',[preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': ' deblank(endo_names(i_var(j),:)) ' (detail).'],'position',[200 100 650 850], 'PaperPositionMode', 'auto','PaperOrientation','portrait','renderermode','auto'); fhandle = dyn_figure(DynareOptions.plot_shock_decomp.nodisplay,'Name',[preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': ' endo_names{i_var(j)} ' (detail).'],'position',[200 100 650 850], 'PaperPositionMode', 'auto','PaperOrientation','portrait','renderermode','auto');
a0=zeros(1,4); a0=zeros(1,4);
a0(3)=inf; a0(3)=inf;
a0(4)=-inf; a0(4)=-inf;
@ -183,7 +183,7 @@ for j=1:nvar
mydata.use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups; mydata.use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups;
mydata.shock_group = shock_groups.(shock_ind{ic}); mydata.shock_group = shock_groups.(shock_ind{ic});
mydata.shock_decomp = DynareOptions.plot_shock_decomp; mydata.shock_decomp = DynareOptions.plot_shock_decomp;
if ~isempty(mydata.shock_group.shocks{1}) if ~isempty(mydata.shock_group.shocks)
c = uicontextmenu; c = uicontextmenu;
hax.UIContextMenu=c; hax.UIContextMenu=c;
browse_menu = uimenu(c,'Label','Browse group'); browse_menu = uimenu(c,'Label','Browse group');
@ -224,13 +224,14 @@ for j=1:nvar
else else
suffix = ['_detail']; suffix = ['_detail'];
end end
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname,'_shock_decomposition_',deblank(endo_names(i_var(j),:)),fig_mode1,fig_name suffix],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format); dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname, ...
'_shock_decomposition_', endo_names{i_var(j)}, fig_mode1,fig_name suffix],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format))) if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n'); fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n'); fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[deblank(endo_names(i_var(j),:)) fig_mode1 fig_name suffix]); fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[endo_names{i_var(j)} fig_mode1 fig_name suffix]);
fprintf(fidTeX,'\\label{Fig:shock_decomp_detail:%s}\n',[fig_mode deblank(endo_names(i_var(j),:)) fig_name suffix]); fprintf(fidTeX,'\\label{Fig:shock_decomp_detail:%s}\n',[fig_mode endo_names{i_var(j)} fig_name suffix]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $ (detail).}\n'],deblank(DynareModel.endo_names_tex(i_var(j),:))); fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $ (detail).}\n'], DynareModel.endo_names_tex{i_var(j)});
fprintf(fidTeX,'\\end{figure}\n'); fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
end end

View File

@ -14,7 +14,7 @@ function [rmse_MC, ixx] = filt_mc_(OutDir,options_gsa_,dataset_,dataset_info)
% marco.ratto@ec.europa.eu % marco.ratto@ec.europa.eu
% Copyright (C) 2012-2016 European Commission % Copyright (C) 2012-2016 European Commission
% Copyright (C) 2012-2017 Dynare Team % Copyright (C) 2012-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -38,12 +38,11 @@ vvarvecm = options_gsa_.var_rmse;
if options_.TeX if options_.TeX
vvarvecm_tex = options_gsa_.var_rmse_tex; vvarvecm_tex = options_gsa_.var_rmse_tex;
else else
vvarvecm_tex = []; vvarvecm_tex = {};
end end
loadSA = options_gsa_.load_rmse; loadSA = options_gsa_.load_rmse;
pfilt = options_gsa_.pfilt_rmse; pfilt = options_gsa_.pfilt_rmse;
alpha = options_gsa_.alpha_rmse; alpha = options_gsa_.alpha_rmse;
% alpha2 = options_gsa_.alpha2_rmse;
alpha2 = 0; alpha2 = 0;
pvalue = options_gsa_.alpha2_rmse; pvalue = options_gsa_.alpha2_rmse;
istart = max(2,options_gsa_.istart_rmse); istart = max(2,options_gsa_.istart_rmse);
@ -133,7 +132,6 @@ if ~loadSA
M_ = set_all_parameters(xparam1_mean,estim_params_,M_); M_ = set_all_parameters(xparam1_mean,estim_params_,M_);
ys_mean=steady_(M_,options_,oo_); ys_mean=steady_(M_,options_,oo_);
end end
% eval(options_.datafile)
Y = transpose(dataset_.data); Y = transpose(dataset_.data);
gend = dataset_.nobs; gend = dataset_.nobs;
data_index = dataset_info.missing.aindex; data_index = dataset_info.missing.aindex;
@ -141,8 +139,6 @@ if ~loadSA
for jx=1:gend for jx=1:gend
data_indx(jx,data_index{jx})=true; data_indx(jx,data_index{jx})=true;
end end
%stock_gend=data_info.gend;
%stock_data = data_info.data;
load([DirectoryName filesep M_.fname '_data.mat']); load([DirectoryName filesep M_.fname '_data.mat']);
filfilt = dir([DirectoryName filesep M_.fname '_filter_step_ahead*.mat']); filfilt = dir([DirectoryName filesep M_.fname '_filter_step_ahead*.mat']);
temp_smooth_file_list = dir([DirectoryName filesep M_.fname '_smooth*.mat']); temp_smooth_file_list = dir([DirectoryName filesep M_.fname '_smooth*.mat']);
@ -159,7 +155,6 @@ if ~loadSA
logpo2=[]; logpo2=[];
sto_ys=[]; sto_ys=[];
for j=1:length(filparam) for j=1:length(filparam)
%load([DirectoryName filesep M_.fname '_param',int2str(j),'.mat']);
if isempty(strmatch([M_.fname '_param_irf'],filparam(j).name)) if isempty(strmatch([M_.fname '_param_irf'],filparam(j).name))
load([DirectoryName filesep filparam(j).name]); load([DirectoryName filesep filparam(j).name]);
x=[x; stock]; x=[x; stock];
@ -173,11 +168,10 @@ if ~loadSA
if options_.opt_gsa.ppost || (options_.opt_gsa.ppost==0 && options_.opt_gsa.lik_only==0) if options_.opt_gsa.ppost || (options_.opt_gsa.ppost==0 && options_.opt_gsa.lik_only==0)
skipline() skipline()
disp('Computing RMSE''s...') disp('Computing RMSE''s...')
for i=1:size(vvarvecm,1) for i = 1:length(vvarvecm)
vj=deblank(vvarvecm(i,:)); vj = vvarvecm{i};
jxj(i) = strmatch(vj, lgy_(dr_.order_var), 'exact');
jxj(i) = strmatch(vj,lgy_(dr_.order_var,:),'exact'); js(i) = strmatch(vj, lgy_, 'exact');
js(i) = strmatch(vj,lgy_,'exact');
yss(i,:,:)=repmat(sto_ys(:,js(i))',[gend,1]); yss(i,:,:)=repmat(sto_ys(:,js(i))',[gend,1]);
end end
if exist('xparam1','var') if exist('xparam1','var')
@ -213,7 +207,6 @@ if ~loadSA
r2_MC(j,:) = 1-mean((yobs(:,istart:end,j)'-y0(:,istart:end,j)').^2)./mean((yobs(:,istart:end,j)').^2); r2_MC(j,:) = 1-mean((yobs(:,istart:end,j)'-y0(:,istart:end,j)').^2)./mean((yobs(:,istart:end,j)').^2);
end end
if exist('xparam1_mean','var') if exist('xparam1_mean','var')
%eval(['rmse_pmean(i) = sqrt(mean((',vj,'(fobs-1+istart:fobs-1+nobs)-y0M(istart:end-1)).^2));'])
[alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1_mean,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_); [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1_mean,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
y0 = reshape( squeeze(aK(1,jxj,1:gend)),[gend length(jxj)]);% + kron(ys_mean(js),ones(1,gend))); y0 = reshape( squeeze(aK(1,jxj,1:gend)),[gend length(jxj)]);% + kron(ys_mean(js),ones(1,gend)));
yobs = transpose( ahat(jxj,:));% + kron(ys_mean(js),ones(1,gend))); yobs = transpose( ahat(jxj,:));% + kron(ys_mean(js),ones(1,gend)));
@ -260,14 +253,14 @@ else
nfilt=floor(pfilt*nruns); nfilt=floor(pfilt*nruns);
end end
% smirnov tests % smirnov tests
nfilt0=nfilt*ones(size(vvarvecm,1),1); nfilt0 = nfilt*ones(length(vvarvecm), 1);
logpo2=logpo2(:); logpo2=logpo2(:);
if ~options_.opt_gsa.ppost if ~options_.opt_gsa.ppost
[dum, ipost]=sort(-logpo2); [dum, ipost]=sort(-logpo2);
[dum, ilik]=sort(-likelihood); [dum, ilik]=sort(-likelihood);
end end
%% visual scatter analysis! % visual scatter analysis!
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
tmp_title='R2 Posterior:'; tmp_title='R2 Posterior:';
atitle='R2 Posterior:'; atitle='R2 Posterior:';
@ -291,8 +284,7 @@ options_scatter.amcf_name = asname;
options_scatter.amcf_title = atitle; options_scatter.amcf_title = atitle;
options_scatter.title = tmp_title; options_scatter.title = tmp_title;
scatter_analysis(r2_MC, x,options_scatter, options_); scatter_analysis(r2_MC, x,options_scatter, options_);
%% end of visual scatter analysis % end of visual scatter analysis
if ~options_.opt_gsa.ppost && options_.opt_gsa.lik_only if ~options_.opt_gsa.ppost && options_.opt_gsa.lik_only
if options_.opt_gsa.pprior if options_.opt_gsa.pprior
@ -307,12 +299,12 @@ if ~options_.opt_gsa.ppost && options_.opt_gsa.lik_only
options_mcf.alpha2 = alpha2; options_mcf.alpha2 = alpha2;
if options_.TeX if options_.TeX
[pnames,pnames_tex]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_); [pnames,pnames_tex]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_);
options_mcf.param_names = char(pnames); options_mcf.param_names = pnames;
options_mcf.param_names_tex = char(pnames_tex); options_mcf.param_names_tex = pnames_tex;
else else
[pnames]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_); [pnames]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_);
options_mcf.param_names = char(pnames); options_mcf.param_names = pnames;
options_mcf.param_names_tex = []; options_mcf.param_names_tex = {};
end end
options_mcf.fname_ = fname_; options_mcf.fname_ = fname_;
options_mcf.OutputDirectoryName = OutDir; options_mcf.OutputDirectoryName = OutDir;
@ -322,7 +314,6 @@ if ~options_.opt_gsa.ppost && options_.opt_gsa.lik_only
options_mcf.beha_title = 'better posterior kernel'; options_mcf.beha_title = 'better posterior kernel';
options_mcf.nobeha_title = 'worse posterior kernel'; options_mcf.nobeha_title = 'worse posterior kernel';
mcf_analysis(x, ipost(1:nfilt), ipost(nfilt+1:end), options_mcf, options_); mcf_analysis(x, ipost(1:nfilt), ipost(nfilt+1:end), options_mcf, options_);
if options_.opt_gsa.pprior if options_.opt_gsa.pprior
anam = 'rmse_prior_lik'; anam = 'rmse_prior_lik';
atitle = 'RMSE prior: Log Likelihood Kernel'; atitle = 'RMSE prior: Log Likelihood Kernel';
@ -351,22 +342,21 @@ else
r2_txt=NaN(1,size(r2_MC,2)); r2_txt=NaN(1,size(r2_MC,2));
end end
else else
%nfilt0(i)=length(find(rmse_MC(:,i)<rmse_pmean(i)));
rmse_txt=rmse_pmean; rmse_txt=rmse_pmean;
r2_txt=r2_pmean; r2_txt=r2_pmean;
end end
end end
for i=1:size(vvarvecm,1) for i = 1:length(vvarvecm)
[dum, ixx(:,i)]=sort(rmse_MC(:,i)); [dum, ixx(:,i)] = sort(rmse_MC(:,i));
end end
PP=ones(npar+nshock,size(vvarvecm,1)); PP = ones(npar+nshock, length(vvarvecm));
PPV=ones(size(vvarvecm,1),size(vvarvecm,1),npar+nshock); PPV = ones(length(vvarvecm), length(vvarvecm), npar+nshock);
SS=zeros(npar+nshock,size(vvarvecm,1)); SS = zeros(npar+nshock, length(vvarvecm));
for j=1:npar+nshock for j = 1:npar+nshock
for i=1:size(vvarvecm,1) for i = 1:length(vvarvecm)
[H,P,KSSTAT] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j), alpha); [H, P, KSSTAT] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j), alpha);
[H1,P1,KSSTAT1] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j),alpha,1); [H1, P1, KSSTAT1] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j),alpha,1);
[H2,P2,KSSTAT2] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j),alpha,-1); [H2, P2, KSSTAT2] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j),alpha,-1);
if H1 & H2==0 if H1 & H2==0
SS(j,i)=1; SS(j,i)=1;
elseif H1==0 elseif H1==0
@ -376,17 +366,11 @@ else
end end
PP(j,i)=P; PP(j,i)=P;
end end
for i=1:size(vvarvecm,1) for i = 1:length(vvarvecm)
for l=1:size(vvarvecm,1) for l = 1:length(vvarvecm)
if l~=i && PP(j,i)<alpha && PP(j,l)<alpha if l~=i && PP(j,i)<alpha && PP(j,l)<alpha
[H,P,KSSTAT] = smirnov(x(ixx(1:nfilt0(i),i),j),x(ixx(1:nfilt0(l),l),j), alpha); [H,P,KSSTAT] = smirnov(x(ixx(1:nfilt0(i),i),j),x(ixx(1:nfilt0(l),l),j), alpha);
%[H1,P1,KSSTAT1] = smirnov(x(ixx(1:nfilt0(i),i),j),x(:,j), alpha);
% PP(j,i)=min(P,PP(j,i));
% PP(j,l)=min(P,PP(j,l));
%if P<P1
% if SS(j,i)*SS(j,l)
PPV(i,l,j) = P; PPV(i,l,j) = P;
% end
elseif l==i elseif l==i
PPV(i,l,j) = PP(j,i); PPV(i,l,j) = PP(j,i);
end end
@ -395,7 +379,7 @@ else
end end
if ~options_.nograph if ~options_.nograph
ifig=0; ifig=0;
for i=1:size(vvarvecm,1) for i=1:length(vvarvecm)
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
temp_name='RMSE Posterior: Log Prior'; temp_name='RMSE Posterior: Log Prior';
else else
@ -416,8 +400,8 @@ else
set(h,'color','k','linewidth',1) set(h,'color','k','linewidth',1)
h=cumplot(lnprior(ixx(nfilt0(i)+1:end,i))); h=cumplot(lnprior(ixx(nfilt0(i)+1:end,i)));
set(h,'color','red','linewidth',2) set(h,'color','red','linewidth',2)
title(vvarvecm(i,:),'interpreter','none') title(vvarvecm{i},'interpreter','none')
if mod(i,9)==0 || i==size(vvarvecm,1) if mod(i,9)==0 || i==length(vvarvecm)
if ~isoctave if ~isoctave
annotation('textbox', [0.1,0,0.35,0.05],'String', 'Log-prior for BETTER R2','Color','Blue','horizontalalignment','center'); annotation('textbox', [0.1,0,0.35,0.05],'String', 'Log-prior for BETTER R2','Color','Blue','horizontalalignment','center');
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-prior for WORSE R2', 'Color','Red','horizontalalignment','center'); annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-prior for WORSE R2', 'Color','Red','horizontalalignment','center');
@ -443,7 +427,7 @@ else
end end
end end
ifig=0; ifig=0;
for i=1:size(vvarvecm,1) for i=1:length(vvarvecm)
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
temp_name='RMSE Posterior: Log Likelihood'; temp_name='RMSE Posterior: Log Likelihood';
else else
@ -464,11 +448,11 @@ else
set(h,'color','k','linewidth',1) set(h,'color','k','linewidth',1)
h=cumplot(likelihood(ixx(nfilt0(i)+1:end,i))); h=cumplot(likelihood(ixx(nfilt0(i)+1:end,i)));
set(h,'color','red','linewidth',2) set(h,'color','red','linewidth',2)
title(vvarvecm(i,:),'interpreter','none') title(vvarvecm{i},'interpreter','none')
if options_.opt_gsa.ppost==0 if options_.opt_gsa.ppost==0
set(gca,'xlim',[min( likelihood(ixx(1:nfilt0(i),i)) ) max( likelihood(ixx(1:nfilt0(i),i)) )]) set(gca,'xlim',[min( likelihood(ixx(1:nfilt0(i),i)) ) max( likelihood(ixx(1:nfilt0(i),i)) )])
end end
if mod(i,9)==0 || i==size(vvarvecm,1) if mod(i,9)==0 || i==length(vvarvecm)
if ~isoctave if ~isoctave
annotation('textbox', [0.1,0,0.35,0.05],'String', 'Log-likelihood for BETTER R2','Color','Blue','horizontalalignment','center'); annotation('textbox', [0.1,0,0.35,0.05],'String', 'Log-likelihood for BETTER R2','Color','Blue','horizontalalignment','center');
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-likelihood for WORSE R2', 'Color','Red','horizontalalignment','center'); annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-likelihood for WORSE R2', 'Color','Red','horizontalalignment','center');
@ -494,7 +478,7 @@ else
end end
end end
ifig=0; ifig=0;
for i=1:size(vvarvecm,1) for i=1:length(vvarvecm)
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
temp_name='RMSE Posterior: Log Posterior'; temp_name='RMSE Posterior: Log Posterior';
else else
@ -515,11 +499,11 @@ else
set(h,'color','k','linewidth',1) set(h,'color','k','linewidth',1)
h=cumplot(logpo2(ixx(nfilt0(i)+1:end,i))); h=cumplot(logpo2(ixx(nfilt0(i)+1:end,i)));
set(h,'color','red','linewidth',2) set(h,'color','red','linewidth',2)
title(vvarvecm(i,:),'interpreter','none') title(vvarvecm{i},'interpreter','none')
if options_.opt_gsa.ppost==0 if options_.opt_gsa.ppost==0
set(gca,'xlim',[min( logpo2(ixx(1:nfilt0(i),i)) ) max( logpo2(ixx(1:nfilt0(i),i)) )]) set(gca,'xlim',[min( logpo2(ixx(1:nfilt0(i),i)) ) max( logpo2(ixx(1:nfilt0(i),i)) )])
end end
if mod(i,9)==0 || i==size(vvarvecm,1) if mod(i,9)==0 || i==length(vvarvecm)
if ~isoctave if ~isoctave
annotation('textbox', [0.1,0,0.35,0.05],'String', 'Log-posterior for BETTER R2','Color','Blue','horizontalalignment','center'); annotation('textbox', [0.1,0,0.35,0.05],'String', 'Log-posterior for BETTER R2','Color','Blue','horizontalalignment','center');
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-posterior for WORSE R2', 'Color','Red','horizontalalignment','center'); annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-posterior for WORSE R2', 'Color','Red','horizontalalignment','center');
@ -545,64 +529,50 @@ else
end end
end end
end end
if options_.TeX if options_.TeX
[pnames,pnames_tex]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_); [pnames,pnames_tex]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_);
param_names = char(pnames); param_names = pnames;
param_names_tex = char(pnames_tex); param_names_tex = pnames_tex;
else else
[pnames]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_); [pnames]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_);
param_names = char(pnames); param_names = pnames;
param_names_tex = []; param_names_tex = {};
end end
skipline() skipline()
title_string='RMSE over the MC sample:'; title_string='RMSE over the MC sample:';
data_mat=[min(rmse_MC)' max(rmse_MC)']; data_mat=[min(rmse_MC)' max(rmse_MC)'];
headers=strvcat('Variable','min yr RMSE','max yr RMSE'); headers={'Variable'; 'min yr RMSE'; 'max yr RMSE'};
dyntable(options_,title_string,headers,vvarvecm,data_mat, 0, 15, 5); dyntable(options_, title_string, headers, vvarvecm, data_mat, 0, 15, 5);
if options_.TeX if options_.TeX
headers_tex=strvcat('\text{Variable}','\text{min yr RMSE}','\text{max yr RMSE}'); headers_tex = {'\text{Variable}'; '\text{min yr RMSE}'; '\text{max yr RMSE}'};
dyn_latex_table(M_,options_,title_string,'RMSE_MC',headers_tex,vvarvecm_tex,data_mat,0,15,5); dyn_latex_table(M_, options_, title_string, 'RMSE_MC', headers_tex, vvarvecm_tex, data_mat, 0, 15, 5);
end end
invar = find( std(rmse_MC)./mean(rmse_MC)<=0.0001 ); invar = find( std(rmse_MC)./mean(rmse_MC)<=0.0001 );
if ~isempty(invar) if ~isempty(invar)
skipline(2) skipline(2)
disp('RMSE is not varying significantly over the MC sample for the following variables:') disp('RMSE is not varying significantly over the MC sample for the following variables:')
disp(vvarvecm(invar,:)) disp(vvarvecm{invar})
disp('These variables are excluded from SA') disp('These variables are excluded from SA')
disp('[Unless you treat these series as exogenous, there is something wrong in your estimation !]') disp('[Unless you treat these series as exogenous, there is something wrong in your estimation !]')
end end
vvarvecm0=vvarvecm; vvarvecm0=vvarvecm;
ivar = find( std(rmse_MC)./mean(rmse_MC)>0.0001 ); ivar = find( std(rmse_MC)./mean(rmse_MC)>0.0001 );
vvarvecm=vvarvecm(ivar,:); vvarvecm = vvarvecm(ivar);
rmse_MC=rmse_MC(:,ivar); rmse_MC = rmse_MC(:,ivar);
skipline() skipline()
% if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior,
disp(['Sample filtered the ',num2str(pfilt*100),'% best RMSE''s for each observed series ...' ]) disp(['Sample filtered the ',num2str(pfilt*100),'% best RMSE''s for each observed series ...' ])
% else
% disp(['Sample filtered the best RMSE''s smaller than RMSE at the posterior mean ...' ])
% end
% figure, boxplot(rmse_MC)
% set(gca,'xticklabel',vvarvecm)
% saveas(gcf,[fname_,'_SA_RMSE'])
skipline(2) skipline(2)
disp('RMSE ranges after filtering:') disp('RMSE ranges after filtering:')
title_string='RMSE ranges after filtering:'; title_string='RMSE ranges after filtering:';
if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
headers=strvcat('Variable','min','max','min','max','posterior mode'); headers = {'Variable'; 'min'; 'max'; 'min'; 'max'; 'posterior mode'};
headers_tex=strvcat('\text{Variable}','\text{min}','\text{max}','\text{min}','\text{max}','\text{posterior mode}'); headers_tex = {'\text{Variable}'; '\text{min}'; '\text{max}'; '\text{min}'; '\text{max}'; '\text{posterior mode}'};
else else
headers=strvcat('Variable','min','max','min','max','posterior mean'); headers = {'Variable'; 'min'; 'max'; 'min'; 'max'; 'posterior mean'};
headers_tex=strvcat('\text{Variable}','\text{min}','\text{max}','\text{min}','\text{max}','\text{posterior mean}'); headers_tex = {'\text{Variable}'; '\text{min}'; '\text{max}'; '\text{min}'; '\text{max}'; '\text{posterior mean}'};
end end
data_mat=NaN(size(vvarvecm,1),5); data_mat=NaN(length(vvarvecm),5);
for j=1:size(vvarvecm,1) for j = 1:length(vvarvecm)
data_mat(j,:)=[min(rmse_MC(ixx(1:nfilt0(j),j),j)) ... data_mat(j,:)=[min(rmse_MC(ixx(1:nfilt0(j),j),j)) ...
max(rmse_MC(ixx(1:nfilt0(j),j),j)) ... max(rmse_MC(ixx(1:nfilt0(j),j),j)) ...
min(rmse_MC(ixx(nfilt0(j)+1:end,j),j)) ... min(rmse_MC(ixx(nfilt0(j)+1:end,j),j)) ...
@ -610,10 +580,10 @@ else
rmse_txt(j)]; rmse_txt(j)];
end end
%get formatting for additional header line %get formatting for additional header line
val_width=15; val_width = 15;
val_precis=5; val_precis = 5;
label_width = max(size(deblank(char(headers(1,:),vvarvecm)),2)+2,0); label_width = max(cellofchararraymaxlength(vertcat(headers{1}, vvarvecm))+2, 0);
label_format_leftbound = sprintf('%%-%ds',label_width); label_format_leftbound = sprintf('%%-%ds', label_width);
if all(~isfinite(data_mat)) if all(~isfinite(data_mat))
values_length = 4; values_length = 4;
else else
@ -622,61 +592,55 @@ else
if any(data_mat) < 0 %add one character for minus sign if any(data_mat) < 0 %add one character for minus sign
values_length = values_length+1; values_length = values_length+1;
end end
headers_length = cellofchararraymaxlength(headers(2:end));
headers_length = max(size(deblank(headers(2:end,:)),2));
if ~isempty(val_width) if ~isempty(val_width)
val_width = max(max(headers_length,values_length)+2,val_width); val_width = max(max(headers_length,values_length)+2, val_width);
else else
val_width = max(headers_length,values_length)+2; val_width = max(headers_length, values_length)+2;
end end
value_format = sprintf('%%%d.%df',val_width,val_precis); value_format = sprintf('%%%d.%df',val_width,val_precis);
header_string_format = sprintf('%%%ds',val_width); header_string_format = sprintf('%%%ds',val_width);
if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
optional_header=sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','',['best ',num2str(pfilt*100),'% filtered'],'','remaining 90%'); optional_header=sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','',['best ',num2str(pfilt*100),'% filtered'],'','remaining 90%');
else else
optional_header=sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','','best filtered','','remaining'); optional_header=sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','','best filtered','','remaining');
end end
dyntable(options_,title_string,headers,vvarvecm,data_mat, 0, val_width, val_precis,optional_header); dyntable(options_, title_string, headers, vvarvecm, data_mat, 0, val_width, val_precis,optional_header);
if options_.TeX if options_.TeX
if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
optional_header={[' & \multicolumn{2}{c}{best ',num2str(pfilt*100),' filtered} & \multicolumn{2}{c}{remaining 90\%}\\']}; optional_header={[' & \multicolumn{2}{c}{best ',num2str(pfilt*100),' filtered} & \multicolumn{2}{c}{remaining 90\%}\\']};
else else
optional_header={[' & \multicolumn{2}{c}{best filtered} & \multicolumn{2}{c}{remaining}\\']}; optional_header={[' & \multicolumn{2}{c}{best filtered} & \multicolumn{2}{c}{remaining}\\']};
end end
dyn_latex_table(M_,options_,title_string,'RMSE_ranges_after_filtering',headers_tex,vvarvecm_tex,data_mat,0,val_width,val_precis,optional_header); dyn_latex_table(M_, options_, title_string, 'RMSE_ranges_after_filtering', headers_tex, vvarvecm_tex, data_mat, 0, val_width, val_precis, optional_header);
end end
% R2 table
%%%%% R2 table
vvarvecm=vvarvecm0; vvarvecm=vvarvecm0;
skipline() skipline()
title_string='R2 over the MC sample:'; title_string='R2 over the MC sample:';
data_mat=[min(r2_MC)' max(r2_MC)']; data_mat=[min(r2_MC)' max(r2_MC)'];
headers=strvcat('Variable','min yr R2','max yr R2'); headers = {'Variable'; 'min yr R2'; 'max yr R2'};
dyntable(options_,title_string,headers,vvarvecm,data_mat, 0, 15, 5); dyntable(options_, title_string, headers, vvarvecm, data_mat, 0, 15, 5);
if options_.TeX if options_.TeX
headers_tex=strvcat('\text{Variable}','\text{min yr R2}','\text{max yr R2}'); headers_tex = {'\text{Variable}'; '\text{min yr R2}'; '\text{max yr R2}'};
dyn_latex_table(M_,options_,title_string,'R2_MC',headers_tex,vvarvecm_tex,data_mat,0,15,5); dyn_latex_table(M_, options_, title_string, 'R2_MC', headers_tex, vvarvecm_tex, data_mat, 0, 15, 5);
end end
r2_MC=r2_MC(:,ivar); r2_MC=r2_MC(:,ivar);
vvarvecm=vvarvecm(ivar,:); vvarvecm=vvarvecm(ivar);
skipline() skipline()
disp(['Sample filtered the ',num2str(pfilt*100),'% best R2''s for each observed series ...' ]) disp(['Sample filtered the ',num2str(pfilt*100),'% best R2''s for each observed series ...' ])
skipline() skipline()
disp('R2 ranges after filtering:') disp('R2 ranges after filtering:')
title_string='R2 ranges after filtering:'; title_string='R2 ranges after filtering:';
if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
headers=strvcat('Variable','min','max','min','max','posterior mode'); headers = {'Variable'; 'min'; 'max'; 'min'; 'max'; 'posterior mode'};
headers_tex=strvcat('\text{Variable}','\text{min}','\text{max}','\text{min}','\text{max}','\text{posterior mode}'); headers_tex = {'\text{Variable}'; '\text{min}'; '\text{max}'; '\text{min}'; '\text{max}'; '\text{posterior mode}'};
else else
headers=strvcat('Variable','min','max','min','max','posterior mean'); headers = {'Variable'; 'min'; 'max'; 'min'; 'max'; 'posterior mean'};
headers_tex=strvcat('\text{Variable}','\text{min}','\text{max}','\text{min}','\text{max}','\text{posterior mean}'); headers_tex = {'\text{Variable}'; '\text{min}'; '\text{max}'; '\text{min}'; '\text{max}'; '\text{posterior mean}'};
end end
data_mat=NaN(size(vvarvecm,1),5); data_mat=NaN(length(vvarvecm),5);
for j=1:size(vvarvecm,1) for j = 1:length(vvarvecm)
data_mat(j,:)=[min(r2_MC(ixx(1:nfilt0(j),j),j)) ... data_mat(j,:)=[min(r2_MC(ixx(1:nfilt0(j),j),j)) ...
max(r2_MC(ixx(1:nfilt0(j),j),j)) ... max(r2_MC(ixx(1:nfilt0(j),j),j)) ...
min(r2_MC(ixx(nfilt0(j)+1:end,j),j)) ... min(r2_MC(ixx(nfilt0(j)+1:end,j),j)) ...
@ -684,10 +648,10 @@ else
r2_txt(j)]; r2_txt(j)];
end end
%get formatting for additional header line %get formatting for additional header line
val_width=15; val_width = 15;
val_precis=5; val_precis = 5;
label_width = max(size(deblank(char(headers(1,:),vvarvecm)),2)+2,0); label_width = max(cellofchararraymaxlength(vertcat(headers{1}, vvarvecm))+2, 0);
label_format_leftbound = sprintf('%%-%ds',label_width); label_format_leftbound = sprintf('%%-%ds', label_width);
if all(~isfinite(data_mat)) if all(~isfinite(data_mat))
values_length = 4; values_length = 4;
else else
@ -696,35 +660,32 @@ else
if any(data_mat) < 0 %add one character for minus sign if any(data_mat) < 0 %add one character for minus sign
values_length = values_length+1; values_length = values_length+1;
end end
headers_length = cellofchararraymaxlength(headers(2:end));
headers_length = max(size(deblank(headers(2:end,:)),2));
if ~isempty(val_width) if ~isempty(val_width)
val_width = max(max(headers_length,values_length)+2,val_width); val_width = max(max(headers_length, values_length)+2, val_width);
else else
val_width = max(headers_length,values_length)+2; val_width = max(headers_length, values_length)+2;
end end
value_format = sprintf('%%%d.%df',val_width,val_precis); value_format = sprintf('%%%d.%df',val_width,val_precis);
header_string_format = sprintf('%%%ds',val_width); header_string_format = sprintf('%%%ds',val_width);
if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
optional_header=sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','',['best ',num2str(pfilt*100),'% filtered'],'','remaining 90%'); optional_header = sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','',['best ',num2str(pfilt*100),'% filtered'],'','remaining 90%');
else else
optional_header=sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','','best filtered','','remaining'); optional_header = sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','','best filtered','','remaining');
end end
dyntable(options_,title_string,headers,vvarvecm,data_mat, 0, val_width, val_precis,optional_header); dyntable(options_, title_string, headers, vvarvecm, data_mat, 0, val_width, val_precis, optional_header);
if options_.TeX if options_.TeX
if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior if ~options_.opt_gsa.ppost && options_.opt_gsa.pprior
optional_header={[' & \multicolumn{2}{c}{best ',num2str(pfilt*100),' filtered} & \multicolumn{2}{c}{remaining 90\%}\\']}; optional_header = {[' & \multicolumn{2}{c}{best ',num2str(pfilt*100),' filtered} & \multicolumn{2}{c}{remaining 90\%}\\']};
else else
optional_header={[' & \multicolumn{2}{c}{best filtered} & \multicolumn{2}{c}{remaining}\\']}; optional_header = {[' & \multicolumn{2}{c}{best filtered} & \multicolumn{2}{c}{remaining}\\']};
end end
dyn_latex_table(M_,options_,title_string,'R2_ranges_after_filtering',headers_tex,vvarvecm_tex,data_mat,0,val_width,val_precis,optional_header); dyn_latex_table(M_, options_, title_string, 'R2_ranges_after_filtering', headers_tex, vvarvecm_tex, data_mat, 0, val_width, val_precis, optional_header);
end end
% R2 table
SP = zeros(npar+nshock, length(vvarvecm));
%%%% R2 table for j = 1:length(vvarvecm)
SP=zeros(npar+nshock,size(vvarvecm,1));
for j=1:size(vvarvecm,1)
ns=find(PP(:,j)<alpha); ns=find(PP(:,j)<alpha);
SP(ns,j)=ones(size(ns)); SP(ns,j)=ones(size(ns));
SS(:,j)=SS(:,j).*SP(:,j); SS(:,j)=SS(:,j).*SP(:,j);
@ -733,33 +694,24 @@ else
for j=1:npar+nshock %estim_params_.np, for j=1:npar+nshock %estim_params_.np,
nsp(j)=length(find(SP(j,:))); nsp(j)=length(find(SP(j,:)));
end end
snam0=param_names(find(nsp==0),:); snam0=param_names(find(nsp==0));
snam1=param_names(find(nsp==1),:); snam1=param_names(find(nsp==1));
snam2=param_names(find(nsp>1),:); snam2=param_names(find(nsp>1));
snam=param_names(find(nsp>0),:); snam=param_names(find(nsp>0));
% snam0=bayestopt_.name(find(nsp==0));
% snam1=bayestopt_.name(find(nsp==1));
% snam2=bayestopt_.name(find(nsp>1));
% snam=bayestopt_.name(find(nsp>0));
nsnam=(find(nsp>1)); nsnam=(find(nsp>1));
skipline(2) skipline(2)
disp('These parameters do not affect significantly the fit of ANY observed series:') disp('These parameters do not affect significantly the fit of ANY observed series:')
disp(snam0) disp(char(snam0))
skipline() skipline()
disp('These parameters affect ONE single observed series:') disp('These parameters affect ONE single observed series:')
disp(snam1) disp(char(snam1))
skipline() skipline()
disp('These parameters affect MORE THAN ONE observed series: trade off exists!') disp('These parameters affect MORE THAN ONE observed series: trade off exists!')
disp(snam2) disp(char(snam2))
%pnam=bayestopt_.name(end-estim_params_.np+1:end);
pnam=bayestopt_.name; pnam=bayestopt_.name;
% plot trade-offs % plot trade-offs
if ~options_.nograph if ~options_.nograph
a00=jet(size(vvarvecm,1)); a00=jet(length(vvarvecm));
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
temp_name='RMSE Posterior Tradeoffs:'; temp_name='RMSE Posterior Tradeoffs:';
atitle='RMSE Posterior Map:'; atitle='RMSE Posterior Map:';
@ -783,33 +735,30 @@ else
options_mcf.param_names_tex = param_names_tex; options_mcf.param_names_tex = param_names_tex;
options_mcf.fname_ = fname_; options_mcf.fname_ = fname_;
options_mcf.OutputDirectoryName = OutDir; options_mcf.OutputDirectoryName = OutDir;
for iy=1:size(vvarvecm,1) for iy = 1:length(vvarvecm)
options_mcf.amcf_name = [asname '_' deblank(vvarvecm(iy,:)) '_map' ]; options_mcf.amcf_name = [asname '_' vvarvecm{iy} '_map' ];
options_mcf.amcf_title = [atitle ' ' deblank(vvarvecm(iy,:))]; options_mcf.amcf_title = [atitle ' ' vvarvecm{iy}];
options_mcf.beha_title = ['better fit of ' deblank(vvarvecm(iy,:))]; options_mcf.beha_title = ['better fit of ' vvarvecm{iy}];
options_mcf.nobeha_title = ['worse fit of ' deblank(vvarvecm(iy,:))]; options_mcf.nobeha_title = ['worse fit of ' vvarvecm{iy}];
options_mcf.title = ['the fit of ' deblank(vvarvecm(iy,:))]; options_mcf.title = ['the fit of ' vvarvecm{iy}];
mcf_analysis(x, ixx(1:nfilt0(iy),iy), ixx(nfilt0(iy)+1:end,iy), options_mcf, options_); mcf_analysis(x, ixx(1:nfilt0(iy),iy), ixx(nfilt0(iy)+1:end,iy), options_mcf, options_);
end end
for iy=1:size(vvarvecm,1) for iy = 1:length(vvarvecm)
ipar = find(any(squeeze(PPV(iy,:,:))<alpha)); ipar = find(any(squeeze(PPV(iy,:,:))<alpha));
for ix=1:ceil(length(ipar)/5) for ix=1:ceil(length(ipar)/5)
hh = dyn_figure(options_.nodisplay,'name',[temp_name,' observed variable ',deblank(vvarvecm(iy,:))]); hh = dyn_figure(options_.nodisplay,'name',[temp_name,' observed variable ', vvarvecm{iy}]);
for j=1+5*(ix-1):min(length(ipar),5*ix) for j=1+5*(ix-1):min(length(ipar),5*ix)
subplot(2,3,j-5*(ix-1)) subplot(2,3,j-5*(ix-1))
%h0=cumplot(x(:,nsnam(j)+nshock));
h0=cumplot(x(:,ipar(j))); h0=cumplot(x(:,ipar(j)));
set(h0,'color',[0 0 0]) set(h0,'color',[0 0 0])
hold on, hold on,
iobs=find(squeeze(PPV(iy,:,ipar(j)))<alpha); iobs=find(squeeze(PPV(iy,:,ipar(j)))<alpha);
for i=1:size(vvarvecm,1) for i = 1:length(vvarvecm)
%h0=cumplot(x(ixx(1:nfilt,np(i)),nsnam(j)+nshock));
% h0=cumplot(x(ixx(1:nfilt0(np(i)),np(i)),nsnam(j)));
if any(iobs==i) || i==iy if any(iobs==i) || i==iy
h0=cumplot(x(ixx(1:nfilt0(i),i),ipar(j))); h0=cumplot(x(ixx(1:nfilt0(i),i),ipar(j)));
if ~isoctave if ~isoctave
hcmenu = uicontextmenu; hcmenu = uicontextmenu;
uimenu(hcmenu,'Label',deblank(vvarvecm(i,:))); uimenu(hcmenu,'Label',vvarvecm{i});
set(h0,'uicontextmenu',hcmenu) set(h0,'uicontextmenu',hcmenu)
end end
else else
@ -818,7 +767,6 @@ else
set(h0,'color',a00(i,:),'linewidth',2) set(h0,'color',a00(i,:),'linewidth',2)
end end
ydum=get(gca,'ylim'); ydum=get(gca,'ylim');
%xdum=xparam1(nshock+nsnam(j));
if exist('xparam1') if exist('xparam1')
xdum=xparam1(ipar(j)); xdum=xparam1(ipar(j));
h1=plot([xdum xdum],ydum); h1=plot([xdum xdum],ydum);
@ -827,65 +775,55 @@ else
xlabel('') xlabel('')
title([pnam{ipar(j)}],'interpreter','none') title([pnam{ipar(j)}],'interpreter','none')
end end
%subplot(3,2,6)
if isoctave if isoctave
legend(char('base',vvarvecm),'location','eastoutside'); legend(vertcat('base',vvarvecm),'location','eastoutside');
else else
h0=legend(char('base',vvarvecm)); h0=legend(vertcat('base',vvarvecm));
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none'); set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none');
end end
%h0=legend({'base',vnam{np}}',0);
%set(findobj(get(h0,'children'),'type','text'),'interpreter','none')
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],options_.nodisplay,options_.graph_format); dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_' vvarvecm{iy} '_' int2str(ix)],options_.nodisplay,options_.graph_format);
if options_.TeX if options_.TeX
create_TeX_loader(options_,[ OutDir filesep fname_ '_rmse_post_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],ix,[temp_name,' observed variable $',deblank(vvarvecm_tex(iy,:)) '$'],['rmse_post_' deblank(vvarvecm(iy,:))],1) create_TeX_loader(options_,[ OutDir filesep fname_ '_rmse_post_' vvarvecm{iy} '_' int2str(ix)],ix,[temp_name,' observed variable $',vvarvecm_tex{iy} '$'],['rmse_post_' vvarvecm{iy}],1)
end end
else else
if options_.opt_gsa.pprior if options_.opt_gsa.pprior
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_' deblank(vvarvecm(iy,:)) '_' int2str(ix) ],options_.nodisplay,options_.graph_format); dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_' vvarvecm{iy} '_' int2str(ix) ],options_.nodisplay,options_.graph_format);
if options_.TeX if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_' deblank(vvarvecm(iy,:)) '_' int2str(ix) ],ix,[temp_name,' observed variable $',deblank(vvarvecm_tex(iy,:)) '$'],['rmse_prior_' deblank(vvarvecm(iy,:))],1) create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_' vvarvecm{iy} '_' int2str(ix) ],ix,[temp_name,' observed variable $',vvarvecm_tex{iy} '$'],['rmse_prior_' vvarvecm{iy}],1)
end end
else else
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],options_.nodisplay,options_.graph_format); dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_' vvarvecm{iy} '_' int2str(ix)],options_.nodisplay,options_.graph_format);
if options_.TeX if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],ix,[temp_name,' observed variable $',deblank(vvarvecm_tex(iy,:)) '$'],['rmse_mc_' deblank(vvarvecm(iy,:))],1) create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_' vvarvecm{iy} '_' int2str(ix)],ix,[temp_name,' observed variable $',vvarvecm_tex{iy} '$'],['rmse_mc_' vvarvecm{iy}],1)
end end
end end
end end
end end
end end
% now I plot by individual parameters % now I plot by individual parameters
for ix=1:ceil(length(nsnam)/5) for ix=1:ceil(length(nsnam)/5)
hh = dyn_figure(options_.nodisplay,'name',[temp_name,' estimated params and shocks ',int2str(ix)]); hh = dyn_figure(options_.nodisplay,'name',[temp_name,' estimated params and shocks ',int2str(ix)]);
for j=1+5*(ix-1):min(size(snam2,1),5*ix) for j=1+5*(ix-1):min(size(snam2,1),5*ix)
subplot(2,3,j-5*(ix-1)) subplot(2,3,j-5*(ix-1))
%h0=cumplot(x(:,nsnam(j)+nshock));
h0=cumplot(x(:,nsnam(j))); h0=cumplot(x(:,nsnam(j)));
set(h0,'color',[0 0 0]) set(h0,'color',[0 0 0])
hold on, hold on,
npx=find(SP(nsnam(j),:)==0); npx=find(SP(nsnam(j),:)==0);
%a0=jet(nsp(nsnam(j))); for i = 1:length(vvarvecm)
% a0=a00(np,:);
for i=1:size(vvarvecm,1)
%h0=cumplot(x(ixx(1:nfilt,np(i)),nsnam(j)+nshock));
% h0=cumplot(x(ixx(1:nfilt0(np(i)),np(i)),nsnam(j)));
if any(npx==i) if any(npx==i)
h0=cumplot(x(ixx(1:nfilt0(i),i),nsnam(j))*NaN); h0=cumplot(x(ixx(1:nfilt0(i),i),nsnam(j))*NaN);
else else
h0=cumplot(x(ixx(1:nfilt0(i),i),nsnam(j))); h0=cumplot(x(ixx(1:nfilt0(i),i),nsnam(j)));
if ~isoctave if ~isoctave
hcmenu = uicontextmenu; hcmenu = uicontextmenu;
uimenu(hcmenu,'Label',deblank(vvarvecm(i,:))); uimenu(hcmenu,'Label', vvarvecm{i});
set(h0,'uicontextmenu',hcmenu) set(h0,'uicontextmenu',hcmenu)
end end
end end
set(h0,'color',a00(i,:),'linewidth',2) set(h0,'color',a00(i,:),'linewidth',2)
end end
ydum=get(gca,'ylim'); ydum=get(gca,'ylim');
%xdum=xparam1(nshock+nsnam(j));
if exist('xparam1') if exist('xparam1')
xdum=xparam1(nsnam(j)); xdum=xparam1(nsnam(j));
h1=plot([xdum xdum],ydum); h1=plot([xdum xdum],ydum);
@ -896,13 +834,11 @@ else
end end
%subplot(3,2,6) %subplot(3,2,6)
if isoctave if isoctave
legend(char('base',vvarvecm),'location','eastoutside'); legend(vertcat('base',vvarvecm),'location','eastoutside');
else else
h0=legend(char('base',vvarvecm)); h0=legend(vertcat('base',vvarvecm));
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none'); set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none');
end end
%h0=legend({'base',vnam{np}}',0);
%set(findobj(get(h0,'children'),'type','text'),'interpreter','none')
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_params_' int2str(ix)],options_.nodisplay,options_.graph_format); dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_params_' int2str(ix)],options_.nodisplay,options_.graph_format);
if options_.TeX if options_.TeX
@ -923,66 +859,6 @@ else
end end
end end
end end
% for j=1:size(SP,2),
% nsx(j)=length(find(SP(:,j)));
% end
% skipline(2)
% disp('Sensitivity table (significance and direction):')
% vav=char(zeros(1, size(param_names,2)+3 ));
% ibl = 12-size(vvarvecm,2);
% for j=1:size(vvarvecm,1),
% vav = [vav, char(zeros(1,ibl)),vvarvecm(j,:)];
% end
% disp(vav)
% for j=1:npar+nshock, %estim_params_.np,
% %disp([param_names(j,:), sprintf('%8.5g',SP(j,:))])
% disp([param_names(j,:),' ', sprintf('%12.3g',PP(j,:))])
% disp([char(zeros(1, size(param_names,2)+3 )),sprintf(' (%6g)',SS(j,:))])
% end
% skipline()
% disp('Starting bivariate analysis:')
%
% for i=1:size(vvarvecm,1)
% if options_.opt_gsa.ppost
% fnam = ['rmse_post_',deblank(vvarvecm(i,:))];
% else
% if options_.opt_gsa.pprior
% fnam = ['rmse_prior_',deblank(vvarvecm(i,:))];
% else
% fnam = ['rmse_mc_',deblank(vvarvecm(i,:))];
% end
% end
% stab_map_2(x(ixx(1:nfilt0(i),i),:),alpha2,pvalue,fnam, OutDir,[],[temp_name ' observed variable ' deblank(vvarvecm(i,:))]);
%
% % [pc,latent,explained] = pcacov(c0);
% % %figure, bar([explained cumsum(explained)])
% % ifig=0;
% % j2=0;
% % for j=1:npar+nshock,
% % i2=find(abs(pc(:,j))>alphaPC);
% % if ~isempty(i2),
% % j2=j2+1;
% % if mod(j2,12)==1,
% % ifig=ifig+1;
% % figure('name',['PCA of the filtered sample ',deblank(vvarvecm(i,:)),' ',num2str(ifig)]),
% % end
% % subplot(3,4,j2-(ifig-1)*12)
% % bar(pc(i2,j)),
% % set(gca,'xticklabel',bayestopt_.name(i2)),
% % set(gca,'xtick',[1:length(i2)])
% % title(['PC ',num2str(j),'. Explained ',num2str(explained(j)),'%'])
% % end
% % if (mod(j2,12)==0 | j==(npar+nshock)) & j2,
% % saveas(gcf,[fname_,'_SA_PCA_',deblank(vvarvecm(i,:)),'_',int2str(ifig)])
% % end
% % end
% % close all
% end
end end
function []=create_TeX_loader(options_,figpath,label_number,caption,label_name,scale_factor) function []=create_TeX_loader(options_,figpath,label_number,caption,label_name,scale_factor)

View File

@ -5,7 +5,7 @@ function map_calibration(OutputDirectoryName, Model, DynareOptions, DynareResult
% marco.ratto@ec.europa.eu % marco.ratto@ec.europa.eu
% Copyright (C) 2014-2016 European Commission % Copyright (C) 2014-2016 European Commission
% Copyright (C) 2014-2017 Dynare Team % Copyright (C) 2014-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -48,9 +48,9 @@ init = ~DynareOptions.opt_gsa.load_stab;
options_mcf.pvalue_ks = DynareOptions.opt_gsa.pvalue_ks; options_mcf.pvalue_ks = DynareOptions.opt_gsa.pvalue_ks;
options_mcf.pvalue_corr = DynareOptions.opt_gsa.pvalue_corr; options_mcf.pvalue_corr = DynareOptions.opt_gsa.pvalue_corr;
options_mcf.alpha2 = DynareOptions.opt_gsa.alpha2_stab; options_mcf.alpha2 = DynareOptions.opt_gsa.alpha2_stab;
options_mcf.param_names = char(pnames); options_mcf.param_names = pnames;
if DynareOptions.TeX if DynareOptions.TeX
options_mcf.param_names_tex=char(pnames_tex); options_mcf.param_names_tex = pnames_tex;
end end
options_mcf.fname_ = fname_; options_mcf.fname_ = fname_;
options_mcf.OutputDirectoryName = OutputDirectoryName; options_mcf.OutputDirectoryName = OutputDirectoryName;
@ -375,11 +375,11 @@ if ~isempty(indx_moment)
name{jj,1} = param_name_temp; name{jj,1} = param_name_temp;
end end
end end
options_mcf.param_names = char(name); options_mcf.param_names = name;
if DynareOptions.TeX if DynareOptions.TeX
options_mcf.param_names_tex = char(name_tex); options_mcf.param_names_tex = name_tex;
end end
options_mcf.param_names = char(BayesInfo.name); options_mcf.param_names = BayesInfo.name;
all_moment_couples = cellstr([char(endo_prior_restrictions.moment(:,1)) char(endo_prior_restrictions.moment(:,2))]); all_moment_couples = cellstr([char(endo_prior_restrictions.moment(:,1)) char(endo_prior_restrictions.moment(:,2))]);
moment_couples = unique(all_moment_couples); moment_couples = unique(all_moment_couples);
nbr_moment_couples = size(moment_couples,1); nbr_moment_couples = size(moment_couples,1);

View File

@ -5,7 +5,7 @@ function map_ident_(OutputDirectoryName,opt_gsa)
% marco.ratto@ec.europa.eu % marco.ratto@ec.europa.eu
% Copyright (C) 2012-2016 European Commission % Copyright (C) 2012-2016 European Commission
% Copyright (C) 2012-2017 Dynare Team % Copyright (C) 2012-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -37,7 +37,7 @@ else
gsa_flag=-2; gsa_flag=-2;
end end
pnames = M_.param_names(estim_params_.param_vals(:,1),:); pnames = M_.param_names(estim_params_.param_vals(:,1));
if opt_gsa.pprior if opt_gsa.pprior
filetoload=[OutputDirectoryName '/' fname_ '_prior']; filetoload=[OutputDirectoryName '/' fname_ '_prior'];
@ -106,7 +106,7 @@ if opt_gsa.load_ident_files==0
end end
xlabel(' ') xlabel(' ')
ylabel(' ') ylabel(' ')
title(M_.exo_names(j,:),'interpreter','none') title(M_.exo_names{j},'interpreter','none')
if mod(j,6)==0 | j==M_.exo_nbr if mod(j,6)==0 | j==M_.exo_nbr
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],options_.nodisplay,options_.graph_format); dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],ifig,['Variance decomposition shocks'],'vdec_exo',options_.figures.textwidth*min(iplo/3,1)) create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],ifig,['Variance decomposition shocks'],'vdec_exo',options_.figures.textwidth*min(iplo/3,1))

View File

@ -1,6 +1,6 @@
function [vdec, cc, ac] = mc_moments(mm, ss, dr) function [vdec, cc, ac] = mc_moments(mm, ss, dr)
% Copyright (C) 2012-2017 Dynare Team % Copyright (C) 2012-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -20,7 +20,7 @@ function [vdec, cc, ac] = mc_moments(mm, ss, dr)
global options_ M_ estim_params_ oo_ global options_ M_ estim_params_ oo_
[nr1, nc1, nsam] = size(mm); [nr1, nc1, nsam] = size(mm);
nobs=size(options_.varobs,2); nobs=length(options_.varobs);
disp('Computing theoretical moments ...') disp('Computing theoretical moments ...')
h = dyn_waitbar(0,'Theoretical moments ...'); h = dyn_waitbar(0,'Theoretical moments ...');
vdec = zeros(nobs,M_.exo_nbr,nsam); vdec = zeros(nobs,M_.exo_nbr,nsam);

View File

@ -6,7 +6,7 @@ function indmcf = mcf_analysis(lpmat, ibeha, inobeha, options_mcf, DynareOptions
% %
% Copyright (C) 2014 European Commission % Copyright (C) 2014 European Commission
% Copyright (C) 2016-2017 Dynare Team % Copyright (C) 2016-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -53,13 +53,13 @@ indmcf=find(proba<pvalue_ks);
indmcf = indmcf(jtmp); indmcf = indmcf(jtmp);
if ~isempty(indmcf) if ~isempty(indmcf)
skipline() skipline()
headers=char('Parameter','d-stat','p-value'); headers = {'Parameter','d-stat','p-value'};
labels=char(param_names(indmcf,:)); labels = param_names(indmcf);
data_mat=[dproba(indmcf)' proba(indmcf)']; data_mat=[dproba(indmcf)' proba(indmcf)'];
options_temp.noprint=0; options_temp.noprint=0;
dyntable(options_temp,['Smirnov statistics in driving ', title],headers,labels,data_mat,size(labels,2)+2,16,3); dyntable(options_temp,['Smirnov statistics in driving ', title],headers,labels,data_mat,size(labels,2)+2,16,3);
if DynareOptions.TeX if DynareOptions.TeX
labels_TeX=param_names_tex(indmcf,:); labels_TeX=param_names_tex(indmcf);
M_temp.dname=OutputDirectoryName ; M_temp.dname=OutputDirectoryName ;
M_temp.fname=fname_; M_temp.fname=fname_;
dyn_latex_table(M_temp,options_temp,['Smirnov statistics in driving ', strrep(title,'_','\\_')],amcf_name,headers,labels_TeX,data_mat,size(labels,2)+2,16,6); dyn_latex_table(M_temp,options_temp,['Smirnov statistics in driving ', strrep(title,'_','\\_')],amcf_name,headers,labels_TeX,data_mat,size(labels,2)+2,16,6);
@ -78,7 +78,7 @@ if ~isempty(indmcf) && ~DynareOptions.nograph
skipline() skipline()
xx=[]; xx=[];
if ~ isempty(xparam1), xx=xparam1(indmcf); end if ~ isempty(xparam1), xx=xparam1(indmcf); end
scatter_mcf(lpmat(ibeha,indmcf),lpmat(inobeha,indmcf), param_names(indmcf,:), ... scatter_mcf(lpmat(ibeha,indmcf),lpmat(inobeha,indmcf), param_names(indmcf), ...
'.', [fname_,'_',amcf_name], OutputDirectoryName, amcf_title,xx, DynareOptions, ... '.', [fname_,'_',amcf_name], OutputDirectoryName, amcf_title,xx, DynareOptions, ...
beha_title, nobeha_title) beha_title, nobeha_title)
end end

View File

@ -16,7 +16,7 @@ function redform_map(dirname,options_gsa_)
% marco.ratto@ec.europa.eu % marco.ratto@ec.europa.eu
% Copyright (C) 2012-2016 European Commission % Copyright (C) 2012-2016 European Commission
% Copyright (C) 2012-2017 Dynare Team % Copyright (C) 2012-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -86,9 +86,9 @@ end
options_mcf.pvalue_ks = options_gsa_.ksstat_redform; options_mcf.pvalue_ks = options_gsa_.ksstat_redform;
options_mcf.pvalue_corr = options_gsa_.alpha2_redform; options_mcf.pvalue_corr = options_gsa_.alpha2_redform;
options_mcf.alpha2 = options_gsa_.alpha2_redform; options_mcf.alpha2 = options_gsa_.alpha2_redform;
options_mcf.param_names = char(pnames); options_mcf.param_names = pnames;
if options_.TeX if options_.TeX
options_mcf.param_names_tex=char(pnames_tex); options_mcf.param_names_tex = pnames_tex;
end end
options_mcf.fname_ = M_.fname; options_mcf.fname_ = M_.fname;
options_mcf.OutputDirectoryName = adir; options_mcf.OutputDirectoryName = adir;
@ -147,14 +147,14 @@ nsok = length(find(M_.lead_lag_incidence(M_.maximum_lag,:)));
lpmat=[]; lpmat=[];
lpmat0=[]; lpmat0=[];
js=0; js=0;
for j=1:size(anamendo,1) for j = 1:length(anamendo)
namendo=deblank(anamendo(j,:)); namendo = anamendo{j};
iendo=strmatch(namendo,M_.endo_names(oo_.dr.order_var,:),'exact'); iendo = strmatch(namendo, M_.endo_names(oo_.dr.order_var), 'exact');
ifig=0; ifig = 0;
iplo=0; iplo = 0;
for jx=1:size(anamexo,1) for jx = 1:length(anamexo)
namexo=deblank(anamexo(jx,:)); namexo = anamexo{jx};
iexo=strmatch(namexo,M_.exo_names,'exact'); iexo=strmatch(namexo, M_.exo_names, 'exact');
skipline() skipline()
disp(['[', namendo,' vs ',namexo,']']) disp(['[', namendo,' vs ',namexo,']'])
@ -289,9 +289,9 @@ for j=1:size(anamendo,1)
end end
ifig=0; ifig=0;
iplo=0; iplo=0;
for je=1:size(anamlagendo,1) for je=1:length(anamlagendo)
namlagendo=deblank(anamlagendo(je,:)); namlagendo = anamlagendo{je};
ilagendo=strmatch(namlagendo,M_.endo_names(oo_.dr.order_var(M_.nstatic+1:M_.nstatic+nsok),:),'exact'); ilagendo=strmatch(namlagendo, M_.endo_names(oo_.dr.order_var(M_.nstatic+1:M_.nstatic+nsok)), 'exact');
skipline() skipline()
disp(['[', namendo,' vs lagged ',namlagendo,']']) disp(['[', namendo,' vs lagged ',namlagendo,']'])

View File

@ -11,7 +11,7 @@ function redform_screen(dirname, options_gsa_)
% marco.ratto@ec.europa.eu % marco.ratto@ec.europa.eu
% Copyright (C) 2012-2016 European Commission % Copyright (C) 2012-2016 European Commission
% Copyright (C) 2012-2017 Dynare Team % Copyright (C) 2012-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -38,7 +38,7 @@ anamexo = options_gsa_.namexo;
iload = options_gsa_.load_redform; iload = options_gsa_.load_redform;
nliv = options_gsa_.morris_nliv; nliv = options_gsa_.morris_nliv;
pnames = M_.param_names(estim_params_.param_vals(:,1),:); pnames = M_.param_names(estim_params_.param_vals(:,1));
if nargin==0 if nargin==0
dirname=''; dirname='';
end end
@ -54,36 +54,33 @@ nsok = length(find(M_.lead_lag_incidence(M_.maximum_lag,:)));
js=0; js=0;
for j=1:size(anamendo,1) for j=1:size(anamendo,1)
namendo=deblank(anamendo(j,:)); namendo = deblank(anamendo(j,:));
iendo=strmatch(namendo,M_.endo_names(oo_.dr.order_var,:),'exact'); iendo = strmatch(namendo, M_.endo_names(oo_.dr.order_var), 'exact');
iplo=0; iplo=0;
ifig=0; ifig=0;
for jx=1:size(anamexo,1) for jx=1:size(anamexo,1)
namexo=deblank(anamexo(jx,:)); namexo = deblank(anamexo(jx,:));
iexo=strmatch(namexo,M_.exo_names,'exact'); iexo = strmatch(namexo, M_.exo_names, 'exact');
if ~isempty(iexo) if ~isempty(iexo)
y0=teff(T(iendo,iexo+nspred,:),kn,istable); y0=teff(T(iendo,iexo+nspred,:), kn, istable);
if ~isempty(y0) if ~isempty(y0)
if mod(iplo,9)==0 if mod(iplo,9)==0
ifig=ifig+1; ifig = ifig+1;
hh=dyn_figure(options_.nodisplay,'name',[namendo,' vs. shocks ',int2str(ifig)]); hh = dyn_figure(options_.nodisplay, 'name', [namendo,[' vs. shocks '], int2str(ifig)]);
iplo=0; iplo = 0;
end end
iplo=iplo+1; iplo = iplo+1;
js=js+1; js = js+1;
subplot(3,3,iplo), subplot(3, 3, iplo)
[SAmeas, SAMorris] = Morris_Measure_Groups(np+nshock, [lpmat0 lpmat], y0,nliv); [SAmeas, SAMorris] = Morris_Measure_Groups(np+nshock, [lpmat0 lpmat], y0, nliv);
SAM = squeeze(SAMorris(nshock+1:end,1)); SAM = squeeze(SAMorris(nshock+1:end,1));
SA(:,js)=SAM./(max(SAM)+eps); SA(:,js) = SAM./(max(SAM)+eps);
[saso, iso] = sort(-SA(:,js)); [saso, iso] = sort(-SA(:,js));
bar(SA(iso(1:min(np,10)),js)) bar(SA(iso(1:min(np,10)),js))
%set(gca,'xticklabel',pnames(iso(1:min(np,10)),:),'fontsize',8)
set(gca,'xticklabel',' ','fontsize',10) set(gca,'xticklabel',' ','fontsize',10)
set(gca,'xlim',[0.5 10.5]) set(gca,'xlim',[0.5 10.5])
for ip=1:min(np,10) for ip=1:min(np,10)
text(ip,-0.02,deblank(pnames(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','none') text(ip,-0.02,pnames(iso(ip)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
end end
title([namendo,' vs. ',namexo],'interpreter','none') title([namendo,' vs. ',namexo],'interpreter','none')
if iplo==9 if iplo==9
@ -103,7 +100,7 @@ for j=1:size(anamendo,1)
ifig=0; ifig=0;
for je=1:size(anamlagendo,1) for je=1:size(anamlagendo,1)
namlagendo=deblank(anamlagendo(je,:)); namlagendo=deblank(anamlagendo(je,:));
ilagendo=strmatch(namlagendo,M_.endo_names(oo_.dr.order_var(M_.nstatic+1:M_.nstatic+nsok),:),'exact'); ilagendo=strmatch(namlagendo, M_.endo_names(oo_.dr.order_var(M_.nstatic+1:M_.nstatic+nsok)), 'exact');
if ~isempty(ilagendo) if ~isempty(ilagendo)
y0=teff(T(iendo,ilagendo,:),kn,istable); y0=teff(T(iendo,ilagendo,:),kn,istable);

View File

@ -6,7 +6,7 @@ function scatter_callback(K, type)
% %
% Copyright (C) 2017 European Commission % Copyright (C) 2017 European Commission
% Copyright (C) 2017 Dynare Team % Copyright (C) 2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -34,9 +34,7 @@ xparam1=x(K,:)';
switch type switch type
case 'save' case 'save'
save(['my_params_' int2str(K)],'xparam1') save(['my_params_' int2str(K)],'xparam1')
case 'eval' case 'eval'
disp('Evaluating smoother ...') disp('Evaluating smoother ...')
[oo_, M_]=evaluate_smoother(xparam1,M_.endo_names,M_,oo_,options_,bayestopt_,estim_params_); [oo_, M_]=evaluate_smoother(xparam1, M_.endo_names, M_, oo_, options_, bayestopt_, estim_params_);
% [rmse, lnam, r2,vv] = plot_fit(obsname{:});
end end

View File

@ -35,7 +35,7 @@ function x0 = stab_map_(OutputDirectoryName,opt_gsa)
% marco.ratto@ec.europa.eu % marco.ratto@ec.europa.eu
% Copyright (C) 2012-2016 European Commission % Copyright (C) 2012-2016 European Commission
% Copyright (C) 2012-2017 Dynare Team % Copyright (C) 2012-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -130,9 +130,9 @@ for jj=1:np
end end
end end
if options_.TeX if options_.TeX
options_mcf.param_names_tex=char(name_tex); options_mcf.param_names_tex = name_tex;
end end
options_mcf.param_names = char(name); options_mcf.param_names = name;
options_mcf.fname_ = fname_; options_mcf.fname_ = fname_;
options_mcf.OutputDirectoryName = OutputDirectoryName; options_mcf.OutputDirectoryName = OutputDirectoryName;
@ -663,9 +663,9 @@ if length(iunstable)>0 || length(iwrong)>0
end end
end end
if options_.TeX if options_.TeX
options_mcf.param_names_tex = char(name_tex); options_mcf.param_names_tex = name_tex;
end end
options_mcf.param_names = char(name); options_mcf.param_names = name;
options_mcf.amcf_name = acalibname; options_mcf.amcf_name = acalibname;
options_mcf.amcf_title = acalibtitle; options_mcf.amcf_title = acalibtitle;
options_mcf.beha_title = 'prior IRF/moment calibration'; options_mcf.beha_title = 'prior IRF/moment calibration';

View File

@ -6,7 +6,7 @@ function indcorr = stab_map_2(x,alpha2, pvalue_crit, fnam, dirname,xparam1,figti
% marco.ratto@ec.europa.eu % marco.ratto@ec.europa.eu
% Copyright (C) 2011-2016 European Commission % Copyright (C) 2011-2016 European Commission
% Copyright (C) 2011-2017 Dynare Team % Copyright (C) 2011-2018 Dynare Team
% This file is part of Dynare. % This file is part of Dynare.
% %
% Dynare is free software: you can redistribute it and/or modify % Dynare is free software: you can redistribute it and/or modify
@ -183,10 +183,10 @@ end
if j2==0 if j2==0
disp(['No correlation term with pvalue <', num2str(pvalue_crit),' and |corr. coef.| >',num2str(alpha2),' found for ',fnam]) disp(['No correlation term with pvalue <', num2str(pvalue_crit),' and |corr. coef.| >',num2str(alpha2),' found for ',fnam])
else else
headers=strvcat('Parameters','corrcoef'); headers={'Parameters'; 'corrcoef'};
dyntable(options_,title_string,headers,char(name),data_mat, 0, 7, 3); dyntable(options_,title_string,headers, name, data_mat, 0, 7, 3);
if options_.TeX if options_.TeX
dyn_latex_table(M_,options_,title_string_tex,fig_nam_tex_table,headers,char(name_tex),data_mat,0,7,3); dyn_latex_table(M_, options_, title_string_tex, fig_nam_tex_table, headers, name_tex, data_mat, 0, 7, 3);
end end
end end
%close all %close all

View File

@ -1,7 +1,7 @@
function [vdec, corr, autocorr, z, zz] = th_moments(dr,var_list) function [vdec, corr, autocorr, z, zz] = th_moments(dr,var_list)
% [vdec, corr, autocorr, z, zz] = th_moments(dr,var_list) % [vdec, corr, autocorr, z, zz] = th_moments(dr,var_list)
% Copyright (C) 2012-2017 Dynare Team % Copyright (C) 2012-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -20,14 +20,14 @@ function [vdec, corr, autocorr, z, zz] = th_moments(dr,var_list)
global M_ oo_ options_ global M_ oo_ options_
nvar = size(var_list,2); nvar = length(var_list);
if nvar == 0 if nvar == 0
nvar = length(dr.order_var); nvar = length(dr.order_var);
ivar = [1:nvar]'; ivar = [1:nvar]';
else else
ivar=zeros(nvar,1); ivar=zeros(nvar,1);
for i=1:nvar for i=1:nvar
i_tmp = strmatch(var_list{:,i},M_.endo_names,'exact'); i_tmp = strmatch(var_list{i}, M_.endo_names, 'exact');
if isempty(i_tmp) if isempty(i_tmp)
error(['One of the variables specified does not exist']) ; error(['One of the variables specified does not exist']) ;
else else

View File

@ -1,6 +1,6 @@
function histvalf(fname) function histvalf(fname)
% Copyright (C) 2014-2017 Dynare Team % Copyright (C) 2014-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -61,10 +61,10 @@ for i = 1:length(outvars)
end end
if M_.aux_vars(i).type == 1 if M_.aux_vars(i).type == 1
% Endogenous % Endogenous
orig_var = deblank(M_.endo_names(M_.aux_vars(i).orig_index, :)); orig_var = M_.endo_names{M_.aux_vars(i).orig_index};
else else
% Exogenous % Exogenous
orig_var = deblank(M_.exo_names(M_.aux_vars(i).orig_index, :)); orig_var = M_.exo_names{M_.aux_vars(i).orig_index};
end end
if strcmp(orig_var, ov) && M_.aux_vars(i).orig_lead_lag == lead_lag if strcmp(orig_var, ov) && M_.aux_vars(i).orig_lead_lag == lead_lag
j = M_.aux_vars(i).endo_index; j = M_.aux_vars(i).endo_index;

View File

@ -25,7 +25,7 @@ function homotopy2(values, step_nbr)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2008-2017 Dynare Team % Copyright (C) 2008-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -82,11 +82,11 @@ end
for i = 1:nv for i = 1:nv
switch values(i,1) switch values(i,1)
case 1 case 1
varname = M_.exo_names(values(i,2), :); varname = M_.exo_names{values(i,2)};
case 2 case 2
varname = M_.exo_det_names(values(i,2), :); varname = M_.exo_det_names{values(i,2)};
case 4 case 4
varname = M_.param_names(values(i,2), :); varname = M_.param_names{values(i,2)};
end end
for v = oldvalues(i):(values(i,4)-oldvalues(i))/step_nbr:values(i,4) for v = oldvalues(i):(values(i,4)-oldvalues(i))/step_nbr:values(i,4)
switch values(i,1) switch values(i,1)
@ -98,7 +98,7 @@ for i = 1:nv
M_.params(values(i,2)) = v; M_.params(values(i,2)) = v;
end end
disp([ 'HOMOTOPY mode 2: lauching solver with ' deblank(varname) ' = ' num2str(v) ' ...']) disp([ 'HOMOTOPY mode 2: lauching solver with ' varname ' = ' num2str(v) ' ...'])
oo_.steady_state = steady_(M_,options_,oo_); oo_.steady_state = steady_(M_,options_,oo_);
end end

View File

@ -17,7 +17,7 @@ function [pars, cosnJ] = ident_bruteforce(J,n,TeX, pnames_TeX,tittxt)
% pars : cell array with groupf of params for each column of J for 1 to n % pars : cell array with groupf of params for each column of J for 1 to n
% cosnJ : the cosn of each column with the selected group of columns % cosnJ : the cosn of each column with the selected group of columns
% Copyright (C) 2009-2017 Dynare Team % Copyright (C) 2009-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -105,13 +105,13 @@ for ll = 1:n
plist=''; plist='';
for ii=1:ll for ii=1:ll
if ~isnan(pars{i,ll}(ii)) if ~isnan(pars{i,ll}(ii))
plist = [plist ' $' pnames_TeX(pars{i,ll}(ii),:) '\;\; $ ']; plist = [plist ' $' pnames_TeX{pars{i,ll}(ii)} '\;\; $ '];
else else
plist = [plist ' ---- ']; plist = [plist ' ---- '];
end end
end end
fprintf(fidTeX,'$%s$ & [%s] & %7.3f \\\\ \n',... fprintf(fidTeX,'$%s$ & [%s] & %7.3f \\\\ \n',...
pnames_TeX(i,:),... pnames_TeX{i},...
plist,... plist,...
cosnJ(i,ll)); cosnJ(i,ll));
end end

View File

@ -26,7 +26,7 @@ function imcforecast(constrained_paths, constrained_vars, options_cond_fcst)
% [1] Results are stored in a structure which is saved in a mat file called conditional_forecasts.mat. % [1] Results are stored in a structure which is saved in a mat file called conditional_forecasts.mat.
% [2] Use the function plot_icforecast to plot the results. % [2] Use the function plot_icforecast to plot the results.
% Copyright (C) 2006-2017 Dynare Team % Copyright (C) 2006-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -146,8 +146,8 @@ if estimated_model
end end
% add trend to constant % add trend to constant
for obs_iter=1:length(options_.varobs) for obs_iter=1:length(options_.varobs)
j = strmatch(options_.varobs{obs_iter},M_.endo_names,'exact'); j = strmatch(options_.varobs{obs_iter}, M_.endo_names, 'exact');
constant(j,:) = constant(j,:)+trend_addition(obs_iter,:); constant(j,:) = constant(j,:) + trend_addition(obs_iter,:);
end end
trend = constant(oo_.dr.order_var,:); trend = constant(oo_.dr.order_var,:);
InitState(:,1) = atT(:,end); InitState(:,1) = atT(:,end);
@ -226,7 +226,7 @@ jdx = [];
for i = 1:n1 for i = 1:n1
idx = [idx ; constrained_vars(i,:)]; idx = [idx ; constrained_vars(i,:)];
% idx = [idx ; oo_.dr.inv_order_var(constrained_vars(i,:))]; % idx = [idx ; oo_.dr.inv_order_var(constrained_vars(i,:))];
jdx = [jdx ; strmatch(deblank(options_cond_fcst.controlled_varexo(i,:)),M_.exo_names,'exact')]; jdx = [jdx ; strmatch(options_cond_fcst.controlled_varexo{i},M_.exo_names,'exact')];
end end
mv = zeros(n1,NumberOfStates); mv = zeros(n1,NumberOfStates);
mu = zeros(ExoSize,n2); mu = zeros(ExoSize,n2);
@ -265,15 +265,15 @@ forecasts.controlled_variables = constrained_vars;
forecasts.instruments = options_cond_fcst.controlled_varexo; forecasts.instruments = options_cond_fcst.controlled_varexo;
for i = 1:EndoSize for i = 1:EndoSize
forecasts.cond.Mean.(deblank(M_.endo_names(oo_.dr.order_var(i),:)))= mFORCS1(i,:)'; forecasts.cond.Mean.(M_.endo_names{oo_.dr.order_var(i)}) = mFORCS1(i,:)';
tmp = sort(squeeze(FORCS1(i,:,:))'); tmp = sort(squeeze(FORCS1(i,:,:))');
forecasts.cond.ci.(deblank(M_.endo_names(oo_.dr.order_var(i),:))) = [tmp(t1,:)' ,tmp(t2,:)' ]'; forecasts.cond.ci.(M_.endo_names{oo_.dr.order_var(i)}) = [tmp(t1,:)' ,tmp(t2,:)' ]';
end end
for i = 1:n1 for i = 1:n1
forecasts.controlled_exo_variables.Mean.(deblank(options_cond_fcst.controlled_varexo(i,:))) = mFORCS1_shocks(i,:)'; forecasts.controlled_exo_variables.Mean.(options_cond_fcst.controlled_varexo{i}) = mFORCS1_shocks(i,:)';
tmp = sort(squeeze(FORCS1_shocks(i,:,:))'); tmp = sort(squeeze(FORCS1_shocks(i,:,:))');
forecasts.controlled_exo_variables.ci.(deblank(options_cond_fcst.controlled_varexo(i,:))) = [tmp(t1,:)' ,tmp(t2,:)' ]'; forecasts.controlled_exo_variables.ci.(options_cond_fcst.controlled_varexo{i}) = [tmp(t1,:)' ,tmp(t2,:)' ]';
end end
clear FORCS1 mFORCS1_shocks; clear FORCS1 mFORCS1_shocks;
@ -292,9 +292,9 @@ end
mFORCS2 = mean(FORCS2,3); mFORCS2 = mean(FORCS2,3);
for i = 1:EndoSize for i = 1:EndoSize
forecasts.uncond.Mean.(deblank(M_.endo_names(oo_.dr.order_var(i),:)))= mFORCS2(i,:)'; forecasts.uncond.Mean.(M_.endo_names{oo_.dr.order_var(i)})= mFORCS2(i,:)';
tmp = sort(squeeze(FORCS2(i,:,:))'); tmp = sort(squeeze(FORCS2(i,:,:))');
forecasts.uncond.ci.(deblank(M_.endo_names(oo_.dr.order_var(i),:))) = [tmp(t1,:)' ,tmp(t2,:)' ]'; forecasts.uncond.ci.(M_.endo_names{oo_.dr.order_var(i)}) = [tmp(t1,:)' ,tmp(t2,:)' ]';
end end
forecasts.graph.title=graph_title; forecasts.graph.title=graph_title;
forecasts.graph.fname=M_.fname; forecasts.graph.fname=M_.fname;

View File

@ -9,7 +9,7 @@ function plan = init_plan(date)
% plan [structure] Returns a structure containing a new forecast scenario % plan [structure] Returns a structure containing a new forecast scenario
% %
% %
% Copyright (C) 2013-2017 Dynare Team % Copyright (C) 2013-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -29,10 +29,8 @@ global M_
plan = struct(); plan = struct();
plan.date = date; plan.date = date;
plan.date_str = strings(date); plan.date_str = strings(date);
endo_names_length = size(M_.endo_names,2); plan.endo_names = M_.endo_names(1:M_.orig_endo_nbr);
plan.endo_names = deblank(mat2cell(M_.endo_names(1:M_.orig_endo_nbr,:),ones(1,M_.orig_endo_nbr),endo_names_length)); plan.exo_names = M_.exo_names(1:M_.exo_nbr);
exo_names_length = size(M_.exo_names,2);
plan.exo_names = deblank(mat2cell(M_.exo_names(1:M_.exo_nbr,:),ones(1,M_.exo_nbr),exo_names_length));
plan.constrained_vars_ = []; plan.constrained_vars_ = [];
plan.constrained_paths_ = []; plan.constrained_paths_ = [];
plan.constrained_date_ = []; plan.constrained_date_ = [];

View File

@ -8,20 +8,20 @@ function oo_ = initial_condition_decomposition(M_,oo_,options_,varlist,bayestopt
% in the order of declaration, i.e. M_.endo_names. % in the order of declaration, i.e. M_.endo_names.
% %
% INPUTS % INPUTS
% M_: [structure] Definition of the model % M_: [structure] Definition of the model
% oo_: [structure] Storage of results % oo_: [structure] Storage of results
% options_: [structure] Options % options_: [structure] Options
% varlist: [char] List of variables % varlist: [cell of char array] List of variables
% bayestopt_: [structure] describing the priors % bayestopt_: [structure] Description of the priors
% estim_params_: [structure] characterizing parameters to be estimated % estim_params_: [structure] Estimated parameters
% %
% OUTPUTS % OUTPUTS
% oo_: [structure] Storage of results % oo_: [structure] Storage of results
% %
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2017 Dynare Team % Copyright (C) 2017-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -46,12 +46,12 @@ options_.plot_shock_decomp.plot_init_date = options_.initial_condition_decomp.pl
options_.plot_shock_decomp.plot_end_date = options_.initial_condition_decomp.plot_end_date; options_.plot_shock_decomp.plot_end_date = options_.initial_condition_decomp.plot_end_date;
% indices of endogenous variables % indices of endogenous variables
if size(varlist,1) == 0 if isempty(varlist)
varlist = M_.endo_names(1:M_.orig_endo_nbr,:); varlist = M_.endo_names(1:M_.orig_endo_nbr);
end end
[i_var,nvar,index_uniques] = varlist_indices(varlist,M_.endo_names); [i_var, nvar, index_uniques] = varlist_indices(varlist, M_.endo_names);
varlist=varlist(index_uniques,:); varlist = varlist(index_uniques);
% number of variables % number of variables
endo_nbr = M_.endo_nbr; endo_nbr = M_.endo_nbr;
@ -89,7 +89,7 @@ if ~isfield(oo_,'initval_decomposition')
B = dr.ghu; B = dr.ghu;
% initialization % initialization
gend = size(oo.SmoothedShocks.(deblank(M_.exo_names(1,:))),1); %+options_.forecast; gend = length(oo.SmoothedShocks.(M_.exo_names{1})); %+options_.forecast;
z = zeros(endo_nbr,endo_nbr+2,gend); z = zeros(endo_nbr,endo_nbr+2,gend);
z(:,end,:) = Smoothed_Variables_deviation_from_mean; z(:,end,:) = Smoothed_Variables_deviation_from_mean;
@ -128,5 +128,5 @@ M_.exo_nbr = M_.endo_nbr;
options_.plot_shock_decomp.screen_shocks=1; options_.plot_shock_decomp.screen_shocks=1;
options_.plot_shock_decomp.use_shock_groups = ''; options_.plot_shock_decomp.use_shock_groups = '';
options_.plot_shock_decomp.fig_names='initval'; options_.plot_shock_decomp.fig_names='initval';
plot_shock_decomposition(M_,oo,options_,varlist); plot_shock_decomposition(M_, oo, options_, varlist);
% end % end

View File

@ -20,7 +20,7 @@ function DynareResults = initial_estimation_checks(objective_function,xparam1,Dy
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -73,7 +73,7 @@ if isfield(EstimatedParameters,'param_vals') && ~isempty(EstimatedParameters.par
if ~isempty(changed_par_indices) if ~isempty(changed_par_indices)
fprintf('\nThe steady state file internally changed the values of the following estimated parameters:\n') fprintf('\nThe steady state file internally changed the values of the following estimated parameters:\n')
disp(Model.param_names(EstimatedParameters.param_vals(changed_par_indices,1),:)); disp(char(Model.param_names(EstimatedParameters.param_vals(changed_par_indices,1))))
fprintf('This will override the parameter values drawn from the proposal density and may lead to wrong results.\n') fprintf('This will override the parameter values drawn from the proposal density and may lead to wrong results.\n')
fprintf('Check whether this is really intended.\n') fprintf('Check whether this is really intended.\n')
warning('The steady state file internally changes the values of the estimated parameters.') warning('The steady state file internally changes the values of the estimated parameters.')

View File

@ -14,7 +14,7 @@ function estim_params_ = initialize_from_mode(fname,M_,estim_params_)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -44,7 +44,7 @@ corrx = estim_params_.corrx;
corrn = estim_params_.corrn; corrn = estim_params_.corrn;
for i=1:length(parameter_names) for i=1:length(parameter_names)
name = parameter_names{i}; name = parameter_names{i};
k1 = strmatch(name,param_names,'exact'); k1 = strmatch(name, param_names, 'exact');
if ~isempty(k1) if ~isempty(k1)
k2 = find(param_vals(:,1) == k1); k2 = find(param_vals(:,1) == k1);
if ~isempty(k2) if ~isempty(k2)
@ -64,7 +64,7 @@ for i=1:length(parameter_names)
M_.Sigma_e(k1,k1) = xparam1(i)^2; M_.Sigma_e(k1,k1) = xparam1(i)^2;
continue continue
end end
k1 = strmatch(name,endo_names,'exact'); k1 = strmatch(name, endo_names, 'exact');
if ~isempty(k1) if ~isempty(k1)
k2 = find(var_endo(:,1) == k1); k2 = find(var_endo(:,1) == k1);
if ~isempty(k2) if ~isempty(k2)
@ -85,8 +85,8 @@ for i=1:length(parameter_names)
M_.Sigma_e(k1a,k1) = M_.Sigma_e(k1,k1a); M_.Sigma_e(k1a,k1) = M_.Sigma_e(k1,k1a);
continue continue
end end
k1 = strmatch(name(1:k3-1),endo_names,'exact'); k1 = strmatch(name(1:k3-1), endo_names, 'exact');
k1a = strmatch(name(k3+1:end),endo_names,'exact'); k1a = strmatch(name(k3+1:end), endo_names, 'exact');
if ~isempty(k1) && ~isempty(k1a) if ~isempty(k1) && ~isempty(k1a)
k2 = find(corrn(:,1) == k1 & corrn(:,2) == k1a); k2 = find(corrn(:,1) == k1 & corrn(:,2) == k1a);
if ~isempty(k2) if ~isempty(k2)

View File

@ -13,7 +13,7 @@ function initvalf(fname_)
% All variables local to this function have an underscore appended to % All variables local to this function have an underscore appended to
% their name, to minimize clashes with model variables loaded by this function. % their name, to minimize clashes with model variables loaded by this function.
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -73,36 +73,36 @@ options_.initval_file = 1;
oo_.endo_simul = []; oo_.endo_simul = [];
oo_.exo_simul = []; oo_.exo_simul = [];
for i_=1:size(M_.endo_names,1) for i_=1:length(M_.endo_names)
if series_ == 1 if series_ == 1
x_ = eval(M_.endo_names(i_,:)); x_ = eval(M_.endo_names{i_});
if size(x_,2)>size(x_,1) %oo_.endo_simul must be collection of row vectors if size(x_,2)>size(x_,1) %oo_.endo_simul must be collection of row vectors
oo_.endo_simul = [oo_.endo_simul; x_]; oo_.endo_simul = [oo_.endo_simul; x_];
else %transpose if column vector else %transpose if column vector
oo_.endo_simul = [oo_.endo_simul; x_']; oo_.endo_simul = [oo_.endo_simul; x_'];
end end
else else
k_ = strmatch(deblank(M_.endo_names(i_,:)),names_v_,'exact'); k_ = strmatch(M_.endo_names{i_}, names_v_, 'exact');
if isempty(k_) if isempty(k_)
error(['INITVAL_FILE: ' deblank(M_.endo_names(i_,:)) ' not found']) error(['INITVAL_FILE: ' M_.endo_names{i_} ' not found'])
end end
x_ = data_(:,k_); x_ = data_(:,k_);
oo_.endo_simul = [oo_.endo_simul; x_']; oo_.endo_simul = [oo_.endo_simul; x_'];
end end
end end
for i_=1:size(M_.exo_names,1) for i_=1:length(M_.exo_names)
if series_ == 1 if series_ == 1
x_ = eval(M_.exo_names(i_,:) ); x_ = eval(M_.exo_names{i_});
if size(x_,2)>size(x_,1) %oo_.endo_simul must be collection of row vectors if size(x_,2)>size(x_,1) %oo_.endo_simul must be collection of row vectors
oo_.exo_simul = [oo_.exo_simul x_']; oo_.exo_simul = [oo_.exo_simul x_'];
else %if column vector else %if column vector
oo_.exo_simul = [oo_.exo_simul x_]; oo_.exo_simul = [oo_.exo_simul x_];
end end
else else
k_ = strmatch(deblank(M_.exo_names(i_,:)),names_v_,'exact'); k_ = strmatch(M_.exo_names{i_}, names_v_, 'exact');
if isempty(k_) if isempty(k_)
error(['INITVAL_FILE: ' deblank(M_.exo_names(i_,:)) ' not found']) error(['INITVAL_FILE: ' M_.exo_names{i_} ' not found'])
end end
x_ = data_(:,k_); x_ = data_(:,k_);
oo_.exo_simul = [oo_.exo_simul x_]; oo_.exo_simul = [oo_.exo_simul x_];

View File

@ -1,7 +1,7 @@
function [dr,info] = k_order_pert(dr,M,options) function [dr,info] = k_order_pert(dr,M,options)
% Compute decision rules using the k-order DLL from Dynare++ % Compute decision rules using the k-order DLL from Dynare++
% Copyright (C) 2009-2017 Dynare Team % Copyright (C) 2009-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -20,7 +20,12 @@ function [dr,info] = k_order_pert(dr,M,options)
info = 0; info = 0;
M.var_order_endo_names = M.endo_names(dr.order_var,:); M.var_order_endo_names = M.endo_names(dr.order_var);
% k_order_perturbation expects char array for the names of endogenous and
% exogenous variables (not cells). The mex needs to be fixed...
M.var_order_endo_names = char(M.var_order_endo_names);
M.exo_names = char(M.exo_names);
order = options.order; order = options.order;
endo_nbr = M.endo_nbr; endo_nbr = M.endo_nbr;

View File

@ -12,7 +12,7 @@ function [lb,ub,eq_index] = get_complementarity_conditions(M,ramsey_policy)
% from complementarity setup used in % from complementarity setup used in
% perfect_foresight_mcp_problem.m % perfect_foresight_mcp_problem.m
% Copyright (C) 2014-2017 Dynare Team % Copyright (C) 2014-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -58,7 +58,7 @@ for i=1:size(etags,1)
str = etags{i,3}; str = etags{i,3};
kop = strfind(etags{i,3},'<'); kop = strfind(etags{i,3},'<');
if ~isempty(kop) if ~isempty(kop)
k = find(strcmp(strtrim(str(1:kop-1)),cellstr(M.endo_names))); %get variable index with restriction k = find(strcmp(strtrim(str(1:kop-1)), M.endo_names)); %get variable index with restriction
if isempty(k) if isempty(k)
error(sprintf(['Complementarity condition %s: variable %s is ' ... error(sprintf(['Complementarity condition %s: variable %s is ' ...
'not recognized'],etags{i,3},strtrim(str(1:kop-1)))) 'not recognized'],etags{i,3},strtrim(str(1:kop-1))))
@ -69,7 +69,7 @@ for i=1:size(etags,1)
else else
kop = strfind(etags{i,3},'>'); kop = strfind(etags{i,3},'>');
if ~isempty(kop) if ~isempty(kop)
k = find(strcmp(strtrim(str(1:kop-1)),cellstr(M.endo_names))); %get variable index with restriction k = find(strcmp(strtrim(str(1:kop-1)), M.endo_names)); %get variable index with restriction
if isempty(k) if isempty(k)
error(sprintf(['Complementarity condition %s: variable %s is ' ... error(sprintf(['Complementarity condition %s: variable %s is ' ...
'not recognized'],etags{i,3},strtrim(str(1:kop-1)))) 'not recognized'],etags{i,3},strtrim(str(1:kop-1))))

View File

@ -24,7 +24,7 @@ function [x,f,fvec,check]=lnsrch1(xold, fold, g, p, stpmax, func, j1, j2, tolx,
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2001-2017 Dynare Team % Copyright (C) 2001-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -58,14 +58,14 @@ if ~isfinite(summ)
var_string=[]; var_string=[];
Model=evalin('base','M_'); Model=evalin('base','M_');
for ii=1:length(j2)-1 for ii=1:length(j2)-1
var_string=[var_string, deblank(Model.endo_names(j2(ii),:)), ', ']; var_string=[var_string, Model.endo_names{j2(ii)}, ', '];
end end
var_string=[var_string, deblank(Model.endo_names(j2(end),:))]; var_string=[var_string, Model.endo_names{j2(end)}];
fprintf('\nAn infinite element was encountered when trying to solve equation(s) %s \n',eq_number_string) fprintf('\nAn infinite element was encountered when trying to solve equation(s) %s \n',eq_number_string)
fprintf('with respect to the variable(s): %s.\n',var_string) fprintf('with respect to the variable(s): %s.\n',var_string)
fprintf('The values of the endogenous variables when the problem was encountered were:\n') fprintf('The values of the endogenous variables when the problem was encountered were:\n')
for ii=1:length(xold) for ii=1:length(xold)
fprintf('%-s % 8.4g \n',Model.endo_names(ii,:),xold(ii)); fprintf('%-s % 8.4g \n', Model.endo_names{ii}, xold(ii));
end end
skipline(); skipline();
end end

View File

@ -1,6 +1,6 @@
function data = load_mat_file_data_legacy(datafile, varobs) function data = load_mat_file_data_legacy(datafile, varobs)
% Copyright (C) 2017 Dynare Team % Copyright (C) 2017-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -32,9 +32,9 @@ else
data_mat=[]; data_mat=[];
for var_iter=1:length(varobs) for var_iter=1:length(varobs)
try try
data_mat=[data_mat vec(data_file.(varobs{1,var_iter}))]; data_mat=[data_mat vec(data_file.(varobs{var_iter}))];
catch catch
error('makedataset: The variable %s does not have dimensions conformable with the previous one',varobs{1,var_iter}); error(['makedataset: The variable %s does not have dimensions conformable with the previous one'], varobs{var_iter});
end end
end end
end end

View File

@ -15,7 +15,7 @@ function [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_, bay
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2005-2017 Dynare Team % Copyright (C) 2005-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -167,7 +167,7 @@ if nvx
ip = 1; ip = 1;
for i=1:nvx for i=1:nvx
k = estim_params_.var_exo(i,1); k = estim_params_.var_exo(i,1);
name = deblank(M_.exo_names(k,:)); name = M_.exo_names{k};
eval(['oo_.' field_name '_mode.shocks_std.' name ' = xparam1(ip);']); eval(['oo_.' field_name '_mode.shocks_std.' name ' = xparam1(ip);']);
eval(['oo_.' field_name '_std_at_mode.shocks_std.' name ' = stdh(ip);']); eval(['oo_.' field_name '_std_at_mode.shocks_std.' name ' = stdh(ip);']);
ip = ip+1; ip = ip+1;
@ -188,7 +188,7 @@ if ncx
for i=1:ncx for i=1:ncx
k1 = estim_params_.corrx(i,1); k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2); k2 = estim_params_.corrx(i,2);
NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))]; NAME = [M_.exo_names{k1} '_' M_.exo_names{k2}];
eval(['oo_.' field_name '_mode.shocks_corr.' NAME ' = xparam1(ip);']); eval(['oo_.' field_name '_mode.shocks_corr.' NAME ' = xparam1(ip);']);
eval(['oo_.' field_name '_std_at_mode.shocks_corr.' NAME ' = stdh(ip);']); eval(['oo_.' field_name '_std_at_mode.shocks_corr.' NAME ' = stdh(ip);']);
ip = ip+1; ip = ip+1;
@ -200,7 +200,7 @@ if ncn
for i=1:ncn for i=1:ncn
k1 = estim_params_.corrn(i,1); k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2); k2 = estim_params_.corrn(i,2);
NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))]; NAME = [M_.endo_names{k1} '_' M_.endo_names{k2}];
eval(['oo_.' field_name '_mode.measurement_errors_corr.' NAME ' = xparam1(ip);']); eval(['oo_.' field_name '_mode.measurement_errors_corr.' NAME ' = xparam1(ip);']);
eval(['oo_.' field_name '_std_at_mode.measurement_errors_corr.' NAME ' = stdh(ip);']); eval(['oo_.' field_name '_std_at_mode.measurement_errors_corr.' NAME ' = stdh(ip);']);
ip = ip+1; ip = ip+1;

View File

@ -20,7 +20,7 @@ function oo = model_comparison(ModelNames,ModelPriors,oo,options_,fname)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2007-2017 Dynare Team % Copyright (C) 2007-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -114,42 +114,36 @@ lmpd = log(ModelPriors)+MarginalLogDensity;
elmpd = exp(lmpd-maxval); elmpd = exp(lmpd-maxval);
% Now I display the posterior probabilities. % Now I display the posterior probabilities.
headers = char('Model',ShortModelNames{:}); headers = vertcat('Model', ShortModelNames);
if prior_flag if prior_flag
labels = char('Priors','Log Marginal Density','Bayes Ratio', ... labels = {'Priors'; 'Log Marginal Density'; 'Bayes Ratio'; 'Posterior Model Probability'};
'Posterior Model Probability'); field_labels={'Prior','Log_Marginal_Density','Bayes_Ratio', 'Posterior_Model_Probability'};
field_labels={'Prior','Log_Marginal_Density','Bayes_Ratio', ... values = [ModelPriors';MarginalLogDensity';exp(lmpd-lmpd(1))'; elmpd'/sum(elmpd)];
'Posterior_Model_Probability'};
values = [ModelPriors';MarginalLogDensity';exp(lmpd-lmpd(1))'; ...
elmpd'/sum(elmpd)];
else else
labels = char('Priors','Log Marginal Density','Bayes Ratio','Posterior Odds Ratio', ... labels = {'Priors'; 'Log Marginal Density'; 'Bayes Ratio'; 'Posterior Odds Ratio'; 'Posterior Model Probability'};
'Posterior Model Probability');
field_labels={'Prior','Log_Marginal_Density','Bayes_Ratio','Posterior_Odds_Ratio','Posterior_Model_Probability'}; field_labels={'Prior','Log_Marginal_Density','Bayes_Ratio','Posterior_Odds_Ratio','Posterior_Model_Probability'};
values = [ModelPriors';MarginalLogDensity'; exp(MarginalLogDensity-MarginalLogDensity(1))'; ... values = [ModelPriors';MarginalLogDensity'; exp(MarginalLogDensity-MarginalLogDensity(1))'; exp(lmpd-lmpd(1))'; elmpd'/sum(elmpd)];
exp(lmpd-lmpd(1))'; elmpd'/sum(elmpd)];
end end
for model_iter=1:NumberOfModels for model_iter = 1:NumberOfModels
for var_iter=1:size(labels,1) for var_iter = 1:length(labels)
oo.Model_Comparison.(deblank(headers(1+model_iter,:))).(field_labels{var_iter})=values(var_iter,model_iter); oo.Model_Comparison.(headers{1+model_iter}).(field_labels{var_iter}) = values(var_iter, model_iter);
end end
end end
dyntable(options_,title,headers,labels,values, 0, 15, 6); dyntable(options_, title, headers, labels, values, 0, 15, 6);
if options_.TeX if options_.TeX
M_temp.fname=fname; M_temp.fname = fname;
M_temp.dname=fname; M_temp.dname = fname;
headers_tex=''; headers_tex = {};
for ii=1:size(headers,1) for ii = 1:length(headers)
headers_tex=strvcat(headers_tex,strrep(headers(ii,:),'_', '\_')); headers_tex = vertcat(headers_tex, strrep(headers{ii}, '_', '\_'));
end end
labels_tex=''; labels_tex = {};
for ii=1:size(labels,1) for ii = 1:length(labels)
labels_tex=strvcat(labels_tex,strrep(labels(ii,:),' ', '\ ')); labels_tex = vertcat(labels_tex, strrep(labels{ii},' ', '\ '));
end end
dyn_latex_table(M_temp, options_, title, ['model_comparison', type], headers_tex, labels_tex, values, 0, 16, 6);
dyn_latex_table(M_temp,options_,title,['model_comparison',type],headers_tex,labels_tex,values,0,16,6);
end end
function name = get_model_name_without_path(modelname) function name = get_model_name_without_path(modelname)
@ -178,9 +172,9 @@ name = modelname(1:end-4);
function modellist = get_short_names(modelnames) function modellist = get_short_names(modelnames)
n = length(modelnames); n = length(modelnames);
modellist = {}; modellist = cell(n, 1);
for i=1:n for i=1:n
name = get_model_name_without_extension(modelnames{i}); name = get_model_name_without_extension(modelnames{i});
name = get_model_name_without_path(name); name = get_model_name_without_path(name);
modellist = {modellist{:} name}; modellist(i) = {name};
end end

View File

@ -16,7 +16,7 @@ function model_diagnostics(M,options,oo)
% none. % none.
% %
% Copyright (C) 1996-2017 Dynare Team % Copyright (C) 1996-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -50,7 +50,7 @@ if ~isempty(k)
disp(['MODEL_DIAGNOSTICS: The following endogenous variables aren''t present at ' ... disp(['MODEL_DIAGNOSTICS: The following endogenous variables aren''t present at ' ...
'the current period in the model:']) 'the current period in the model:'])
for i=1:length(k) for i=1:length(k)
disp(endo_names(k(i),:)) disp(endo_names{k(i)})
end end
end end
@ -154,7 +154,7 @@ for b=1:nb
break break
end end
end end
disp(endo_names(k,:)) disp(endo_names{k})
end end
neq = null(jacob'); neq = null(jacob');
n_rel = size(neq,2); n_rel = size(neq,2);

View File

@ -1,7 +1,7 @@
function model_info(varargin) function model_info(varargin)
%function model_info; %function model_info;
% Copyright (C) 2008-2017 Dynare Team % Copyright (C) 2008-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -57,9 +57,9 @@ if(isfield(M_,block_structre_str))
end end
for j=1:size_block for j=1:size_block
if(j==1) if(j==1)
fprintf('| %10d | %10d | %30s | %14d | %-6d %24s |\n',i,size_block,Sym_type(block_structure.block(i).Simulation_Type),block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names(block_structure.block(i).variable(j),:)); fprintf('| %10d | %10d | %30s | %14d | %-6d %24s |\n',i,size_block,Sym_type(block_structure.block(i).Simulation_Type),block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names{block_structure.block(i).variable(j)});
else else
fprintf('| %10s | %10s | %30s | %14d | %-6d %24s |\n','','','',block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names(block_structure.block(i).variable(j),:)); fprintf('| %10s | %10s | %30s | %14d | %-6d %24s |\n','','','',block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names{block_structure.block(i).variable(j)});
end end
end end
end end
@ -76,7 +76,7 @@ if(isfield(M_,block_structre_str))
last=99999999; last=99999999;
for i=1:size_IM for i=1:size_IM
if(last~=IM(i,2)) if(last~=IM(i,2))
fprintf('\n%-30s',M_.endo_names(IM(i,2),:)); fprintf('\n%-30s',M_.endo_names{IM(i,2)});
end end
fprintf(' %5d',IM(i,1)); fprintf(' %5d',IM(i,1));
last=IM(i,2); last=IM(i,2);
@ -100,7 +100,7 @@ if(isfield(M_,block_structre_str))
last=99999999; last=99999999;
for i=1:size_IM for i=1:size_IM
if(last~=IM(i,2)) if(last~=IM(i,2))
fprintf('\n%-30s',M_.endo_names(IM(i,2),:)); fprintf('\n%-30s',M_.endo_names{IM(i,2)});
end end
fprintf(' %5d',IM(i,1)); fprintf(' %5d',IM(i,1));
last=IM(i,2); last=IM(i,2);
@ -122,16 +122,16 @@ if(isfield(M_,block_structre_str))
end end
end end
seq = 1: M_.endo_nbr; seq = 1: M_.endo_nbr;
blank = [ blanks(size(M_.endo_names,2)); blanks(size(M_.endo_names,2))]; blank = [ blanks(cellofchararraymaxlength(M_.endo_names)); blanks(cellofchararraymaxlength(M_.endo_names))];
for i = 1:M_.endo_nbr for i = 1:M_.endo_nbr
if i == 1 if i == 1
var_names = [blank; M_.endo_names(i,:)]; var_names = char(blank, M_.endo_names{i});
else else
var_names = [var_names; blank; M_.endo_names(i,:)]; var_names = char(var_names, blank, M_.endo_names{i});
end end
end end
if incidence if incidence
topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(size(M_.endo_names,2),1))) var_names' ]; topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(cellofchararraymaxlength(M_.endo_names),1))) var_names' ];
bott = [int2str(seq') blanks(M_.endo_nbr)' blanks(M_.endo_nbr)' IM_star]; bott = [int2str(seq') blanks(M_.endo_nbr)' blanks(M_.endo_nbr)' IM_star];
fprintf('\n Gross incidence matrix\n'); fprintf('\n Gross incidence matrix\n');
fprintf(' =======================\n'); fprintf(' =======================\n');
@ -141,7 +141,7 @@ if(isfield(M_,block_structre_str))
IM_star_reordered = char([kron(ones(M_.endo_nbr, M_.endo_nbr-1), double(blanks(3))) double(blanks(M_.endo_nbr)')]); IM_star_reordered = char([kron(ones(M_.endo_nbr, M_.endo_nbr-1), double(blanks(3))) double(blanks(M_.endo_nbr)')]);
eq(block_structure.equation_reordered) = seq; eq(block_structure.equation_reordered) = seq;
va(block_structure.variable_reordered) = seq; va(block_structure.variable_reordered) = seq;
barre_blank = [ barre(size(M_.endo_names,2)); blanks(size(M_.endo_names,2))]; barre_blank = [ barre(cellofchararraymaxlength(M_.endo_names)); blanks(cellofchararraymaxlength(M_.endo_names))];
cur_block = 1; cur_block = 1;
for i = 1:M_.endo_nbr for i = 1:M_.endo_nbr
past_block = cur_block; past_block = cur_block;
@ -149,16 +149,16 @@ if(isfield(M_,block_structre_str))
cur_block = cur_block + 1; cur_block = cur_block + 1;
end end
if i == 1 if i == 1
var_names = [blank; M_.endo_names(block_structure.variable_reordered(i),:)]; var_names = [blank; M_.endo_names{block_structure.variable_reordered(i)}];
else else
if past_block ~= cur_block if past_block ~= cur_block
var_names = [var_names; barre_blank; M_.endo_names(block_structure.variable_reordered(i),:)]; var_names = [var_names; barre_blank; M_.endo_names{block_structure.variable_reordered(i)}];
else else
var_names = [var_names; blank; M_.endo_names(block_structure.variable_reordered(i),:)]; var_names = [var_names; blank; M_.endo_names{block_structure.variable_reordered(i)}];
end end
end end
end end
topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(size(M_.endo_names,2),1))) var_names' ]; topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(cellofchararraymaxlength(M_.endo_names),1))) var_names' ];
n_state_var = length(M_.state_var); n_state_var = length(M_.state_var);
IM_state_var = zeros(n_state_var, n_state_var); IM_state_var = zeros(n_state_var, n_state_var);
inv_variable_reordered(block_structure.variable_reordered) = 1:M_.endo_nbr; inv_variable_reordered(block_structure.variable_reordered) = 1:M_.endo_nbr;

View File

@ -15,7 +15,7 @@ function [endogenousvariables, exogenousvariables] = model_inversion(constraints
% %
% REMARKS % REMARKS
% Copyright (C) 2017 Dynare Team % Copyright (C) 2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -69,8 +69,8 @@ if exogenousvariables.vobs>constraints.vobs
end end
% Get the list of endogenous and exogenous variables. % Get the list of endogenous and exogenous variables.
endo_names = cellstr(DynareModel.endo_names); endo_names = DynareModel.endo_names;
exo_names = cellstr(DynareModel.exo_names); exo_names = DynareModel.exo_names;
% Use specidalized routine if the model is backward looking. % Use specidalized routine if the model is backward looking.
if ~DynareModel.maximum_lead if ~DynareModel.maximum_lead

@ -1 +1 @@
Subproject commit dfa40f0b7506cfdee02c69c33eeb26180a22e76f Subproject commit 53d1e479c4e568ce1fda6b52efa202fa32fedefa

View File

@ -15,7 +15,7 @@ function plot_ms_forecast(M_, options_, forecast, figure_name)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2011-2017 Dynare Team % Copyright (C) 2011-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -36,18 +36,18 @@ nc = 2;
nr = 2; nr = 2;
nvars = M_.endo_nbr; nvars = M_.endo_nbr;
endo_names = M_.endo_names; endo_names = M_.endo_names;
var_list = endo_names(1:M_.orig_endo_nbr,:); var_list = endo_names(1:M_.orig_endo_nbr);
names = {}; names = {};
tex_names = {}; tex_names = {};
m = 1; m = 1;
for i = 1:size(var_list) for i = 1:length(var_list)
tmp = strmatch(var_list(i,:),endo_names,'exact'); tmp = strmatch(var_list{i}, endo_names, 'exact');
if isempty(tmp) if isempty(tmp)
error([var_list(i,:) ' isn''t and endogenous variable']) error([var_list{i} ' isn''t and endogenous variable'])
end end
tex_name = deblank(M_.endo_names_tex(i,:)); tex_name = M_.endo_names_tex{i};
if ~isempty(tex_name) if ~isempty(tex_name)
names{m} = deblank(var_list(i,:)); names{m} = var_list{i};
tex_names{m} = tex_name; tex_names{m} = tex_name;
m = m + 1; m = m + 1;
end end
@ -98,7 +98,7 @@ for j=1:nvars
m = 1; m = 1;
end end
subplot(nr,nc,m); subplot(nr,nc,m);
vn = deblank(endo_names(j,:)); vn = endo_names{j};
plot(forecast(:,j)) plot(forecast(:,j))
title(vn,'Interpreter','none'); title(vn,'Interpreter','none');
grid on; grid on;
@ -130,7 +130,7 @@ for j=1:nvars
m = 1; m = 1;
end end
subplot(nr,nc,m); subplot(nr,nc,m);
vn = deblank(endo_names(j,:)); vn = endo_names{j};
for k=1:num_percentiles for k=1:num_percentiles
if ceil(num_percentiles/2) == k if ceil(num_percentiles/2) == k
plot(forecast(k,:,j),'LineWidth',1.5) plot(forecast(k,:,j),'LineWidth',1.5)

View File

@ -15,7 +15,7 @@ function plot_ms_irf(M_, options_, irf, figure_name, varlist)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2011-2017 Dynare Team % Copyright (C) 2011-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -40,29 +40,29 @@ nvars = M_.endo_nbr;
endo_names = M_.endo_names; endo_names = M_.endo_names;
if isempty(varlist) if isempty(varlist)
var_list = endo_names(1:M_.orig_endo_nbr,:); var_list = endo_names(1:M_.orig_endo_nbr);
end end
names = {}; names = {};
tex_names = {}; tex_names = {};
m = 1; m = 1;
for i = 1:size(var_list) for i = 1:length(var_list)
tmp = strmatch(var_list(i,:),endo_names,'exact'); tmp = strmatch(var_list{i}, endo_names, 'exact');
if isempty(tmp) if isempty(tmp)
error([var_list(i,:) ' isn''t and endogenous variable']) error([var_list{i} ' isn''t and endogenous variable'])
end end
tex_name = deblank(M_.endo_names_tex(tmp,:)); tex_name = M_.endo_names_tex{tmp};
if ~isempty(tex_name) if ~isempty(tex_name)
names{m} = deblank(var_list(i,:)); names{m} = var_list{i};
tex_names{m} = tex_name; tex_names{m} = tex_name;
m = m + 1; m = m + 1;
end end
end end
for i=1:M_.exo_nbr for i=1:M_.exo_nbr
tex_name = deblank(M_.exo_names_tex(i,:)); tex_name = M_.exo_names_tex{i};
if ~isempty(tex_name) if ~isempty(tex_name)
names{m} = deblank(M_.exo_names(i,:)); names{m} = M_.exo_names{i};
tex_names{m} = tex_name; tex_names{m} = tex_name;
m = m + 1; m = m + 1;
end end
@ -81,7 +81,7 @@ else
error('The impulse response matrix passed to be plotted does not appear to be the correct size'); error('The impulse response matrix passed to be plotted does not appear to be the correct size');
end end
if size(endo_names,1) ~= nvars if length(endo_names) ~= nvars
error('The names passed are not the same length as the number of variables'); error('The names passed are not the same length as the number of variables');
end end
@ -92,7 +92,7 @@ if num_percentiles == 1
for i=1:nvars for i=1:nvars
shock(:,i) = irf(:,((i-1) + ((s-1)*nvars)+1)); shock(:,i) = irf(:,((i-1) + ((s-1)*nvars)+1));
end end
plot_point_irf_for_shock(shock, nvars,endo_names, deblank(endo_names(s,:)), ... plot_point_irf_for_shock(shock, nvars,endo_names, endo_names{s}, ...
figure_name, [options_.ms.output_file_tag filesep 'Output' filesep 'IRF'], options_, names, tex_names); figure_name, [options_.ms.output_file_tag filesep 'Output' filesep 'IRF'], options_, names, tex_names);
end end
else else
@ -103,7 +103,7 @@ else
shock(:,i,n) = irf(n,:,((i-1) + ((s-1)*nvars)+1)); shock(:,i,n) = irf(n,:,((i-1) + ((s-1)*nvars)+1));
end end
end end
plot_banded_irf_for_shock(shock, nvars,endo_names, deblank(endo_names(s,:)), ... plot_banded_irf_for_shock(shock, nvars,endo_names, endo_names{s}, ...
figure_name, [options_.ms.output_file_tag filesep 'Output' filesep 'IRF'], options_, names, tex_names); figure_name, [options_.ms.output_file_tag filesep 'Output' filesep 'IRF'], options_, names, tex_names);
end end
end end
@ -114,8 +114,8 @@ fig = figure('Name',figure_name);
for k=1:nvars for k=1:nvars
subplot(ceil(sqrt(nvars)), ceil(sqrt(nvars)),k); subplot(ceil(sqrt(nvars)), ceil(sqrt(nvars)),k);
plot(irf(:,k)) plot(irf(:,k))
disp([endo_names(k,:) ' shock from ' shock_name]); disp([endo_names{k} ' shock from ' shock_name]);
title([endo_names(k,:) ' shock from ' shock_name]); title([endo_names{k} ' shock from ' shock_name]);
end end
dyn_save_graph(dirname,[figure_name ' ' shock_name],options_.graph_save_formats, ... dyn_save_graph(dirname,[figure_name ' ' shock_name],options_.graph_save_formats, ...
options_.TeX,names,tex_names,[figure_name ' ' shock_name]); options_.TeX,names,tex_names,[figure_name ' ' shock_name]);
@ -131,8 +131,8 @@ for k=1:nvars
hold on hold on
end end
hold off hold off
disp([endo_names(k,:) ' shock from ' shock_name]); disp([endo_names{k} ' shock from ' shock_name]);
title([endo_names(k,:) ' shock from ' shock_name]); title([endo_names{k} ' shock from ' shock_name]);
end end
dyn_save_graph(dirname,[figure_name ' ' shock_name],options_.graph_save_formats, ... dyn_save_graph(dirname,[figure_name ' ' shock_name],options_.graph_save_formats, ...
options_.TeX,names,tex_names,[figure_name ' ' shock_name]); options_.TeX,names,tex_names,[figure_name ' ' shock_name]);

View File

@ -22,7 +22,7 @@ function plot_ms_variance_decomposition(M_, options_, vd, figure_name, varargin)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2011-2017 Dynare Team % Copyright (C) 2011-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -51,9 +51,9 @@ names = {};
tex_names = {}; tex_names = {};
m = 1; m = 1;
for i=1:M_.orig_endo_nbr for i=1:M_.orig_endo_nbr
tex_name = deblank(M_.endo_names_tex(i,:)); tex_name = M_.endo_names_tex{i};
if ~isempty(tex_name) if ~isempty(tex_name)
names{m} = deblank(endo_names(i,:)); names{m} = endo_names{i};
tex_names{m} = tex_name; tex_names{m} = tex_name;
m = m + 1; m = m + 1;
end end
@ -79,8 +79,8 @@ else
end end
for i=1:nvars for i=1:nvars
shock_names{i} = endo_names(i,:); shock_names{i} = endo_names{i};
series_names{i} = endo_names(i,:); series_names{i} = endo_names{i};
end end
x = [1:T]; x = [1:T];

View File

@ -15,7 +15,7 @@ function plot_ms_variance_decomposition_error_bands(M_, options_, vddata, figure
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2011-2017 Dynare Team % Copyright (C) 2011-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -34,28 +34,28 @@ function plot_ms_variance_decomposition_error_bands(M_, options_, vddata, figure
nvars = M_.endo_nbr; nvars = M_.endo_nbr;
endo_names = M_.endo_names; endo_names = M_.endo_names;
var_list = endo_names(1:M_.orig_endo_nbr,:); var_list = endo_names(1:M_.orig_endo_nbr);
names = {}; names = {};
tex_names = {}; tex_names = {};
m = 1; m = 1;
for i = 1:size(var_list) for i = 1:length(var_list)
tmp = strmatch(var_list(i,:), endo_names, 'exact'); tmp = strmatch(var_list{i}, endo_names, 'exact');
if isempty(tmp) if isempty(tmp)
error([var_list(i,:) ' isn''t an endogenous variable']) error([var_list{i} ' isn''t an endogenous variable'])
end end
tex_name = deblank(M_.endo_names_tex(tmp,:)); tex_name = M_.endo_names_tex{tmp};
if ~isempty(tex_name) if ~isempty(tex_name)
names{m} = deblank(var_list(i,:)); names{m} = var_list{i};
tex_names{m} = tex_name; tex_names{m} = tex_name;
m = m + 1; m = m + 1;
end end
end end
for i=1:M_.exo_nbr for i=1:M_.exo_nbr
tex_name = deblank(M_.exo_names_tex(i,:)); tex_name = M_.exo_names_tex{i};
if ~isempty(tex_name) if ~isempty(tex_name)
names{m} = deblank(M_.exo_names(i,:)); names{m} = M_.exo_names{i};
tex_names{m} = tex_name; tex_names{m} = tex_name;
m = m + 1; m = m + 1;
end end
@ -67,7 +67,7 @@ if length(dims) ~= 3
end end
num_percentiles = dims(1); num_percentiles = dims(1);
if size(endo_names, 1) ~= nvars if length(endo_names) ~= nvars
error('The names passed are not the same length as the number of variables') error('The names passed are not the same length as the number of variables')
end end
@ -79,7 +79,7 @@ for s=1:nvars
end end
end end
plot_banded_vddata_for_shock(shock, nvars, endo_names, ... plot_banded_vddata_for_shock(shock, nvars, endo_names, ...
deblank(endo_names(s,:)), figure_name, ... endo_names{s}, figure_name, ...
[options_.ms.output_file_tag filesep 'Output' filesep 'Variance_Decomposition'], ... [options_.ms.output_file_tag filesep 'Output' filesep 'Variance_Decomposition'], ...
options_, names, tex_names); options_, names, tex_names);
end end
@ -96,8 +96,8 @@ for k=1:nvars
hold on hold on
end end
hold off hold off
disp([endo_names(k,:) ' contribution to ' shock_name]); disp([endo_names{k} ' contribution to ' shock_name]);
title([endo_names(k,:) ' contribution to ' shock_name]); title([endo_names{k} ' contribution to ' shock_name]);
end end
dyn_save_graph(dirname, [figure_name ' ' shock_name], ... dyn_save_graph(dirname, [figure_name ' ' shock_name], ...
options_.graph_save_formats, options_.TeX, names, tex_names, ... options_.graph_save_formats, options_.TeX, names, tex_names, ...

View File

@ -12,7 +12,7 @@ function dr=mult_elimination(varlist,M_, options_, oo_)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2017 Dynare Team % Copyright (C) 2003-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -34,7 +34,7 @@ dr = oo_.dr;
nstatic = M_.nstatic; nstatic = M_.nstatic;
nspred = M_.nspred; nspred = M_.nspred;
order_var = dr.order_var; order_var = dr.order_var;
nstates = M_.endo_names(order_var(nstatic+(1:nspred)),:); nstates = M_.endo_names(order_var(nstatic+(1:nspred)));
il = strmatch('MULT_',nstates); il = strmatch('MULT_',nstates);
nil = setdiff(1:nspred,il); nil = setdiff(1:nspred,il);
@ -103,10 +103,10 @@ nvar = length(varlist);
if nvar > 0 && options_.noprint == 0 if nvar > 0 && options_.noprint == 0
res_table = zeros(2*(nm_nbr+M_.exo_nbr),nvar); res_table = zeros(2*(nm_nbr+M_.exo_nbr),nvar);
headers = 'Variables'; headers = {'Variables'};
for i=1:length(varlist) for i=1:length(varlist)
k = strmatch(varlist{i},M_.endo_names(dr.order_var,:),'exact'); k = strmatch(varlist{i}, M_.endo_names(dr.order_var), 'exact');
headers = char(headers,varlist{i}); headers = vertcat(headers, varlist{i});
res_table(1:nm_nbr,i) = M1(k,:)'; res_table(1:nm_nbr,i) = M1(k,:)';
res_table(nm_nbr+(1:nm_nbr),i) = M2(k,:)'; res_table(nm_nbr+(1:nm_nbr),i) = M2(k,:)';
@ -115,19 +115,12 @@ if nvar > 0 && options_.noprint == 0
end end
my_title='ELIMINATION OF THE MULTIPLIERS'; my_title='ELIMINATION OF THE MULTIPLIERS';
lab = nstates(nil,:); lab = nstates(nil);
labels = strcat(deblank(lab(i,:)),'(-1)'); labels = cellfun(@(x) horzcat(x, '(-1)'), nstates(nil), 'UniformOutput', false);
for i = 2:size(lab,1) labels = vertcat(labels, cellfun(@(x) horzcat(x, '(-2)'), nstates(nil), 'UniformOutput', false));
labels = char(labels,strcat(deblank(lab(i,:)),'(-1)')); labels = vertcat(labels, M_.exo_names);
end labels = vertcat(labels, cellfun(@(x) horzcat(x, '(-1)'), M_.exo_names, 'UniformOutput', false));
for i = 1:size(lab,1)
labels = char(labels,strcat(deblank(lab(i,:)),'(-2)'));
end
labels = char(labels,M_.exo_names);
for i = 1:M_.exo_nbr
labels = char(labels,strcat(deblank(M_.exo_names(i,:)),'(-1)'));
end
lh = size(labels,2)+2; lh = size(labels,2)+2;
dyntable(options_,my_title,headers,labels,res_table,lh,10,6); dyntable(options_, my_title, headers, labels, res_table, lh, 10, 6);
skipline() skipline()
end end

View File

@ -16,7 +16,7 @@ function i = name2index(options_, M_, estim_params_, type, name1, name2 )
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2008-2017 Dynare Team % Copyright (C) 2008-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -44,7 +44,7 @@ i = [];
if strcmpi(type,'DeepParameter') if strcmpi(type,'DeepParameter')
i = nvx + nvn + ncx + ncn + ... i = nvx + nvn + ncx + ncn + ...
strmatch(name1,M_.param_names(estim_params_.param_vals(:,1),:),'exact'); strmatch(name1, M_.param_names(estim_params_.param_vals(:,1)), 'exact');
if nargin>5 if nargin>5
disp('The last input argument is useless!') disp('The last input argument is useless!')
end end
@ -56,7 +56,7 @@ end
if strcmpi(type,'StructuralShock') if strcmpi(type,'StructuralShock')
if nargin<6% Covariance matrix diagonal term. if nargin<6% Covariance matrix diagonal term.
i = strmatch(name1,M_.exo_names(estim_params_.var_exo(:,1),:),'exact'); i = strmatch(name1, M_.exo_names(estim_params_.var_exo(:,1)), 'exact');
if isempty(i) if isempty(i)
disp(['The standard deviation of ' name1 ' is not an estimated parameter!']) disp(['The standard deviation of ' name1 ' is not an estimated parameter!'])
return return
@ -64,14 +64,14 @@ if strcmpi(type,'StructuralShock')
else% Covariance matrix off-diagonal term else% Covariance matrix off-diagonal term
offset = nvx+nvn; offset = nvx+nvn;
try try
list_of_structural_shocks = { M_.exo_names(estim_params_.corrx(:,1),:) , M_.exo_names(estim_params_.corrx(:,2),:) }; list_of_structural_shocks = [ M_.exo_names(estim_params_.corrx(:,1)) , M_.exo_names(estim_params_.corrx(:,2)) ];
k1 = strmatch(name1,list_of_structural_shocks(:,1),'exact'); k1 = strmatch(name1, list_of_structural_shocks(:,1), 'exact');
k2 = strmatch(name2,list_of_structural_shocks(:,2),'exact'); k2 = strmatch(name2, list_of_structural_shocks(:,2), 'exact');
i = offset+intersect(k1,k2); i = offset+intersect(k1,k2);
if isempty(i) if isempty(i)
k1 = strmatch(name1,list_of_structural_shocks(:,2),'exact'); k1 = strmatch(name1, list_of_structural_shocks(:,2), 'exact');
k2 = strmatch(name2,list_of_structural_shocks(:,1),'exact'); k2 = strmatch(name2, list_of_structural_shocks(:,1), 'exact');
i = offset+intersect(k1,k2); i = offset+intersect(k1, k2);
end end
if isempty(i) if isempty(i)
if isempty(i) if isempty(i)
@ -87,7 +87,7 @@ end
if strcmpi(type,'MeasurementError') if strcmpi(type,'MeasurementError')
if nargin<6% Covariance matrix diagonal term if nargin<6% Covariance matrix diagonal term
i = nvx + strmatch(name1,M_.endo_names(estim_params_.var_endo(:,1),:),'exact'); i = nvx + strmatch(name1, M_.endo_names{estim_params_.var_endo(:,1)}, 'exact');
if isempty(i) if isempty(i)
disp(['The standard deviation of the measurement error on ' name1 ' is not an estimated parameter!']) disp(['The standard deviation of the measurement error on ' name1 ' is not an estimated parameter!'])
return return
@ -95,7 +95,7 @@ if strcmpi(type,'MeasurementError')
else% Covariance matrix off-diagonal term else% Covariance matrix off-diagonal term
offset = nvx+nvn+ncx; offset = nvx+nvn+ncx;
try try
list_of_measurement_errors = { M_.endo_names(estim_params_.corrn(:,1),:) , M_.endo_names(estim_params_.corrn(:,2),:) }; list_of_measurement_errors = { M_.endo_names{estim_params_.corrn(:,1)} , M_.endo_names{estim_params_.corrn(:,2)} };
k1 = strmatch(name1,list_of_measurement_errors(:,1),'exact'); k1 = strmatch(name1,list_of_measurement_errors(:,1),'exact');
k2 = strmatch(name2,list_of_measurement_errors(:,2),'exact'); k2 = strmatch(name2,list_of_measurement_errors(:,2),'exact');
i = offset+intersect(k1,k2); i = offset+intersect(k1,k2);

View File

@ -8,14 +8,14 @@
% unpack the IRFs % unpack the IRFs
for i=1:Mbase_.endo_nbr for i=1:Mbase_.endo_nbr
eval([deblank(Mbase_.endo_names(i,:)),'_uncdifference=zdatalinear(:,i);']); eval([Mbase_.endo_names{i}, '_uncdifference=zdatalinear(:,i);']);
eval([deblank(Mbase_.endo_names(i,:)),'_difference=zdatapiecewise(:,i);']); eval([Mbase_.endo_names{i}, '_difference=zdatapiecewise(:,i);']);
eval([deblank(Mbase_.endo_names(i,:)),'_ss=zdatass(i);']); eval([Mbase_.endo_names{i}, '_ss=zdatass(i);']);
end end
nparams = size(Mbase_.param_names,1); nparams = length(Mbase_.param_names);
for i = 1:nparams for i = 1:nparams
eval([Mbase_.param_names(i,:),'= Mbase_.params(i);']); eval([Mbase_.param_names{i}, '= Mbase_.params(i);']);
end end

View File

@ -6,16 +6,16 @@
for i=1:Mbase_.endo_nbr for i=1:Mbase_.endo_nbr
eval([deblank(Mbase_.endo_names(i,:)),'_uncdifference=zdatalinear(:,i);']); eval([Mbase_.endo_names{i}, '_uncdifference=zdatalinear(:,i);']);
eval([deblank(Mbase_.endo_names(i,:)),'_difference=zdatapiecewise(:,i);']); eval([Mbase_.endo_names{i}, '_difference=zdatapiecewise(:,i);']);
eval([deblank(Mbase_.endo_names(i,:)),'_ss=zdatass(i);']); eval([Mbase_.endo_names{i}, '_ss=zdatass(i);']);
end end
constraint1_difference = process_constraint(constraint1,'_difference',Mbase_.endo_names,0); constraint1_difference = process_constraint(constraint1, '_difference', Mbase_.endo_names,0);
constraint2_difference = process_constraint(constraint2,'_difference',Mbase_.endo_names,0); constraint2_difference = process_constraint(constraint2, '_difference', Mbase_.endo_names,0);
nparams = size(Mbase_.param_names,1); nparams = length(Mbase_.param_names);
for i = 1:nparams for i = 1:nparams
eval([Mbase_.param_names(i,:),'= Mbase_.params(i);']); eval([Mbase_.param_names{i}, '= Mbase_.params(i);']);
end end

Some files were not shown because too many files have changed in this diff Show More