Compare commits

...

18 Commits

Author SHA1 Message Date
Stéphane Adjemian (Guts) 0ce32f3367
[WIP] Error takes sprintf like arguments directly. 2023-12-16 10:05:41 +01:00
Stéphane Adjemian (Guts) 23af7f64b6
Avoid using disp(sprintf()) constructs. 2023-12-15 18:56:08 +01:00
Stéphane Adjemian (Guts) 0249ea2116
Fix bug introduced in #47af0cde1. 2023-12-15 18:07:12 +01:00
Stéphane Adjemian (Guts) 44119077db
Separate outputs with commas. 2023-12-15 16:55:24 +01:00
Stéphane Adjemian (Guts) 47af0cde16
Remove calls to eval. 2023-12-15 16:34:27 +01:00
Sébastien Villemot eb043406e6
Merge branch 'path' of git.dynare.org:JohannesPfeifer/dynare
Ref. !2233
2023-12-15 16:32:08 +01:00
Sébastien Villemot ae082cffbe
Make function names consistent with filenames
Detected and automatically fixed by MATLAB Code Analyzer app.
2023-12-15 16:30:32 +01:00
Sébastien Villemot febd39713e
dseries: more fixes performed with MATLAB Code Analyzer app 2023-12-15 16:28:38 +01:00
Sébastien Villemot 20b2c79ffb
Remove unneeded uses of feval
Detected and automatically fixed by MATLAB Code Analyzer app.
2023-12-15 16:28:38 +01:00
Sébastien Villemot 458926b17b
Remove useless semicolons
Detected and automatically fixed by MATLAB Code Analyzer app.
2023-12-15 16:28:36 +01:00
Sébastien Villemot 162ca815bc
Replace calls to isdir by isfolder
isfolder is the modern replacement to isdir, and is available in MATLAB ⩾
R2017b and in Octave ⩾ 7.

Detected and automatically fixed by MATLAB Code Analyzer app.
2023-12-15 15:40:25 +01:00
Sébastien Villemot ff7cc9267e
Remove useless commas
Detected and automatically fixed by MATLAB Code Analyzer app.
2023-12-15 15:37:35 +01:00
Sébastien Villemot 56e97e29aa
dseries: various fixes performed with MATLAB Code Analyzer app 2023-12-15 15:31:52 +01:00
Sébastien Villemot adddcf6197
minus_logged_prior_density.m: fix syntax error with output arguments
It’s not possible to use tildes for declaration of output arguments (otherwise
these arguments will be uninitialized if requested).

Detected by MATLAB Code Analyzer app.
2023-12-15 15:31:52 +01:00
Sébastien Villemot 79959aa587
Remove duplicate branches in if/then/else statements
Detected by MATLAB Code Analyzer app.
2023-12-15 15:31:52 +01:00
Sébastien Villemot a0bafbcb95
Remove duplicate case value
Detected by MATLAB Code Analyzer app.
2023-12-15 15:31:52 +01:00
Sébastien Villemot 2005f292e5
Fix syntax error
Detected by MATLAB Code Analyzer app.
2023-12-15 15:31:52 +01:00
Johannes Pfeifer 3e7291b573 dynare_config.m: remove paths eliminated due to namespaces 2023-12-15 13:12:39 +01:00
51 changed files with 155 additions and 182 deletions

View File

@ -151,7 +151,7 @@ Comment: The original author gave authorization to change
Files: matlab/+pruned_SS/prodmom.m matlab/+pruned_SS/bivmom.m Files: matlab/+pruned_SS/prodmom.m matlab/+pruned_SS/bivmom.m
Copyright: 2008-2015 Raymond Kan <kan@chass.utoronto.ca> Copyright: 2008-2015 Raymond Kan <kan@chass.utoronto.ca>
2019-2020 Dynare Team 2019-2023 Dynare Team
License: GPL-3+ License: GPL-3+
Comment: The author gave authorization to redistribute Comment: The author gave authorization to redistribute
these functions under GPL-3+ with Dynare and would these functions under GPL-3+ with Dynare and would
@ -242,7 +242,7 @@ License: BSD-2-clause
Files: matlab/utilities/graphics/colorspace.m Files: matlab/utilities/graphics/colorspace.m
Copyright: 2005-2010 Pascal Getreuer Copyright: 2005-2010 Pascal Getreuer
2017 Dynare Team 2017-2023 Dynare Team
License: BSD-2-clause License: BSD-2-clause
Files: examples/fs2000_data.m Files: examples/fs2000_data.m

View File

@ -154,8 +154,8 @@ end
% Store results % Store results
DirectoryName = [ M_.dname '/bvar_forecast' ]; DirectoryName = [ M_.dname '/bvar_forecast' ];
if ~isdir(DirectoryName) if ~isfolder(DirectoryName)
if ~isdir(M_.dname) if ~isfolder(M_.dname)
mkdir(M_.dname); mkdir(M_.dname);
end end
mkdir(DirectoryName); mkdir(DirectoryName);

View File

@ -1,5 +1,5 @@
function dyn_graph=dynare_graph_init(figure_name,nplot,line_types,line_width) function dyn_graph=graph_init(figure_name,nplot,line_types,line_width)
% function dynare_graph_init(figure_name,colors) % function graph_init(figure_name,colors)
% initializes set of graphs % initializes set of graphs
% %
% INPUTS: % INPUTS:
@ -12,7 +12,7 @@ function dyn_graph=dynare_graph_init(figure_name,nplot,line_types,line_width)
% SPECIAL REQUIREMENT % SPECIAL REQUIREMENT
% none % none
% Copyright © 2006-2017 Dynare Team % Copyright © 2006-2023 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %

View File

@ -130,7 +130,7 @@ end
% Save intermediate results % Save intermediate results
DirectoryName = [ M_.dname '/bvar_irf' ]; DirectoryName = [ M_.dname '/bvar_irf' ];
if ~isdir(DirectoryName) if ~isfolder(DirectoryName)
mkdir('.',DirectoryName); mkdir('.',DirectoryName);
end end
save([ DirectoryName '/simulations.mat'], 'sampled_irfs'); save([ DirectoryName '/simulations.mat'], 'sampled_irfs');
@ -146,4 +146,4 @@ for i=1:ny
oo_.bvar.irf.Upper_bound.(variable_name).(shock_name) = posterior_up_conf_irfs(j,i,:); oo_.bvar.irf.Upper_bound.(variable_name).(shock_name) = posterior_up_conf_irfs(j,i,:);
oo_.bvar.irf.Lower_bound.(variable_name).(shock_name) = posterior_down_conf_irfs(j,i,:); oo_.bvar.irf.Lower_bound.(variable_name).(shock_name) = posterior_down_conf_irfs(j,i,:);
end end
end end

View File

@ -1,5 +1,5 @@
function [ny, nx, posterior, prior, forecast_data] = bvar_toolbox(nlags) function [ny, nx, posterior, prior, forecast_data] = toolbox(nlags)
%function [ny, nx, posterior, prior, forecast_data] = bvar_toolbox(nlags) %function [ny, nx, posterior, prior, forecast_data] = toolbox(nlags)
% bvar_toolbox Routines shared between BVAR methods % bvar_toolbox Routines shared between BVAR methods
% Computes several things for the estimations of a BVAR(nlags) % Computes several things for the estimations of a BVAR(nlags)
% %
@ -42,7 +42,7 @@ function [ny, nx, posterior, prior, forecast_data] = bvar_toolbox(nlags)
% - bvar_prior_{tau,decay,lambda,mu,omega,flat,train} % - bvar_prior_{tau,decay,lambda,mu,omega,flat,train}
% Copyright © 2003-2007 Christopher Sims % Copyright © 2003-2007 Christopher Sims
% Copyright © 2007-2017 Dynare Team % Copyright © 2007-2023 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %

View File

@ -1,5 +1,5 @@
function [pars, cosnJ] = ident_bruteforce(dname,fname,J, max_dim_cova_group, TeX, name_tex, tittxt, tol_deriv) function [pars, cosnJ] = bruteforce(dname,fname,J, max_dim_cova_group, TeX, name_tex, tittxt, tol_deriv)
% [pars, cosnJ] = ident_bruteforce(dname,fname,J, max_dim_cova_group, TeX, name_tex, tittxt, tol_deriv) % [pars, cosnJ] = bruteforce(dname,fname,J, max_dim_cova_group, TeX, name_tex, tittxt, tol_deriv)
% ------------------------------------------------------------------------- % -------------------------------------------------------------------------
% given the Jacobian matrix J of moment derivatives w.r.t. parameters % given the Jacobian matrix J of moment derivatives w.r.t. parameters
% computes, for each column of J, the groups of columns from 1 to n that % computes, for each column of J, the groups of columns from 1 to n that

View File

@ -78,14 +78,14 @@ end
Counter(0); Counter(0);
switch L1ops switch L1ops
case {'==' '='}, case {'==' '='}
if isnan(MaxCounter) if isnan(MaxCounter)
% return the number of solutions % return the number of solutions
v = nchoosek(n+L1-1,L1); % nchoosek(n+L1-1,n-1) v = nchoosek(n+L1-1,L1); % nchoosek(n+L1-1,n-1)
else else
v = allVL1eq(n, L1); v = allVL1eq(n, L1);
end end
case '<=', % call allVL1eq for various sum targets case '<=' % call allVL1eq for various sum targets
if isnan(MaxCounter) if isnan(MaxCounter)
% return the number of solutions % return the number of solutions
%v = nchoosek(n+L1,L1)*factorial(n-L1); BUG <- 16/Sep/2009: %v = nchoosek(n+L1,L1)*factorial(n-L1); BUG <- 16/Sep/2009:
@ -99,7 +99,7 @@ switch L1ops
v = cell2mat(arrayfun(@(j) allVL1eq(n, j), (0:L1)', ... v = cell2mat(arrayfun(@(j) allVL1eq(n, j), (0:L1)', ...
'UniformOutput', false)); 'UniformOutput', false));
end end
case '<', case '<'
v = allVL1(n, L1-1, '<=', MaxCounter); v = allVL1(n, L1-1, '<=', MaxCounter);
otherwise otherwise
error('allVL1: unknown L1ops') error('allVL1: unknown L1ops')

View File

@ -21,7 +21,7 @@
% Multivariate Analysis, 2008, vol. 99, issue 3, pages 542-554. % Multivariate Analysis, 2008, vol. 99, issue 3, pages 542-554.
% ========================================================================= % =========================================================================
% Copyright © 2008-2015 Raymond Kan <kan@chass.utoronto.ca> % Copyright © 2008-2015 Raymond Kan <kan@chass.utoronto.ca>
% Copyright © 2019-2020 Dynare Team % Copyright © 2019-2023 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -38,7 +38,7 @@
% 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 <https://www.gnu.org/licenses/>. % along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% ========================================================================= % =========================================================================
function y = prodmom(V,ii,nu); function y = prodmom(V,ii,nu)
if nargin<3 if nargin<3
nu = ones(size(ii)); nu = ones(size(ii));
end end
@ -104,4 +104,4 @@ for i=1:fix(prod(nu+1)/2)
end end
end end
end end
y = y/prod([1:s2]); y = y/prod([1:s2]);

View File

@ -33,7 +33,7 @@ info = 0;
DirectoryName = [ dname '/' type ]; % don't use filesep as it will create issues with LaTeX on Windows DirectoryName = [ dname '/' type ]; % don't use filesep as it will create issues with LaTeX on Windows
if ~isdir(dname) if ~isfolder(dname)
% Make sure there isn't a file with the same name, see trac ticket #47 % Make sure there isn't a file with the same name, see trac ticket #47
if isfile(dname) if isfile(dname)
delete(dname) delete(dname)
@ -41,7 +41,7 @@ if ~isdir(dname)
mkdir('.', dname); mkdir('.', dname);
end end
if ~isdir(DirectoryName) if ~isfolder(DirectoryName)
% Make sure there isn't a file with the same name, see trac ticket #47 % Make sure there isn't a file with the same name, see trac ticket #47
if isfile(DirectoryName) if isfile(DirectoryName)
delete(DirectoryName) delete(DirectoryName)

View File

@ -56,7 +56,8 @@ elseif NumberOfPlots == 1
end end
for plt = 1:NumberOfPlots for plt = 1:NumberOfPlots
eval(['NumberOfCurves = Info.Box' int2str(plt) '.Number;']) field1 = sprintf('Box%u', plt);
NumberOfCurves = Info.(field1).Number;
NumberOfObservations = zeros(2,1); NumberOfObservations = zeros(2,1);
x = cell(NumberOfCurves,1); x = cell(NumberOfCurves,1);
y = cell(NumberOfCurves,1); y = cell(NumberOfCurves,1);
@ -66,10 +67,11 @@ for plt = 1:NumberOfPlots
binf = NaN(NumberOfCurves,1); binf = NaN(NumberOfCurves,1);
bsup = NaN(NumberOfCurves,1); bsup = NaN(NumberOfCurves,1);
for curve = 1:NumberOfCurves for curve = 1:NumberOfCurves
eval(['x{' curve '} = Info.Box' int2str(plt) '.Curve' int2str(curve) '.xdata;']) field2 = sprintf('Curve%u', curve);
eval(['y{' curve '} = Info.Box' int2str(plt) '.Curve' int2str(curve) '.ydata;']) x{curve} = Info.(field1).(field2).xdata;
eval(['name = Info.Box' int2str(plt) '.Curve' int2str(curve) '.variablename;']) y{curve} = Info.(field1).(field2).ydata;
eval(['PltType{' curve '} = Info.Box' int2str(plt) '.Curve' int2str(curve) '.type']); name = Info.(field1).(field2).variablename;
PltType{curve} = Info.(field1).(field2).type;
if length(x{curve})-length(y{curve}) if length(x{curve})-length(y{curve})
disp('MakeFigure :: The number of observations in x doesn''t match with ') disp('MakeFigure :: The number of observations in x doesn''t match with ')
disp(['the number of observation in y for ' name ]) disp(['the number of observation in y for ' name ])
@ -90,9 +92,9 @@ for plt = 1:NumberOfPlots
if isnan(ymin(plt)) if isnan(ymin(plt))
ymin = 0; ymin = 0;
end end
eval(['NAMES{' int2str(plt) '} = Info.Box' int2str(plt) '.name;']) NAMES{plt} = Info.(field1).name;
if options_.TeX if options_.TeX
eval(['TeXNAMES{' int2str(plt) '} = Info.Box' int2str(plt) '.texname;']) TeXNAMES{plt} = Info.(field1).texname;
end end
subplot(nr,nc,plt) subplot(nr,nc,plt)
hold on hold on
@ -148,22 +150,24 @@ end
if Info.SaveFormat.Eps if Info.SaveFormat.Eps
if isempty(Info.SaveFormat.Name) if isempty(Info.SaveFormat.Name)
eval(['print -depsc2 ' M_.fname Info.SaveFormat.GenericName int2str(Info.SaveFormat.Number) '.eps']); print(sprintf('%s%s%u', M_.fname, Info.SaveFormat.GenericName, Info.SaveFormat.Number), '-depsc2')
else else
eval(['print -depsc2 ' M_.fname Info.SaveFormat.GenericName Info.SaveFormat.Name '.eps']); print(sprintf('%s%s%s', M_.fname, Info.SaveFormat.GenericName, Info.SaveFormat.Name), '-depsc2')
end end
end end
if Info.SaveFormat.Pdf && ~isoctave if Info.SaveFormat.Pdf && ~isoctave
if isempty(Info.SaveFormat.Name) if isempty(Info.SaveFormat.Name)
eval(['print -dpdf ' M_.fname Info.SaveFormat.GenericName int2str(Info.SaveFormat.Number)]); print(sprintf('%s%s%u', M_.fname, Info.SaveFormat.GenericName, Info.SaveFormat.Number), '-dpdf')
else else
eval(['print -dpdf ' M_.fname Info.SaveFormat.GenericName Info.SaveFormat.Name]); print(sprintf('%s%s%s', M_.fname, Info.SaveFormat.GenericName, Info.SaveFormat.Name), '-dpdf')
end end
end end
if Info.SaveFormat.Fig && ~isoctave if Info.SaveFormat.Fig && ~isoctave
if isempty(Info.SaveFormat.Name) if isempty(Info.SaveFormat.Name)
saveas(FigHandle,[M_.fname Info.SaveFormat.GenericName int2str(Info.SaveFormat.Number) '.fig']); saveas(FigHandle, sprintf('%s%s%u.fig', M_.fname, Info.SaveFormat.GenericName, Info.SaveFormat.Number));
else else
saveas(FigHandle,[M_.fname Info.SaveFormat.GenericName Info.SaveFormat.Name '.fig']); saveas(FigHandle, sprintf('%s%s%s.fig', M_.fname, Info.SaveFormat.GenericName, Info.SaveFormat.Name));
end end
end end

View File

@ -33,7 +33,7 @@ global M_
i = strmatch(pname,M_.param_names,'exact'); i = strmatch(pname,M_.param_names,'exact');
if isempty(i) if isempty(i)
error(sprintf('Can''t find parameter %s', pname)) error('Can''t find parameter %s', pname)
end end
x = M_.params(i); x = M_.params(i);

View File

@ -41,7 +41,7 @@ if options_.dsge_var && options_.bayesian_irf
for i=1:size(varlist,1) for i=1:size(varlist,1)
idx = strmatch(varlist{i}, options_.varobs, 'exact'); idx = strmatch(varlist{i}, options_.varobs, 'exact');
if isempty(idx) if isempty(idx)
disp(sprintf('%s is not an observed variable!', varlist{i})) dprintf('%s is not an observed variable!', varlist{i})
msg = true; msg = true;
end end
end end
@ -169,4 +169,4 @@ while ~isempty(remain)
end end
if index<max_number_of_words_per_line if index<max_number_of_words_per_line
disp(line_of_text) disp(line_of_text)
end end

View File

@ -103,6 +103,6 @@ for taper_index=1:length(taper_steps)
results_vec(1,4+taper_index*2-1)=NSE_taper; results_vec(1,4+taper_index*2-1)=NSE_taper;
results_vec(1,4+taper_index*2)=total_variance/(n_draws_used*NSE_taper^2); results_vec(1,4+taper_index*2)=total_variance/(n_draws_used*NSE_taper^2);
eval(['results_struct.nse_taper_',num2str(taper),'= NSE_taper;']); results_struct.(sprintf('nse_taper_%u', taper)) = NSE_taper;
eval(['results_struct.rne_taper_',num2str(taper),'= total_variance/(n_draws_used*NSE_taper^2);']); results_struct.(sprintf('rne_taper_%u', taper)) = total_variance/(n_draws_used*NSE_taper^2);
end % end of for mm loop end % end of for mm loop

View File

@ -48,7 +48,7 @@ function [H,G,retcode]=discretionary_policy_engine(AAlag,AA0,AAlead,BB,bigw,inst
% Dennis, Richard (2007): Optimal policy in rational expectations models: new solution algorithms, % Dennis, Richard (2007): Optimal policy in rational expectations models: new solution algorithms,
% Macroeconomic Dynamics, 11, 31–55. % Macroeconomic Dynamics, 11, 31–55.
% Copyright © 2007-2018 Dynare Team % Copyright © 2007-2023 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -189,7 +189,7 @@ function [rcode,NQ]=CheckConvergence(Q,iter,MaxIter,crit)
NQ=max(max(abs(Q)));% norm(Q); seems too costly NQ=max(max(abs(Q)));% norm(Q); seems too costly
if isnan(NQ) if isnan(NQ)
rcode=3; rcode=3;
elseif iter>MaxIter; elseif iter>MaxIter
rcode=2; rcode=2;
elseif NQ<crit elseif NQ<crit
rcode=1; rcode=1;

View File

@ -94,7 +94,7 @@ try
for i=1:n_shapes for i=1:n_shapes
for j=1:n_scales for j=1:n_scales
if debug if debug
disp(sprintf('... mu=%s and s2=%s', num2str(mu(j,i)),num2str(s2(j,i)))) dprintf('... mu=%s and s2=%s', num2str(mu(j,i)),num2str(s2(j,i)))
end end
if ~isnan(mu(j,i)) && ~isnan(s2(j,i)) && ~isinf(mu(j,i)) && ~isinf(s2(j,i)) if ~isnan(mu(j,i)) && ~isnan(s2(j,i)) && ~isinf(mu(j,i)) && ~isinf(s2(j,i))
[shape, scale] = weibull_specification(mu(j,i), s2(j,i)); [shape, scale] = weibull_specification(mu(j,i), s2(j,i));

View File

@ -47,7 +47,6 @@ p = {'/../contrib/ms-sbvar/TZcode/MatlabFiles/' ; ...
'/AIM/' ; ... '/AIM/' ; ...
'/backward/' ; ... '/backward/' ; ...
'/cli/' ; ... '/cli/' ; ...
'/conditional_forecasts/'; ...
'/convergence_diagnostics/' ; ... '/convergence_diagnostics/' ; ...
'/discretionary_policy/' ; ... '/discretionary_policy/' ; ...
'/distributions/' ; ... '/distributions/' ; ...
@ -55,7 +54,6 @@ p = {'/../contrib/ms-sbvar/TZcode/MatlabFiles/' ; ...
'/estimation/'; ... '/estimation/'; ...
'/estimation/smc/'; ... '/estimation/smc/'; ...
'/estimation/resampler/'; ... '/estimation/resampler/'; ...
'/gsa/' ; ...
'/kalman/' ; ... '/kalman/' ; ...
'/kalman/likelihood' ; ... '/kalman/likelihood' ; ...
'/latex/' ; ... '/latex/' ; ...

View File

@ -54,7 +54,7 @@ if ismember(method, [1, 2])
flag = ~flag; flag = ~flag;
end end
if debug if debug
disp(sprintf('%s\t %1.8f\t %s',int2str(iteration),weight,int2str(flag))) dprintf('%u\t %1.8f\t %u', iteration, weight, flag)
end end
state(2:end) = state(1:end-1); state(2:end) = state(1:end-1);
state(1) = flag; state(1) = flag;
@ -121,7 +121,7 @@ if isequal(method, 3) || (isequal(method, 2) && noconvergence)
flag = ~flag; flag = ~flag;
end end
if debug if debug
disp(sprintf('%s\t %1.8f\t %s',int2str(index),weight,int2str(flag))) dprintf('%u\t %1.8f\t %u', index, weight, flag)
end end
if flag if flag
jndex = index; jndex = index;

View File

@ -119,11 +119,11 @@ if np
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),... dprintf(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 = M_.param_names_tex{k}; name = M_.param_names_tex{k};
@ -167,7 +167,7 @@ if nvx
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, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip))); dprintf(pformat, header_width, name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip));
if TeX if TeX
name = M_.exo_names_tex{k}; name = M_.exo_names_tex{k};
TeXCore(fid,name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval); TeXCore(fid,name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval);
@ -205,7 +205,7 @@ if nvn
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, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip))); dprintf(pformat, header_width, name,bayestopt_.p1(ip), post_mean, hpd_interval, 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 = M_.endo_names_tex{k}; name = M_.endo_names_tex{k};
@ -257,7 +257,7 @@ if ncx
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, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip))); dprintf(pformat, header_width,name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip));
if TeX if TeX
name = sprintf('(%s,%s)', M_.exo_names_tex{k1}, M_.exo_names_tex{k2}); name = sprintf('(%s,%s)', M_.exo_names_tex{k1}, M_.exo_names_tex{k2});
TeXCore(fid, name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval); TeXCore(fid, name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval);
@ -304,7 +304,7 @@ if ncn
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, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip))); dprintf(pformat, header_width, name, bayestopt_.p1(ip), post_mean, hpd_interval, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p2(ip));
if TeX if TeX
name = sprintf('(%s,%s)', M_.endo_names_tex{k1}, M_.endo_names_tex{k2}); name = sprintf('(%s,%s)', M_.endo_names_tex{k1}, M_.endo_names_tex{k2});
TeXCore(fid, name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval); TeXCore(fid, name, pnames{bayestopt_.pshape(ip)+1}, bayestopt_.p1(ip), bayestopt_.p2(ip), post_mean, sqrt(post_var), hpd_interval);

View File

@ -72,8 +72,8 @@ if np
fprintf('%-*s %10.4f %7.4f %7.4f \n', ... fprintf('%-*s %10.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);']); oo_.(sprintf('%s_mode', field_name)).parameters.(name) = xparam1(ip);
eval(['oo_.' field_name '_std_at_mode.parameters.' name ' = stdh(ip);']); oo_.(sprintf('%s_std_at_mode', field_name)).parameters.(name) = stdh(ip);
ip = ip+1; ip = ip+1;
end end
skipline() skipline()
@ -94,8 +94,8 @@ if nvx
fprintf('%-*s %10.4f %7.4f %7.4f \n', header_width, name, xparam1(ip), stdh(ip), tstath(ip)); fprintf('%-*s %10.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);']); oo_.(sprintf('%s_mode', field_name)).shocks_std.(name) = xparam1(ip);
eval(['oo_.' field_name '_std_at_mode.shocks_std.' name ' = stdh(ip);']); oo_.(sprintf('%s_std_at_mode', field_name)).shocks_std.(name) = stdh(ip);
ip = ip+1; ip = ip+1;
end end
skipline() skipline()
@ -116,8 +116,8 @@ if nvn
fprintf('%-*s %10.4f %7.4f %7.4f \n', header_width, name, xparam1(ip), ... fprintf('%-*s %10.4f %7.4f %7.4f \n', header_width, name, xparam1(ip), ...
stdh(ip), tstath(ip)) stdh(ip), tstath(ip))
end end
eval(['oo_.' field_name '_mode.measurement_errors_std.' name ' = xparam1(ip);']); oo_.(sprintf('%s_mode', field_name)).measurement_errors_std.(name) = xparam1(ip);
eval(['oo_.' field_name '_std_at_mode.measurement_errors_std.' name ' = stdh(ip);']); oo_.(sprintf('%s_std_at_mode', field_name)).measurement_errors_std.(name) = stdh(ip);
ip = ip+1; ip = ip+1;
end end
skipline() skipline()
@ -142,8 +142,8 @@ if ncx
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);
eval(['oo_.' field_name '_mode.shocks_corr.' NAME ' = xparam1(ip);']); oo_.(sprintf('%s_mode', field_name)).shocks_corr.(NAME) = xparam1(ip);
eval(['oo_.' field_name '_std_at_mode.shocks_corr.' NAME ' = stdh(ip);']); oo_.(sprintf('%s_std_at_mode', field_name)).shocks_corr.(NAME) = stdh(ip);
ip = ip+1; ip = ip+1;
end end
skipline() skipline()
@ -166,8 +166,8 @@ if ncn
fprintf('%-*s %10.4f %7.4f %7.4f \n',header_width, name, xparam1(ip), ... fprintf('%-*s %10.4f %7.4f %7.4f \n',header_width, name, xparam1(ip), ...
stdh(ip), tstath(ip)); stdh(ip), tstath(ip));
end end
eval(['oo_.' field_name '_mode.measurement_errors_corr.' NAME ' = xparam1(ip);']); oo_.(sprintf('%s_mode', field_name)).measurement_errors_corr.(NAME) = xparam1(ip);
eval(['oo_.' field_name '_std_at_mode.measurement_errors_corr.' NAME ' = stdh(ip);']); oo_.(sprintf('%s_std_at_mode', field_name)).measurement_errors_corr.(NAME) = stdh(ip);
ip = ip+1; ip = ip+1;
end end
skipline() skipline()
@ -407,4 +407,4 @@ function TeXEnd(fid)
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);

View File

@ -80,7 +80,7 @@ switch pshape(indx)
abscissa = linspace(infbound,supbound,steps); abscissa = linspace(infbound,supbound,steps);
dens = density(abscissa,p6(indx),p7(indx),p3(indx)); dens = density(abscissa,p6(indx),p7(indx),p3(indx));
otherwise otherwise
error(sprintf('draw_prior_density: unknown distribution shape (index %d, type %d)', indx, pshape(indx))); error('draw_prior_density: unknown distribution shape (index %d, type %d)', indx, pshape(indx));
end end
if pshape(indx) ~= 5 if pshape(indx) ~= 5
@ -88,9 +88,9 @@ if pshape(indx) ~= 5
if k1 == 1 || k1 == length(dens) if k1 == 1 || k1 == length(dens)
k = find(dens > 10); k = find(dens > 10);
dens(k) = NaN; dens(k) = NaN;
end
end end
end
binf = abscissa(1); binf = abscissa(1);
bsup = abscissa(end); bsup = abscissa(end);
x = abscissa; x = abscissa;
f = dens; f = dens;

View File

@ -373,7 +373,7 @@ if ~issmc(options_) && any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode
oo_.MarginalDensity.LaplaceApproximation = NaN; oo_.MarginalDensity.LaplaceApproximation = NaN;
end end
skipline() skipline()
disp(sprintf('Log data density [Laplace approximation] is %f.',oo_.MarginalDensity.LaplaceApproximation)) dprintf('Log data density [Laplace approximation] is %f.', oo_.MarginalDensity.LaplaceApproximation)
skipline() skipline()
end end
if options_.dsge_var if options_.dsge_var

View File

@ -54,7 +54,7 @@ function [xparams, lpd, hessian_mat] = ...
names, ... names, ...
[], ... [], ...
[], ... [], ...
Prior, Prior, ...
options_, ... options_, ...
M_, ... M_, ...
estim_params_, ... estim_params_, ...

View File

@ -1,4 +1,4 @@
function [fval, info, exitflag, ~, ~] = minus_logged_prior_density(xparams, Prior, options_, M_, estim_params_, oo_) function [fval, info, exitflag, fake1, fake2] = minus_logged_prior_density(xparams, Prior, options_, M_, estim_params_, oo_)
% Evaluates minus the logged prior density. % Evaluates minus the logged prior density.
% %
@ -33,6 +33,8 @@ function [fval, info, exitflag, ~, ~] = minus_logged_prior_density(xparams, Prio
exitflag = true; exitflag = true;
info = zeros(4,1); info = zeros(4,1);
fake1 = [];
fake2 = [];
%------------------------------------------------------------------------------ %------------------------------------------------------------------------------
% 1. Get the structural parameters & define penalties % 1. Get the structural parameters & define penalties

View File

@ -87,7 +87,7 @@ for i=1:NumberOfModels
end end
end end
try try
eval(['MarginalLogDensity(i) = mstruct.oo_.MarginalDensity.' type ';']) MarginalLogDensity(i) = mstruct.oo_.MarginalDensity.(type);
catch catch
if strcmpi(type,'LaplaceApproximation') if strcmpi(type,'LaplaceApproximation')
if isfield(mstruct.oo_,'mle_mode') if isfield(mstruct.oo_,'mle_mode')

View File

@ -125,7 +125,7 @@ switch posterior_sampling_method
% check whether draw is valid and compute posterior % check whether draw is valid and compute posterior
if all( proposed_par(:) > mh_bounds.lb(indices(blocks==block_iter,1),:) ) && all( proposed_par(:) < mh_bounds.ub(indices(blocks==block_iter,1),:) ) if all( proposed_par(:) > mh_bounds.lb(indices(blocks==block_iter,1),:) ) && all( proposed_par(:) < mh_bounds.ub(indices(blocks==block_iter,1),:) )
try try
logpost = - feval('TaRB_optimizer_wrapper', proposed_par(:),... logpost = - TaRB_optimizer_wrapper(proposed_par(:),...
current_draw,indices(blocks==block_iter,1),TargetFun,...% inputs for wrapper current_draw,indices(blocks==block_iter,1),TargetFun,...% inputs for wrapper
varargin{:}); varargin{:});
catch catch

View File

@ -36,24 +36,24 @@ function indx = get_new_or_existing_ei_index(substructure_name, name1, name2)
global estimation_info global estimation_info
if eval(['isempty(estimation_info.' substructure_name ')']) if isempty(estimation_info.(substructure_name))
indx = 1; indx = 1;
return return
end end
if isempty(name2) % parameter or std() statement if isempty(name2) % parameter or std() statement
indx = eval(['find(strcmp(name1, estimation_info.' substructure_name ') == 1)']); indx = find(strcmp(name1, estimation_info.(substructure_name)));
else % corr statement else % corr statement
indx = eval(['find(strcmp([''' name1 ':' name2 '''], estimation_info.' substructure_name ') == 1)']); indx = find(strcmp(sprintf('%s:%s', name1, name2), estimation_info.(substructure_name)));
if isempty(indx) if isempty(indx)
indx = eval(['find(strcmp([''' name2 ':' name1 '''], estimation_info.' substructure_name ') == 1)']); indx = find(strcmp(sprintf('%s:%s', name2, name1), estimation_info.(substructure_name)));
end end
end end
if isempty(indx) if isempty(indx)
indx = eval(['size(estimation_info.' substructure_name ', 2) + 1']); indx = size(estimation_info.(substructure_name), 2) + 1;
end end
if size(indx, 2) > 1 if size(indx, 2) > 1
error(['Error: ' name1 ' ' name2 'found more than once in estimation_info.subsamples_index']); error('Error: %s %s found more than once in estimation_info.subsamples_index', name1, name2);
end end

View File

@ -194,13 +194,10 @@ while notsteady && t<=last
end end
end end
if badly_conditioned_F if badly_conditioned_F
if ~all(abs(F(:))<kalman_tol) % if ~all(abs(F(:))<kalman_tol), then use univariate filter (will remove
% Use univariate filter (will remove observations with zero variance prediction error) % observations with zero variance prediction error), otherwise this is a
return % pathological case and the draw is discarded
else return
% Pathological case, discard draw.
return
end
else else
F_singular = false; F_singular = false;
if rescale_prediction_error_covariance if rescale_prediction_error_covariance

View File

@ -87,13 +87,9 @@ while rank(Z*Pinf*Z',diffuse_kalman_tol) && (t<=last)
else %rank of F_{\infty,t} is 0 else %rank of F_{\infty,t} is 0
Fstar = Z*Pstar*Z' + H; % (5.7) in DK (2012) Fstar = Z*Pstar*Z' + H; % (5.7) in DK (2012)
if rcond(Fstar) < kalman_tol %F_{*} is singular if rcond(Fstar) < kalman_tol %F_{*} is singular
if ~all(abs(Fstar(:))<kalman_tol) % if ~all(abs(Fstar(:))<kalman_tol), then use univariate diffuse filter,
% The univariate diffuse kalman filter should be used. % otherwise this is a pathological case and the draw is discarded
return return
else %rank 0
%pathological case, discard draw
return
end
else else
iFstar = inv(Fstar); iFstar = inv(Fstar);
dFstar = det(Fstar); dFstar = det(Fstar);

View File

@ -151,13 +151,9 @@ while notsteady && t<=last
v = Y(:,t)-a(Z); v = Y(:,t)-a(Z);
end end
if rcond(F) < kalman_tol if rcond(F) < kalman_tol
if ~all(abs(F(:))<kalman_tol) % if ~all(abs(F(:))<kalman_tol), then use univariate diffuse filter, otherwise
% The univariate diffuse kalman filter should be used. % this is a pathological case and the draw is discarded
return return
else
%pathological case, discard draw
return
end
else else
F_singular = 0; F_singular = 0;
dF = det(F); dF = det(F);

View File

@ -191,13 +191,9 @@ while notsteady && t<=last
end end
end end
if badly_conditioned_F && (~occbin_.status || (occbin_.status && t<first_period_occbin_update)) if badly_conditioned_F && (~occbin_.status || (occbin_.status && t<first_period_occbin_update))
if ~all(abs(F(:))<kalman_tol) % if ~all(abs(F(:))<kalman_tol), then use univariate filter, otherwise this is a
% Use univariate filter. % pathological case and the draw is discarded
return return
else
% Pathological case, discard draw
return
end
else else
F_singular = false; F_singular = false;
end end

View File

@ -105,13 +105,9 @@ while rank(Pinf,diffuse_kalman_tol) && (t<=last)
else %rank of F_{\infty,t} is 0 else %rank of F_{\infty,t} is 0
Fstar = ZZ*Pstar*ZZ' + H(d_index,d_index); % (5.7) in DK (2012) Fstar = ZZ*Pstar*ZZ' + H(d_index,d_index); % (5.7) in DK (2012)
if rcond(Fstar) < kalman_tol %F_{*} is singular if rcond(Fstar) < kalman_tol %F_{*} is singular
if ~all(abs(Fstar(:))<kalman_tol) % if ~all(abs(Fstar(:))<kalman_tol), then use univariate diffuse filter,
% The univariate diffuse kalman filter should be used. % otherwise this is a pathological case and the draw is discarded
return return
else %rank 0
%pathological case, discard draw
return
end
else else
iFstar = inv(Fstar); iFstar = inv(Fstar);
dFstar = det(Fstar); dFstar = det(Fstar);

View File

@ -57,8 +57,7 @@ for i=1:size(etags,1)
if ~isempty(kop) if ~isempty(kop)
k = find(strcmp(strtrim(str(1:kop-1)), 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('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))))
end end
ub(k) = str2num(str(kop+1:end)); ub(k) = str2num(str(kop+1:end));
eq_index(eq_nbr) = k; eq_index(eq_nbr) = k;
@ -68,15 +67,13 @@ for i=1:size(etags,1)
if ~isempty(kop) if ~isempty(kop)
k = find(strcmp(strtrim(str(1:kop-1)), 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('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))))
end end
lb(k) = str2num(str(kop+1:end)); lb(k) = str2num(str(kop+1:end));
eq_index(eq_nbr) = k; eq_index(eq_nbr) = k;
eq_index(k) = eq_nbr; eq_index(k) = eq_nbr;
else else
error(sprintf(['Complementarity condition %s can''t be ' ... error('Complementarity condition %s can''t be parsed',etags{i,3})
'parsed'],etags{i,3}))
end end
end end
end end

@ -1 +1 @@
Subproject commit a3874403fe5b403f74d727006cb4ccf198cf63c8 Subproject commit 8acb7f8d5f6418717a9ad47e6b6b911354a86409

View File

@ -130,7 +130,7 @@ for k=1:nvar
for draws = 1:ndraws1 for draws = 1:ndraws1
if ~mod(draws,nbuffer) if ~mod(draws,nbuffer)
skipline() skipline()
disp(sprintf('The %dth column or equation in A0 with %d 1st tossed-away draws in Gibbs',k,draws)) dprintf('The %dth column or equation in A0 with %d 1st tossed-away draws in Gibbs', k, draws)
end end
A0gbs1 = fn_gibbsrvar(A0gbs0,UT,nvar,fss,n0,indx_ks); A0gbs1 = fn_gibbsrvar(A0gbs0,UT,nvar,fss,n0,indx_ks);
A0gbs0=A0gbs1; % repeat the Gibbs sampling A0gbs0=A0gbs1; % repeat the Gibbs sampling
@ -141,7 +141,7 @@ for k=1:nvar
for draws = 1:ndraws2 for draws = 1:ndraws2
if ~mod(draws,nbuffer) if ~mod(draws,nbuffer)
skipline() skipline()
disp(sprintf('The %dth column or equation in A0 with %d usable draws in Gibbs',k,draws)) dprintf('The %dth column or equation in A0 with %d usable draws in Gibbs', k, draws)
end end
[A0gbs1, Wcell] = fn_gibbsrvar(A0gbs0,UT,nvar,fss,n0,indx_ks); [A0gbs1, Wcell] = fn_gibbsrvar(A0gbs0,UT,nvar,fss,n0,indx_ks);
%------ See p.71, Forecast (II). %------ See p.71, Forecast (II).
@ -163,7 +163,7 @@ for k=1:nvar
% The log value of p(a0_k|Y,a_others) where a_others: other a's at some point such as the peak of ONLY some a0's % The log value of p(a0_k|Y,a_others) where a_others: other a's at some point such as the peak of ONLY some a0's
else else
skipline() skipline()
disp(sprintf('The last(6th) column or equation in A0 with no Gibbs draws')) disp('The last(6th) column or equation in A0 with no Gibbs draws')
[A0gbs1, Wcell] = fn_gibbsrvar(A0gbs0,UT,nvar,fss,n0,indx_ks) [A0gbs1, Wcell] = fn_gibbsrvar(A0gbs0,UT,nvar,fss,n0,indx_ks)
%------ See p.71, Forecast (II). %------ See p.71, Forecast (II).
%------ Computing p(a0_k|Y,a_others) at some point such as the peak along the dimensions of indx_ks. %------ Computing p(a0_k|Y,a_others) at some point such as the peak along the dimensions of indx_ks.

View File

@ -1739,7 +1739,7 @@ while irun <= myeval(opts.Restarts) % for-loop does not work with resume
if N < 102 if N < 102
disp(['mean solution:' sprintf(' %+.1e', xmean)]); disp(['mean solution:' sprintf(' %+.1e', xmean)]);
disp(['std deviation:' sprintf(' %.1e', sigma*sqrt(diagC))]); disp(['std deviation:' sprintf(' %.1e', sigma*sqrt(diagC))]);
disp(sprintf('use plotcmaesdat.m for plotting the output at any time (option LogModulo must not be zero)')); dprintf('use plotcmaesdat.m for plotting the output at any time (option LogModulo must not be zero)');
end end
if exist('sfile', 'var') if exist('sfile', 'var')
disp(['Results saved in ' sfile]); disp(['Results saved in ' sfile]);
@ -1944,7 +1944,7 @@ end
% --------------------------------------------------------------- % ---------------------------------------------------------------
function flush function flush
if isoctave if isoctave
feval('fflush', stdout); fflush(stdout);
end end
% --------------------------------------------------------------- % ---------------------------------------------------------------
@ -2256,7 +2256,7 @@ ax(2) = max(minxend, ax(2));
axis(ax); axis(ax);
% add some annotation lines % add some annotation lines
[ignore idx] = sort(d.x(end,6:end)); [ignore, idx] = sort(d.x(end,6:end));
% choose no more than 25 indices % choose no more than 25 indices
idxs = round(linspace(1, size(d.x,2)-5, min(size(d.x,2)-5, 25))); idxs = round(linspace(1, size(d.x,2)-5, min(size(d.x,2)-5, 25)));
yy = repmat(NaN, 2, size(d.x,2)-5); yy = repmat(NaN, 2, size(d.x,2)-5);

View File

@ -384,19 +384,19 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
fval_(1:length(fval)) = fval; fval_(1:length(fval)) = fval;
if isfinite(fv(end)) && isfinite(fv(1)) if isfinite(fv(end)) && isfinite(fv(1))
if fv(end)<0 if fv(end)<0
disp(sprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move)) dprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move)
else else
if fv(1)>0 if fv(1)>0
disp(sprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move)) dprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move)
else else
disp(sprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move)) dprintf('%s %s %12.7E %12.7E %12.7E %12.7E %s', iter_, fval_, fv(1), fv(end), critF, critX, move)
end end
end end
else else
if isfinite(fv(1)) if isfinite(fv(1))
disp(sprintf(['%s %s %12.7E %12.7E %s'], iter_, fval_, fv(1) , critX, move)) dprintf(['%s %s %12.7E %12.7E %s'], iter_, fval_, fv(1) , critX, move)
else else
disp(sprintf('%s %s %12.7E %s', iter_, fval_, critX, move)) dprintf('%s %s %12.7E %s', iter_, fval_, critX, move)
end end
end end
end end
@ -551,4 +551,4 @@ for j = 1:n
end end
% Sort by increasing order of the objective function values. % Sort by increasing order of the objective function values.
[fv,sort_idx] = sort(fv); [fv,sort_idx] = sort(fv);
v = v(:,sort_idx); v = v(:,sort_idx);

View File

@ -264,7 +264,7 @@ while 1
if nITERATIONS == 0 if nITERATIONS == 0
disp(' Nr Iter Nr Fun Eval Min function Best function TEMP Algorithm Step'); disp(' Nr Iter Nr Fun Eval Min function Best function TEMP Algorithm Step');
else else
disp(sprintf('%5.0f %5.0f %12.6g %15.6g %12.6g %s',nITERATIONS,nFUN_EVALS,Y(1),YBEST,TEMP,'best point')); dprintf('%5.0f %5.0f %12.6g %15.6g %12.6g %s',nITERATIONS,nFUN_EVALS,Y(1),YBEST,TEMP,'best point');
end end
end end
@ -319,7 +319,7 @@ while 1
end end
if strcmp(OPTIONS.DISPLAY,'iter') if strcmp(OPTIONS.DISPLAY,'iter')
disp(sprintf('%5.0f %5.0f %12.6g %15.6g %12.6g %s',nITERATIONS,nFUN_EVALS,Y(1),YBEST,TEMP,ALGOSTEP)); dprintf('%5.0f %5.0f %12.6g %15.6g %12.6g %s',nITERATIONS,nFUN_EVALS,Y(1),YBEST,TEMP,ALGOSTEP);
end end
% if output function given then run output function to plot intermediate result % if output function given then run output function to plot intermediate result

View File

@ -175,12 +175,12 @@ for Node=1:length(DataInput) % To obtain a recursive function remove the 'for'
if Environment if Environment
if OScallerWindows if OScallerWindows
[si1 de1]=system(['ping ', DataInput(Node).ComputerName]); [si1, de1]=system(['ping ', DataInput(Node).ComputerName]);
else else
[si1 de1]=system(['ping ', DataInput(Node).ComputerName, ' -c 4']); [si1, de1]=system(['ping ', DataInput(Node).ComputerName, ' -c 4']);
end end
else else
[si1 de1]=system(['ping ', DataInput(Node).ComputerName]); [si1, de1]=system(['ping ', DataInput(Node).ComputerName]);
end end
if (si1) if (si1)
@ -387,15 +387,15 @@ for Node=1:length(DataInput) % To obtain a recursive function remove the 'for'
else else
if ~strcmp(DataInput(Node).ComputerName,MasterName) % run on remote machine if ~strcmp(DataInput(Node).ComputerName,MasterName) % run on remote machine
if strfind([DataInput(Node).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! if strfind([DataInput(Node).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
[NonServeS NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e -u ',DataInput(Node).UserName,' -p ',DataInput(Node).Password,' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low ',DataInput(Node).MatlabOctavePath,' Tracing.m']); [NonServeS, NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e -u ',DataInput(Node).UserName,' -p ',DataInput(Node).Password,' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low ',DataInput(Node).MatlabOctavePath,' Tracing.m']);
else else
[NonServeS NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e -u ',DataInput(Node).UserName,' -p ',DataInput(Node).Password,' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low ',DataInput(Node).MatlabOctavePath,' -nosplash -nodesktop -minimize -r Tracing']); [NonServeS, NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e -u ',DataInput(Node).UserName,' -p ',DataInput(Node).Password,' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low ',DataInput(Node).MatlabOctavePath,' -nosplash -nodesktop -minimize -r Tracing']);
end end
else % run on local machine via the network: user and passwd cannot be used! else % run on local machine via the network: user and passwd cannot be used!
if strfind([DataInput(Node).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! if strfind([DataInput(Node).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
[NonServeS NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e ',' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low ',DataInput(Node).MatlabOctavePath,' Tracing.m']); [NonServeS, NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e ',' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low ',DataInput(Node).MatlabOctavePath,' Tracing.m']);
else else
[NonServeS NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e ',' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low ',DataInput(Node).MatlabOctavePath,' -nosplash -nodesktop -minimize -r Tracing']); [NonServeS, NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e ',' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low ',DataInput(Node).MatlabOctavePath,' -nosplash -nodesktop -minimize -r Tracing']);
end end
end end
@ -570,7 +570,7 @@ for Node=1:length(DataInput) % To obtain a recursive function remove the 'for'
% Questo controllo penso che si possa MIGLIORARE!!!!! % Questo controllo penso che si possa MIGLIORARE!!!!!
if isempty (RealCPUnbr) && Environment1==0 if isempty (RealCPUnbr) && Environment1==0
[si0 de0]=system(['psinfo \\',DataInput(Node).ComputerName]); [si0, de0]=system(['psinfo \\',DataInput(Node).ComputerName]);
end end
RealCPUnbr=GiveCPUnumber(de0,Environment1); RealCPUnbr=GiveCPUnumber(de0,Environment1);

View File

@ -129,7 +129,7 @@ if SumOfJobs~=NumbersOfJobs
% Many choices are possible: % Many choices are possible:
% - ... (see above). % - ... (see above).
[NonServe VeryFast]= min(CPUWeight); [NonServe, VeryFast]= min(CPUWeight);
while SumOfJobs<NumbersOfJobs while SumOfJobs<NumbersOfJobs
JobsForNode(VeryFast)=JobsForNode(VeryFast)+1; JobsForNode(VeryFast)=JobsForNode(VeryFast)+1;

View File

@ -59,7 +59,7 @@ for indPC=1:length(Parallel)
if isoctave % Patch for peculiar behaviour of ls under Linux. if isoctave % Patch for peculiar behaviour of ls under Linux.
% It is necessary to capture the ls warning message and properly manage the jolly char '*'! % It is necessary to capture the ls warning message and properly manage the jolly char '*'!
[check ax]=system(['ls ' ,filename, ' 2> OctaveStandardOutputMessage.txt']); [check, ax]=system(['ls ' ,filename, ' 2> OctaveStandardOutputMessage.txt']);
if check ~= 0 || ~isempty(strfind(ax,'No such file or directory')) if check ~= 0 || ~isempty(strfind(ax,'No such file or directory'))
ax=[]; ax=[];

View File

@ -61,13 +61,13 @@ for indPC=1:length(Parallel)
if isempty (FindAst) if isempty (FindAst)
[NonServeL NonServeR]= system(['scp ',scp_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',NamFileInput{jfil,1}]); [NonServeL, NonServeR]= system(['scp ',scp_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',NamFileInput{jfil,1}]);
else else
filenameTemp=NamFileInput{jfil,2}; filenameTemp=NamFileInput{jfil,2};
[NotUsed FlI]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filenameTemp, ' 2> OctaveStandardOutputMessage.txt']); [NotUsed, FlI]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filenameTemp, ' 2> OctaveStandardOutputMessage.txt']);
if isempty (FlI) if isempty (FlI)
return return
@ -81,13 +81,13 @@ for indPC=1:length(Parallel)
for i=1: NumFileToCopy for i=1: NumFileToCopy
Ni=num2str(i); Ni=num2str(i);
filenameTemp(1,AstPos)=Ni; filenameTemp(1,AstPos)=Ni;
[NonServeL NonServeR]= system(['scp ',scp_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},filenameTemp,' ',NamFileInput{jfil,1}]); [NonServeL, NonServeR]= system(['scp ',scp_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},filenameTemp,' ',NamFileInput{jfil,1}]);
end end
end end
else else
[NonServeL NonServeR]= system(['scp ',scp_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',NamFileInput{jfil,1}]); [NonServeL, NonServeR]= system(['scp ',scp_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',NamFileInput{jfil,1}]);
end end
end end

View File

@ -710,11 +710,7 @@ if parallel_recover ==0
pcerdone(j) = prtfrc; pcerdone(j) = prtfrc;
idCPU(j) = njob; idCPU(j) = njob;
if isoctave || options_.console_mode if isoctave || options_.console_mode
if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)) statusString = [statusString, int2str(j), ' %3.f%% done! '];
statusString = [statusString, int2str(j), ' %3.f%% done! '];
else
statusString = [statusString, int2str(j), ' %3.f%% done! '];
end
else else
status_String{j} = waitbarString; status_String{j} = waitbarString;
status_Title{j} = waitbarTitle; status_Title{j} = waitbarTitle;
@ -722,11 +718,7 @@ if parallel_recover ==0
catch % ME catch % ME
% To define! % To define!
if isoctave || options_.console_mode if isoctave || options_.console_mode
if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)) statusString = [statusString, int2str(j), ' %3.f%% done! '];
statusString = [statusString, int2str(j), ' %3.f%% done! '];
else
statusString = [statusString, int2str(j), ' %3.f%% done! '];
end
end end
end end
end end
@ -901,7 +893,7 @@ switch Strategy
end end
if isempty(dir('dynareParallelLogFiles')) if isempty(dir('dynareParallelLogFiles'))
[A B C]=rmdir('dynareParallelLogFiles'); [A, B, C]=rmdir('dynareParallelLogFiles');
mkdir('dynareParallelLogFiles'); mkdir('dynareParallelLogFiles');
end end
try try
@ -919,7 +911,7 @@ switch Strategy
delete(['temp_input.mat']) delete(['temp_input.mat'])
if newInstance if newInstance
if isempty(dir('dynareParallelLogFiles')) if isempty(dir('dynareParallelLogFiles'))
[A B C]=rmdir('dynareParallelLogFiles'); [A, B, C]=rmdir('dynareParallelLogFiles');
mkdir('dynareParallelLogFiles'); mkdir('dynareParallelLogFiles');
end end
end end

View File

@ -31,14 +31,14 @@ function storeGlobalVars(fname,append)
GlobalNames = who('global'); GlobalNames = who('global');
% varlist = '';
for j=1:length(GlobalNames) for j=1:length(GlobalNames)
eval(['global ',GlobalNames{j},';']); eval(['global ',GlobalNames{j},';']);
eval(['fGlobalVar.',GlobalNames{j},'=',GlobalNames{j},';']); fGlobalvar.(GlobalNames{j}) = GlobalNames{j};
end end
if nargin<2 if nargin<2
save(fname,'fGlobalVar'); save(fname,'fGlobalVar');
else else
save(fname,'fGlobalVar','-append'); save(fname,'fGlobalVar','-append');
end end

View File

@ -76,7 +76,7 @@ try
warning('off','MATLAB:nearlySingularMatrix'); warning('off','MATLAB:nearlySingularMatrix');
warning('off','MATLAB:singularMatrix'); warning('off','MATLAB:singularMatrix');
UAVinv=inv(C2); % i.e. inv(U02'*a1*V02) UAVinv=inv(C2); % i.e. inv(U02'*a1*V02)
[LastWarningTxt LastWarningID]=lastwarn; [LastWarningTxt, LastWarningID]=lastwarn;
if any(any(isinf(UAVinv)))==1 if any(any(isinf(UAVinv)))==1
singular=1; singular=1;
end end
@ -178,9 +178,9 @@ G0pi=eye(n+FL_RANK+NX);
try try
if isoctave && octave_ver_less_than('9') if isoctave && octave_ver_less_than('9')
% Need to force QZ complex on Octave ⩽ 8 (otherwise it returns the real one) % Need to force QZ complex on Octave ⩽ 8 (otherwise it returns the real one)
[a b q z]=qz(complex(G0pi),complex(G1pi)); [a, b, q, z]=qz(complex(G0pi),complex(G1pi));
else else
[a b q z]=qz(G0pi,G1pi); [a, b, q, z]=qz(G0pi,G1pi);
end end
catch catch
try try
@ -239,7 +239,7 @@ for i=1:nn
end end
div ; div ;
if ~zxz if ~zxz
[a b q z]=qzdiv(div,a,b,q,z); [a, b, q, z]=qzdiv(div,a,b,q,z);
end end
gev=[diag(a) diag(b)]; gev=[diag(a) diag(b)];

View File

@ -71,7 +71,7 @@ try
singular=1; singular=1;
else else
UAVinv=inv(C2); UAVinv=inv(C2);
[LastWarningTxt LastWarningID]=lastwarn; [LastWarningTxt, LastWarningID]=lastwarn;
if any(any(isinf(UAVinv)))==1 if any(any(isinf(UAVinv)))==1
singular=1; singular=1;
end end

View File

@ -888,7 +888,7 @@ else
% in case of mixed surprise and perfect foresight on the % in case of mixed surprise and perfect foresight on the
% endogenous path, at each date all the exogenous paths have to be % endogenous path, at each date all the exogenous paths have to be
% stored. The paths are stacked in exo. % stored. The paths are stacked in exo.
for time = time_index_constraint; for time = time_index_constraint
exo(past_val + time,j_pos) = oo_.exo_simul(time,j_pos); exo(past_val + time,j_pos) = oo_.exo_simul(time,j_pos);
end end
else else

View File

@ -48,7 +48,7 @@ else
end end
if options_.verbosity if options_.verbosity
printline(41) printline(41)
disp(sprintf('MODEL SIMULATION (method=%s):',mthd)) dprintf('MODEL SIMULATION (method=%s):', mthd)
skipline() skipline()
end end

View File

@ -24,7 +24,7 @@ function print_expectations(eqname, expectationmodelname, expectationmodelkind,
% %
% The variable expectationmodelkind can take two values 'var' or 'pac'. % The variable expectationmodelkind can take two values 'var' or 'pac'.
% Copyright © 2018-2021 Dynare Team % Copyright © 2018-2023 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -347,7 +347,7 @@ for i=1:maxlag
for k=1:length(expectationmodel.components) for k=1:length(expectationmodel.components)
parameter = M_.params(expectationmodel.components(k).h_param_indices(id)); parameter = M_.params(expectationmodel.components(k).h_param_indices(id));
if parameter>=0 if parameter>=0
expressions{k} = sprintf('%s+%1.16f*%s', expressions{k}, parameter, variable);; expressions{k} = sprintf('%s+%1.16f*%s', expressions{k}, parameter, variable);
else else
expressions{k} = sprintf('%s-%1.16f*%s', expressions{k}, -parameter, variable); expressions{k} = sprintf('%s-%1.16f*%s', expressions{k}, -parameter, variable);
end end

View File

@ -126,5 +126,4 @@ switch (extension)
end end
cd(old_pwd) cd(old_pwd)
disp(sprintf('Loading %d observations from %s\n',... dprintf('Loading %d observations from %s', size(dyn_data_01, 1), fullname)
size(dyn_data_01,1),fullname))

View File

@ -108,7 +108,7 @@ end
if abs(floor(x(1))-xind_tick(1))-abs(ceil(x(end))-xind_tick(end))<-1 if abs(floor(x(1))-xind_tick(1))-abs(ceil(x(end))-xind_tick(end))<-1
xind_tick = xind_tick+1; xind_tick = xind_tick+1;
end end
if length(xind_tick)==gend, if length(xind_tick)==gend
xind_tick = x(2:end); xind_tick = x(2:end);
end end
% xind_tick = [x(ind_yrs(1))-floor(dind_tick/2):dind_tick:x(ind_yrs(end))+floor(dind_tick/2)]+1; % xind_tick = [x(ind_yrs(1))-floor(dind_tick/2):dind_tick:x(ind_yrs(end))+floor(dind_tick/2)]+1;
@ -154,7 +154,7 @@ comp_nbr0=comp_nbr;
%%plot decomposition %%plot decomposition
for j=1:nvar for j=1:nvar
z1 = squeeze(z(i_var(j),:,:)); z1 = squeeze(z(i_var(j),:,:));
if screen_shocks, if screen_shocks
[~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend'); [~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
if initval if initval
labels = char(char(shock_names(isort(1:16))),'Others', 'All shocks'); labels = char(char(shock_names(isort(1:16))),'Others', 'All shocks');

View File

@ -82,7 +82,7 @@ function varargout = colorspace(Conversion,varargin)
% ("short"). % ("short").
% Copyright © 2005-2010 Pascal Getreuer % Copyright © 2005-2010 Pascal Getreuer
% Copyright © 2017 Dynare Team % Copyright © 2017-2023 Dynare Team
% %
% Redistribution and use in source and binary forms, with or without % Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are % modification, are permitted provided that the following conditions are
@ -203,7 +203,7 @@ switch Space
Space = 'hsv'; Space = 'hsv';
case {'hsl','hsi','hls'} case {'hsl','hsi','hls'}
Space = 'hsl'; Space = 'hsl';
case {'rgb','yuv','yiq','ydbdr','ycbcr','jpegycbcr','xyz','lab','luv','lch'} case {'rgb','yuv','yiq','ydbdr','jpegycbcr','xyz','lab','luv','lch'}
return return
end end
return return