Remove unused output arguments.

covariance-quadratic-approximation
Stéphane Adjemian (Ryûk) 2023-12-18 07:48:27 +01:00
parent 7468a903b7
commit 735bd66d4d
Signed by: stepan
GPG Key ID: 295C1FE89E17EB3C
136 changed files with 331 additions and 340 deletions

View File

@ -34,7 +34,7 @@ global oo_
oo_.bvar.log_marginal_data_density=NaN(maxnlags,1);
for nlags = 1:maxnlags
[ny, nx, posterior, prior] = bvar.toolbox(nlags);
[ny, ~, posterior, prior] = bvar.toolbox(nlags);
oo_.bvar.posterior{nlags}=posterior;
oo_.bvar.prior{nlags}=prior;
@ -75,8 +75,8 @@ function w = matrictint(S, df, XXi)
k=size(XXi,1);
ny=size(S,1);
[cx,p]=chol(XXi);
[cs,q]=chol(S);
cx = chol(XXi);
cs = chol(S);
if any(diag(cx)<100*eps)
error('singular XXi')

View File

@ -33,7 +33,7 @@ global options_ oo_ M_
if options_.forecast == 0
error('bvar.forecast: you must specify "forecast" option')
end
[ny, nx, posterior, prior, forecast_data] = bvar.toolbox(nlags);
[ny, nx, posterior, ~, forecast_data] = bvar.toolbox(nlags);
sims_no_shock = NaN(options_.forecast, ny, options_.bvar_replic);
sims_with_shocks = NaN(options_.forecast, ny, options_.bvar_replic);

View File

@ -35,7 +35,7 @@ if nargin==1
identification = 'Cholesky';
end
[ny, nx, posterior, prior] = bvar.toolbox(nlags);
[ny, nx, posterior] = bvar.toolbox(nlags);
S_inv_upper_chol = chol(inv(posterior.S));

View File

@ -292,23 +292,23 @@ end
%
if is_gauss_newton
[params1, SSR, exitflag] = gauss_newton(resfun, params0);
[params1, SSR] = gauss_newton(resfun, params0);
elseif is_lsqnonlin
if ismember('levenberg-marquardt', varargin)
% Levenberg Marquardt does not handle boundary constraints.
[params1, SSR, ~, exitflag] = lsqnonlin(resfun, params0, [], [], optimset(varargin{:}));
[params1, SSR] = lsqnonlin(resfun, params0, [], [], optimset(varargin{:}));
else
[params1, SSR, ~, exitflag] = lsqnonlin(resfun, params0, bounds(:,1), bounds(:,2), optimset(varargin{:}));
[params1, SSR] = lsqnonlin(resfun, params0, bounds(:,1), bounds(:,2), optimset(varargin{:}));
end
else
% Estimate the parameters by minimizing the sum of squared residuals.
[params1, SSR, exitflag] = dynare_minimize_objective(ssrfun, params0, ...
minalgo, ...
options_, ...
bounds, ...
parameter_names, ...
[], ...
[]);
[params1, SSR] = dynare_minimize_objective(ssrfun, params0, ...
minalgo, ...
options_, ...
bounds, ...
parameter_names, ...
[], ...
[]);
end
% Revert local modifications to the options.

View File

@ -89,7 +89,7 @@ lpmat0=zeros(Nsam,0);
xparam1=[];
%% prepare prior bounds
[~,~,~,lb,ub,~] = set_prior(estim_params_,M_,options_); %Prepare bounds
[~,~,~,lb,ub] = set_prior(estim_params_,M_,options_); %Prepare bounds
if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0)
% Set prior bounds
bounds = prior_bounds(bayestopt_, options_.prior_trunc);
@ -600,4 +600,4 @@ end
skipline(1);
xparam1=x0;
save([OutputDirectoryName filesep 'prior_ok.mat'],'xparam1');
save([OutputDirectoryName filesep 'prior_ok.mat'],'xparam1');

View File

@ -206,7 +206,7 @@ if info(1) == 0 %no errors in solution
options_ident_local.no_identification_spectrum = 1; %do not recompute dSPECTRUM
options_ident_local.ar = nlags; %store new lag number
options_.ar = nlags; %store new lag number
[~, ~, ~, ~, ~, ~, MOMENTS, dMOMENTS, ~, ~, ~, ~] = identification.get_jacobians(estim_params_, M_, options_, options_ident_local, indpmodel, indpstderr, indpcorr, indvobs, oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
[~, ~, ~, ~, ~, ~, MOMENTS, dMOMENTS] = identification.get_jacobians(estim_params_, M_, options_, options_ident_local, indpmodel, indpstderr, indpcorr, indvobs, oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
ind_dMOMENTS = (find(max(abs(dMOMENTS'),[],1) > tol_deriv)); %new index with non-zero rows
end

View File

@ -86,7 +86,7 @@ else
Xparnonzero = Xpar(:,ind1); % focus on non-zero columns
end
[eu, ee2, ee1] = svd( [Xparnonzero Xrest], 0 );
[~, ~, ee1] = svd( [Xparnonzero Xrest], 0 );
condX = cond([Xparnonzero Xrest]);
rankX = rank(X, tol_rank);
icheck = 0; %initialize flag which is equal to 0 if we already found all single parameters that are not identified
@ -118,7 +118,7 @@ if icheck
else
Xparnonzero = Xpar(:,ind1); % focus on non-zero columns
end
[eu, ee2, ee1] = svd( [Xparnonzero Xrest], 0 );
[~, ~, ee1] = svd( [Xparnonzero Xrest], 0 );
condX = cond([Xparnonzero Xrest]);
rankX = rank(X,tol_rank);
end

View File

@ -209,7 +209,7 @@ function [mSYS,U] = minrealold(SYS,tol)
a = SYS.A;
b = SYS.B;
c = SYS.C;
[ns,nu] = size(b);
[ns,~] = size(b);
[am,bm,cm,U,k] = ControllabilityStaircaseRosenbrock(a,b,c,tol);
kk = sum(k);
nu = ns - kk;
@ -219,7 +219,7 @@ function [mSYS,U] = minrealold(SYS,tol)
cm = cm(:,nu+1:ns);
ns = ns - nu;
if ns
[am,bm,cm,t,k] = ObservabilityStaircaseRosenbrock(am,bm,cm,tol);
[am,bm,cm,~,k] = ObservabilityStaircaseRosenbrock(am,bm,cm,tol);
kk = sum(k);
nu = ns - kk;
nn = nn + nu;
@ -242,8 +242,8 @@ end
function [abar,bbar,cbar,t,k] = ControllabilityStaircaseRosenbrock(a, b, c, tol)
% Controllability staircase algorithm of Rosenbrock, 1968
[ra,ca] = size(a);
[rb,cb] = size(b);
[ra,~] = size(a);
[~,cb] = size(b);
ptjn1 = eye(ra);
ajn1 = a;
bjn1 = b;
@ -255,8 +255,8 @@ function [abar,bbar,cbar,t,k] = ControllabilityStaircaseRosenbrock(a, b, c, tol)
tol = ra*norm(a,1)*eps;
end
for jj = 1 : ra
[uj,sj,vj] = svd(bjn1);
[rsj,csj] = size(sj);
[uj,sj] = svd(bjn1);
[rsj,~] = size(sj);
%p = flip(eye(rsj),2);
p = eye(rsj);
p = p(:,end:-1:1);
@ -264,7 +264,7 @@ function [abar,bbar,cbar,t,k] = ControllabilityStaircaseRosenbrock(a, b, c, tol)
uj = uj*p;
bb = uj'*bjn1;
roj = rank(bb,tol);
[rbb,cbb] = size(bb);
[rbb,~] = size(bb);
sigmaj = rbb - roj;
sigmajn1 = sigmaj;
k(jj) = roj;

View File

@ -78,7 +78,7 @@ else
end
%% compute Kalman transition matrices and steady state with updated parameters
[dr,info,M_.params] = compute_decision_rules(M_,options_,dr, steady_state, exo_steady_state, exo_det_steady_state);
[dr,~,M_.params] = compute_decision_rules(M_,options_,dr, steady_state, exo_steady_state, exo_det_steady_state);
options_ = rmfield(options_,'options_ident');
pruned = pruned_SS.pruned_state_space_system(M_, options_, dr, indvar, nlags, useautocorr, 0);

View File

@ -302,7 +302,7 @@ options_.mode_compute = 0;
options_.plot_priors = 0;
options_.smoother = 1;
options_.options_ident = [];
[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_info, ~, ~, M_, options_, oo_, estim_params_, bayestopt_] = dynare_estimation_init(M_.endo_names, fname, 1, M_, options_, oo_, estim_params_, bayestopt_);
% set method to compute identification Jacobians (kronflag). Default:0
options_ident = set_default_option(options_ident,'analytic_derivation_mode', options_.analytic_derivation_mode); % if not set by user, inherit default global one
@ -470,7 +470,7 @@ if iload <=0
end
options_ident.tittxt = parameters; %title text for graphs and figures
% perform identification analysis for single point
[ide_moments_point, ide_spectrum_point, ide_minimal_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, derivatives_info_point, info, error_indicator_point] = ...
[ide_moments_point, ide_spectrum_point, ide_minimal_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, ~, info, error_indicator_point] = ...
identification.analysis(M_,options_,oo_,bayestopt_,estim_params_,params, indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1); %the 1 at the end implies initialization of persistent variables
if info(1)~=0
% there are errors in the solution algorithm
@ -487,7 +487,7 @@ if iload <=0
params = Prior.draw();
options_ident.tittxt = 'Random_prior_params'; %title text for graphs and figures
% perform identification analysis
[ide_moments_point, ide_spectrum_point, ide_minimal_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, derivatives_info_point, info, error_indicator_point] = ...
[ide_moments_point, ide_spectrum_point, ide_minimal_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, ~, info, error_indicator_point] = ...
identification.analysis(M_,options_,oo_,bayestopt_,estim_params_,params, indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1);
end
end
@ -542,7 +542,7 @@ if iload <=0
end
options_ident.tittxt = []; % clear title text for graphs and figures
% run identification analysis
[ide_moments, ide_spectrum, ide_minimal, ide_hess, ide_reducedform, ide_dynamic, ide_derivatives_info, info, error_indicator] = ...
[ide_moments, ide_spectrum, ide_minimal, ~, ide_reducedform, ide_dynamic, ~, info, error_indicator] = ...
identification.analysis(M_,options_,oo_,bayestopt_,estim_params_,params, indpmodel, indpstderr, indpcorr, options_MC, dataset_info, prior_exist, 0); % the 0 implies that we do not initialize persistent variables anymore
if iteration==0 && info(1)==0 % preallocate storage in the first admissable run
@ -911,7 +911,7 @@ if SampleSize > 1
fprintf('\nTesting %s.\n',tittxt);
if ~iload
options_ident.tittxt = tittxt; %title text for graphs and figures
[ide_moments_max, ide_spectrum_max, ide_minimal_max, ide_hess_max, ide_reducedform_max, ide_dynamic_max, derivatives_info_max, info_max, error_indicator_max] = ...
[ide_moments_max, ide_spectrum_max, ide_minimal_max, ide_hess_max, ide_reducedform_max, ide_dynamic_max, ~, ~, error_indicator_max] = ...
identification.analysis(M_,options_,oo_,bayestopt_,estim_params_,pdraws(jmax,:), indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1); %the 1 at the end initializes some persistent variables
save([IdentifDirectoryName '/' fname '_identif.mat'], 'ide_hess_max', 'ide_moments_max', 'ide_spectrum_max', 'ide_minimal_max','ide_reducedform_max', 'ide_dynamic_max', 'jmax', '-append');
end
@ -978,4 +978,4 @@ end
%reset warning state
warning_config;
fprintf('\n==== Identification analysis completed ====\n\n')
fprintf('\n==== Identification analysis completed ====\n\n')

View File

@ -112,8 +112,8 @@ for stage_iter = 1:size(options_mom_.mom.weighting_matrix,1)
else
options_mom_.mom.compute_derivs = false;
end
[xparam1, fval, exitflag] = dynare_minimize_objective(objective_function, xparam0, options_mom_.optimizer_vec{optim_iter}, options_mom_, [Bounds.lb Bounds.ub], bayestopt_.name, bayestopt_, [],...
Bounds, oo_, estim_params_, M_, options_mom_);
[xparam1, fval] = dynare_minimize_objective(objective_function, xparam0, options_mom_.optimizer_vec{optim_iter}, options_mom_, [Bounds.lb Bounds.ub], bayestopt_.name, bayestopt_, [],...
Bounds, oo_, estim_params_, M_, options_mom_);
if options_mom_.mom.vector_output
fval = fval'*fval;
end
@ -126,4 +126,4 @@ for stage_iter = 1:size(options_mom_.mom.weighting_matrix,1)
end
options_mom_.vector_output = false;
[~, ~, ~,~,~, oo_] = feval(objective_function, xparam1, Bounds, oo_, estim_params_, M_, options_mom_); % get oo_.mom.model_moments for iterated GMM/SMM to compute optimal weighting matrix
end
end

View File

@ -403,7 +403,7 @@ end
% Build dataset
if strcmp(options_mom_.mom.mom_method,'GMM') || strcmp(options_mom_.mom.mom_method,'SMM')
% Check if datafile has same name as mod file
[~,name,~] = fileparts(options_mom_.datafile);
[~,name] = fileparts(options_mom_.datafile);
if strcmp(name,M_.fname)
error('method_of_moments: ''datafile'' and mod file are not allowed to have the same name; change the name of the ''datafile''!')
end

View File

@ -118,7 +118,7 @@ occbin_options.first_period_occbin_update = options_.occbin.smoother.first_perio
occbin_options.opts_regime = opts_simul; % this builds the opts_simul options field needed by occbin.solver
occbin_options.opts_regime.binding_indicator = options_.occbin.likelihood.init_binding_indicator;
occbin_options.opts_regime.regime_history=options_.occbin.likelihood.init_regime_history;
[alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK,T0,R0,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_,alphahat0,state_uncertainty0, diffuse_steps] = DsgeSmoother(xparam1,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_,occbin_options);% T1=TT;
[alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK,T0,R0,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_,alphahat0,state_uncertainty0] = DsgeSmoother(xparam1,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_,occbin_options);% T1=TT;
oo_.occbin.smoother.realtime_regime_history = oo_.occbin.smoother.regime_history;
regime_history = oo_.occbin.smoother.regime_history;

View File

@ -71,7 +71,7 @@ end
if ~isempty(xparam1)
M_ = set_all_parameters(xparam1,estim_params_,M_);
[fval,info,exit_flag,Q,H]=check_bounds_and_definiteness_estimation(xparam1, M_, estim_params_, BoundsInfo);
[fval,info,exit_flag]=check_bounds_and_definiteness_estimation(xparam1, M_, estim_params_, BoundsInfo);
if info(1)
return
end
@ -81,7 +81,7 @@ err_index=options_.occbin.likelihood.IVF_shock_observable_mapping; % err_index=
COVMAT1 = M_.Sigma_e(err_index,err_index);
% Linearize the model around the deterministic steady state and extract the matrices of the state equation (T and R).
[T,R,SteadyState,info,dr, M_.params] = dynare_resolve(M_,options_,dr, endo_steady_state, exo_steady_state, exo_det_steady_state,'restrict');
[~,~,SteadyState,info,dr, M_.params] = dynare_resolve(M_,options_,dr, endo_steady_state, exo_steady_state, exo_det_steady_state,'restrict');
% Return, with endogenous penalty when possible, if dynare_resolve issues an error code (defined in resol).
if info(1)
@ -195,4 +195,4 @@ end
% remember that the likelihood has already been multiplied by -1
% hence, posterior is -1 times the log of the prior
fval = like+prior;
fval = like+prior;

View File

@ -28,7 +28,7 @@ if opts.replic
effective_exo_nbr= length(ishock);
effective_exo_names = M_.exo_names(ishock);
effective_Sigma_e = M_.Sigma_e(ishock,ishock);
[U,S,V] = svd(effective_Sigma_e);
[U,S] = svd(effective_Sigma_e);
if opts.qmc
opts.replic =2^(round(log2(opts.replic+1)))-1;
SHOCKS_ant = qmc_sequence(forecast*effective_exo_nbr, int64(1), 1, opts.replic)';

View File

@ -292,8 +292,7 @@ error_flag = out.error_flag;
if ~error_flag && niter>options_.occbin.likelihood.max_number_of_iterations && ~isequal(regimes_(1),regimes0(1))
error_flag = 1;
if M_.occbin.constraint_nbr==1 % try some other regime
[ll, il]=sort(lik_hist);
[ll, il]=sort(regime_end);
[~, il]=sort(regime_end);
rr=regime_hist(il(2:3));
newstart=1;
if length(rr{1}.regimestart)>1

View File

@ -287,7 +287,7 @@ if error_flag==0 && niter>options_.occbin.likelihood.max_number_of_iterations &&
if M_.occbin.constraint_nbr==1
% try some other regime before giving up
[ll, il]=sort(regime_end);
[~, il]=sort(regime_end);
rr=regime_hist(il(2:3));
newstart=1;
if length(rr{1}(1).regimestart)>1

View File

@ -18,7 +18,7 @@ function [pacmodl, lhs, rhs, pnames, enames, xnames, rname, pid, eid, xid, pname
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% Get the original equation to be estimated
[LHS, RHS] = get_lhs_and_rhs(eqname, M_, true);
[~, RHS] = get_lhs_and_rhs(eqname, M_, true);
% Check that the equation has a PAC expectation term.
if ~contains(RHS, 'pac_expectation', 'IgnoreCase', true)

View File

@ -41,7 +41,7 @@ function iterative_ols(eqname, params, data, range)
global M_ oo_ options_
[pacmodl, ~, rhs, ~, ~, ~, rname, ~, ~, ~, ~, ipnames_, params, data, ~] = ...
[pacmodl, ~, rhs, ~, ~, ~, rname, ~, ~, ~, ~, ipnames_, params, data] = ...
pac.estimate.init(M_, oo_, eqname, params, data, range);
% Set initial condition.

View File

@ -200,23 +200,23 @@ if isnan(ssr0) || isinf(ssr0) || ~isreal(ssr0)
end
if is_gauss_newton
[params1, SSR, exitflag] = gauss_newton(resfun, params0);
[params1, SSR] = gauss_newton(resfun, params0);
elseif is_lsqnonlin
if ismember('levenberg-marquardt', varargin)
% Levenberg Marquardt does not handle boundary constraints.
[params1, SSR, ~, exitflag] = lsqnonlin(resfun, params0, [], [], optimset(varargin{:}));
[params1, SSR] = lsqnonlin(resfun, params0, [], [], optimset(varargin{:}));
else
[params1, SSR, ~, exitflag] = lsqnonlin(resfun, params0, bounds(:,1), bounds(:,2), optimset(varargin{:}));
[params1, SSR] = lsqnonlin(resfun, params0, bounds(:,1), bounds(:,2), optimset(varargin{:}));
end
else
% Estimate the parameters by minimizing the sum of squared residuals.
[params1, SSR, exitflag] = dynare_minimize_objective(ssrfun, params0, ...
minalgo, ...
options_, ...
bounds, ...
parameter_names, ...
[], ...
[]);
[params1, SSR] = dynare_minimize_objective(ssrfun, params0, ...
minalgo, ...
options_, ...
bounds, ...
parameter_names, ...
[], ...
[]);
end
% Revert local modifications to the options.

View File

@ -40,7 +40,7 @@ end
errorcode = 0;
% Get the original equation to be estimated
[LHS, RHS] = get_lhs_and_rhs(eqname, M_, true);
[~, RHS] = get_lhs_and_rhs(eqname, M_, true);
% Check that the equation has a PAC expectation term.
if ~contains(RHS, 'pac_expectation', 'IgnoreCase', true)

View File

@ -89,7 +89,7 @@ if leads ==0
end
%disp('gensysToAMA:running ama');
try % try to run AIM
[bb,rts,ia,nexact,nnumeric,lgroots,aimcode] =...
[bb,rts,~,~,~,~,aimcode] =...
SPAmalg(theAIM_H,neq, lags,leads,condn,uprbnd);
catch
err = lasterror;

View File

@ -84,7 +84,7 @@ for i=1:length(varargin)
end
% Ensure that the equation tag name matches the LHS variable.
eqtagname = regexp(model{j}, 'name=''(\w*)''', 'match');
[lhs, ~] = getequation(model{j+1});
lhs = getequation(model{j+1});
endovar = getendovar(lhs);
eqtagname_ = strcat('name=''', endovar{1}, '''');
if ~isempty(eqtagname)

View File

@ -63,7 +63,7 @@ for i=1:M_.exo_nbr
end
% Set up initial conditions
[initialcondition, periods, innovations, options_local, M_local, oo_local, endonames, exonames, dynamic_resid, dynamic_g1, y] = ...
[initialcondition, periods, innovations, options_local, M_local, oo_local, endonames, ~, dynamic_resid, dynamic_g1] = ...
simul_backward_model_init(initialcondition, periods, options_, M_, oo_, zeros(periods, M_.exo_nbr));
% Get vector of indices for the selected endogenous variables.
@ -110,9 +110,9 @@ if withuncertainty
for i=1:B
innovations = transpose(sigma*randn(M_.exo_nbr, periods));
if options_.linear
[ysim__, xsim__, errorflag] = simul_backward_linear_model_(initialcondition, periods, options_local, M_local, oo_local, innovations, dynamic_resid, dynamic_g1);
[ysim__, ~, errorflag] = simul_backward_linear_model_(initialcondition, periods, options_local, M_local, oo_local, innovations, dynamic_resid, dynamic_g1);
else
[ysim__, xsim__, errorflag] = simul_backward_nonlinear_model_(initialcondition, periods, options_local, M_local, oo_local, innovations, dynamic_resid, dynamic_g1);
[ysim__, ~, errorflag] = simul_backward_nonlinear_model_(initialcondition, periods, options_local, M_local, oo_local, innovations, dynamic_resid, dynamic_g1);
end
if errorflag
error('Simulation failed.')

View File

@ -139,7 +139,7 @@ if ~isempty(innovationbaseline)
end
% Set up initial conditions
[initialcondition, periods, Innovations, options_local, M_local, oo_local, endonames, exonames, dynamic_resid, dynamic_g1, y] = ...
[initialcondition, periods, Innovations, options_local, M_local, oo_local, endonames, exonames, dynamic_resid, dynamic_g1] = ...
simul_backward_model_init(initialcondition, periods, options_, M_, oo_, Innovations);
% Get the covariance matrix of the shocks.

View File

@ -57,7 +57,7 @@ if isempty(initialconditions)
vertcat(M_.endo_names(1:M_.orig_endo_nbr), M_.exo_names));
end
[initialconditions, info] = checkdatabase(initialconditions, M_, false, true);
initialconditions = checkdatabase(initialconditions, M_, false, true);
% Test if the first argument contains all the lagged endogenous variables
endonames = M_.endo_names;

View File

@ -143,7 +143,7 @@ for it = initialconditions.nobs+(1:samplesize)
%
% Evaluate and check the residuals
%
[r, J] = dynamic_backward_model_for_simulation(ytm, dynamic_resid, dynamic_g1, ytm, x, M_.params, oo_.steady_state, M_.dynamic_g1_sparse_rowval, M_.dynamic_g1_sparse_colval, M_.dynamic_g1_sparse_colptr);
r = dynamic_backward_model_for_simulation(ytm, dynamic_resid, dynamic_g1, ytm, x, M_.params, oo_.steady_state, M_.dynamic_g1_sparse_rowval, M_.dynamic_g1_sparse_colval, M_.dynamic_g1_sparse_colptr);
residuals_evaluating_to_nan = isnan(r);
residuals_evaluating_to_inf = isinf(r);
residuals_evaluating_to_complex = ~isreal(r);

View File

@ -52,7 +52,7 @@ if writelistofroutinestobecleared
end
end
end
[~, list_of_functions, ~] = cellfun(@fileparts, list_of_files, 'UniformOutput',false);
[~, list_of_functions] = cellfun(@fileparts, list_of_files, 'UniformOutput',false);
cellofchar2mfile(sprintf('%slist_of_functions_to_be_cleared.m', DYNARE_FOLDER), list_of_functions)
end
return

View File

@ -35,4 +35,4 @@ end
parameters = strrep(parameters, ' ', '_');
[oo_, M_, options_, bayestopt_, Smoothed_variables_declaration_order_deviation_form] = evaluate_smoother(parameters, varlist, M_, oo_, options_, bayestopt_, estim_params_);
[oo_, M_, options_, bayestopt_] = evaluate_smoother(parameters, varlist, M_, oo_, options_, bayestopt_, estim_params_);

View File

@ -61,7 +61,7 @@ if (size(estim_params_.var_endo,1) || size(estim_params_.corrn,1))
end
% Fill or update bayestopt_ structure
[xparam1, estim_params_, BayesOptions, lb, ub, M_local] = set_prior(estim_params_, M_, options_);
[~, estim_params_, ~, lb, ub, M_local] = set_prior(estim_params_, M_, options_);
% Set restricted state space
options_plot_priors_old=options_.plot_priors;
options_.plot_priors=0;

View File

@ -272,7 +272,7 @@ else
end
NamFileInput={[M_.dname '/metropolis/'],[ModelName '_mh*_blck*.mat']};
[fout, nBlockPerCPU, totCPU] = masterParallel(options_.parallel, 1, npar,NamFileInput,'mcmc_diagnostics_core', localVars, [], options_.parallel_info);
[fout, ~, totCPU] = masterParallel(options_.parallel, 1, npar,NamFileInput,'mcmc_diagnostics_core', localVars, [], options_.parallel_info);
UDIAG = fout(1).UDIAG;
for j=2:totCPU
UDIAG = cat(3,UDIAG ,fout(j).UDIAG);

View File

@ -93,7 +93,7 @@ for nv = 1:n_vars % big loop over variables
% Find thinning factor for which first-order Markov Chain is preferred to second-order one
while(bic > 0)
thinned_chain=work(1:k_thin_current_var:n_runs,1);
[g2, bic] = first_vs_second_order_MC_test(thinned_chain);
[~, bic] = first_vs_second_order_MC_test(thinned_chain);
k_thin_current_var = k_thin_current_var+1;
end
@ -108,11 +108,11 @@ for nv = 1:n_vars % big loop over variables
beta = transition_matrix(2,1)/(transition_matrix(2,1)+transition_matrix(2,2)); %prob of going from 2 to 1
kmind=k_thin_current_var;
[g2, bic]=independence_chain_test(thinned_chain);
[~, bic]=independence_chain_test(thinned_chain);
while(bic > 0)
thinned_chain=work(1:kmind:n_runs,1);
[g2, bic] = independence_chain_test(thinned_chain);
[~, bic] = independence_chain_test(thinned_chain);
kmind = kmind+1;
end

View File

@ -49,7 +49,7 @@ else
end
params=M_.params;
[U,Uy,W] = feval([M_.fname,'.objective.static'],zeros(M_.endo_nbr,1),[], M_.params);
[~,Uy,W] = feval([M_.fname,'.objective.static'],zeros(M_.endo_nbr,1),[], M_.params);
if any(any(isnan(Uy)))
info = 64 ; %the derivatives of the objective function contain NaN
return;

View File

@ -121,7 +121,7 @@ if (distribution==3)% Inverted Gamma 1 distribution
nu = 2;
s = 3*(m*m);
else
[mu, parameters] = mode_and_variance_to_mean(m,s2,2);
[~, parameters] = mode_and_variance_to_mean(m,s2,2);
nu = sqrt(parameters(1));
nu2 = 2*nu;
nu1 = 2;

View File

@ -48,6 +48,6 @@ X = randn(v, m) * H_inv_upper_chol;
% G = inv(X'*X);
% Rather compute inv(X'*X) using the SVD
[U,S,V] = svd(X, 0);
[~,S,V] = svd(X, 0);
SSi = 1 ./ (diag(S) .^ 2);
G = (V .* repmat(SSi', m, 1)) * V';

View File

@ -56,7 +56,7 @@ eqn = @(k) gammaln(1+2./k) - 2*gammaln(1+1./k) - log(1+sigma2/mu2);
eqn2 = @(k) eqn(k).*eqn(k);
kstar = fminbnd(eqn2, 1e-9, 100);
[shape, fval, exitflag] = fzero(eqn, kstar);
[shape, ~, exitflag] = fzero(eqn, kstar);
if exitflag<1
shape = NaN;

@ -1 +1 @@
Subproject commit 65ea12c7a5c0ac29ba42428e0ec5d991b6dd7f5e
Subproject commit 4fceb85e3a1d10e8040b60bcb5cf79a3c533956c

View File

@ -240,7 +240,7 @@ end
% https://forum.dynare.org/t/issue-with-dynare-preprocessor-4-6-1/15448/1
if ~fast
if ispc && ~isoctave && exist(['+',fname(1:end-4)],'dir')
[~,~]=rmdir(['+', fname(1:end-4)],'s');
rmdir(['+', fname(1:end-4)],'s');
end
end

View File

@ -51,7 +51,7 @@ if ~isempty(endo_prior_restrictions.irf)
end
varlist = M_.endo_names(dr.order_var);
if isempty(T)
[T,R,SteadyState,infox,dr, M_.params] = dynare_resolve(M_,options_,dr, endo_steady_state, exo_steady_state, exo_det_steady_state);
[T,R,~,~,dr, M_.params] = dynare_resolve(M_,options_,dr, endo_steady_state, exo_steady_state, exo_det_steady_state);
else % check if T and R are given in the restricted form!!!
if size(T,1)<length(varlist)
varlist = varlist(dr.restrict_var_list);
@ -65,7 +65,7 @@ if ~isempty(endo_prior_restrictions.irf)
end
if ~varlistok
varlist = M_.endo_names(dr.order_var);
[T,R,SteadyState,infox,dr, M_.params] = dynare_resolve(M_,options_,dr, endo_steady_state, exo_steady_state, exo_det_steady_state);
[T,R,~,~,dr, M_.params] = dynare_resolve(M_,options_,dr, endo_steady_state, exo_steady_state, exo_det_steady_state);
end
end
NT=1;
@ -138,7 +138,7 @@ if ~isempty(endo_prior_restrictions.moment)
end
end
options_.ar = max(abs(NTmin),NTmax);
[gamma_y,stationary_vars] = th_autocovariances(dr, ivar, M_, options_,1);
gamma_y = th_autocovariances(dr, ivar, M_, options_,1);
for t=NTmin:NTmax
RR = gamma_y{abs(t)+1};
if t==0
@ -171,4 +171,4 @@ if ~isempty(endo_prior_restrictions.moment)
if any(info_moment)
info=[49, info(2) + sum(info_moment(:,2))];
end
end
end

View File

@ -20,14 +20,14 @@ function e = ep_accuracy_check(M_,options_,oo_)
endo_simul = oo_.endo_simul;
n = size(endo_simul,2);
[initialconditions, innovations, pfm, ep, verbosity, options_, oo_] = ...
[~, innovations, pfm, ~, ~, options_, oo_] = ...
extended_path_initialization([], n-1, [], options_, M_, oo_);
options_.ep.accuracy.stochastic.order = options_.ep.stochastic.order;
[nodes,weights,nnodes] = setup_integration_nodes(options_.ep.accuracy,pfm);
[nodes,weights] = setup_integration_nodes(options_.ep.accuracy,pfm);
e = zeros(M_.endo_nbr,n);
for i=1:n
e(:,i) = euler_equation_error(endo_simul(:,i),oo_.exo_simul, ...
innovations, M_, options_,oo_,pfm,nodes,weights);
end
end

View File

@ -20,31 +20,29 @@ function e = euler_equation_error(y0,x,innovations,M_,options_,oo_,pfm,nodes,wei
dynamic_model = str2func([M_.fname '.dynamic']);
ep = options_.ep;
[y1, info_convergence, endogenousvariablespaths] = extended_path_core(ep.periods, ...
M_.endo_nbr, M_.exo_nbr, ...
innovations.positive_var_indx, ...
x, ep.init, y0, oo_.steady_state, ...
0, ...
ep.stochastic.order, M_, ...
pfm, ep.stochastic.algo, ...
ep.solve_algo, ...
ep.stack_solve_algo, ...
options_.lmmcp, options_, oo_, ...
[]);
y1 = extended_path_core(ep.periods, ...
M_.endo_nbr, M_.exo_nbr, ...
innovations.positive_var_indx, ...
x, ep.init, y0, oo_.steady_state, ...
0, ...
ep.stochastic.order, M_, ...
pfm, ep.stochastic.algo, ...
ep.solve_algo, ...
ep.stack_solve_algo, ...
options_.lmmcp, options_, oo_, ...
[]);
i_pred = find(M_.lead_lag_incidence(1,:));
i_fwrd = find(M_.lead_lag_incidence(3,:));
x1 = [x(2:end,:); zeros(1,M_.exo_nbr)];
for i=1:length(nodes)
x2 = x1;
x2(2,:) = x2(2,:) + nodes(i,:);
[y2, info_convergence, endogenousvariablespaths] = ...
extended_path_core(ep.periods, M_.endo_nbr, M_.exo_nbr, ...
innovations.positive_var_indx, x2, ep.init, ...
y1, oo_.steady_state, 0, ...
ep.stochastic.order, M_, pfm, ep.stochastic.algo, ...
ep.solve_algo, ep.stack_solve_algo, options_.lmmcp, ...
options_, oo_, []);
y2 = extended_path_core(ep.periods, M_.endo_nbr, M_.exo_nbr, ...
innovations.positive_var_indx, x2, ep.init, ...
y1, oo_.steady_state, 0, ...
ep.stochastic.order, M_, pfm, ep.stochastic.algo, ...
ep.solve_algo, ep.stack_solve_algo, options_.lmmcp, ...
options_, oo_, []);
z = [y0(i_pred); y1; y2(i_fwrd)];
res(:,i) = dynamic_model(z,x,M_.params,oo_.steady_state,2);
end

View File

@ -78,7 +78,7 @@ dr = struct();
if ep.init
options_.order = 1;
oo_.dr=set_state_space(dr,M_);
[oo_.dr,Info,M_.params] = resol(0,M_,options_,oo_.dr,oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
[oo_.dr,~,M_.params] = resol(0,M_,options_,oo_.dr,oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
end
% Do not use a minimal number of perdiods for the perfect foresight solver (with bytecode and blocks)

View File

@ -36,7 +36,7 @@ function Simulations = extended_path_mc(initialconditions, samplesize, replic, e
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
[initialconditions, innovations, pfm, ep, verbosity, options_, oo_] = ...
[initialconditions, innovations, pfm, ep, ~, options_, oo_] = ...
extended_path_initialization(initialconditions, samplesize, exogenousvariables, options_, M_, oo_);
% Check the dimension of the first input argument

View File

@ -200,7 +200,7 @@ if isnumeric(options_.parallel)
nosaddle = fout.nosaddle;
else
% Parallel execution!
[nCPU, totCPU, nBlockPerCPU] = distributeJobs(options_.parallel, 1, B);
[~, totCPU, nBlockPerCPU] = distributeJobs(options_.parallel, 1, B);
for j=1:totCPU-1
nfiles = ceil(nBlockPerCPU(j)/MAX_nirfs_dsge);
NumberOfIRFfiles_dsge(j+1) =NumberOfIRFfiles_dsge(j)+nfiles;

View File

@ -464,7 +464,7 @@ if analytic_derivation
AHess = [];
iv = dr.restrict_var_list;
if nargin<13 || isempty(derivatives_info)
[A,B,nou,nou,dr, M_.params] = dynare_resolve(M_,options_,dr, endo_steady_state, exo_steady_state, exo_det_steady_state);
[~,~,~,~,dr, M_.params] = dynare_resolve(M_,options_,dr, endo_steady_state, exo_steady_state, exo_det_steady_state);
if ~isempty(estim_params_.var_exo)
indexo=estim_params_.var_exo(:,1);
else

View File

@ -81,7 +81,7 @@ options_.ar = 0;
NumberOfSavedElementsPerSimulation = nvar*M_.exo_nbr*length(Steps);
MaXNumberOfConditionalDecompLines = ceil(options_.MaxNumberOfBytes/NumberOfSavedElementsPerSimulation/8);
[ME_present,observable_pos_requested_vars,index_subset,index_observables]=check_measurement_error_requested_vars(M_,options_,ivar);
[ME_present,observable_pos_requested_vars] = check_measurement_error_requested_vars(M_,options_,ivar);
if ME_present && ~isempty(observable_pos_requested_vars)
nobs_ME=length(observable_pos_requested_vars);
@ -132,7 +132,7 @@ for file = 1:NumberOfDrawsFiles
dr = temp.pdraws{linee,2};
else
M_=set_parameters_locally(M_,temp.pdraws{linee,1});
[dr,info,M_.params] = compute_decision_rules(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
[dr,~,M_.params] = compute_decision_rules(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
end
M_ = set_measurement_errors(temp.pdraws{linee,1},temp.estim_params_,M_);

View File

@ -36,7 +36,7 @@ function [nvar,vartan,CorrFileNumber] = dsge_simulated_theoretical_correlation(S
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
nvar = length(ivar);
[ivar,vartan, options_] = get_variables_list(options_, M_);
[~,vartan] = get_variables_list(options_, M_);
% Get informations about the _posterior_draws files.
if strcmpi(type,'posterior')

View File

@ -127,7 +127,7 @@ for file = 1:NumberOfDrawsFiles
dr = temp.pdraws{linee,2};
else
M_=set_parameters_locally(M_,temp.pdraws{linee,1});
[dr,info,M_.params] = compute_decision_rules(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
[dr,~,M_.params] = compute_decision_rules(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
end
if ~options_.pruning
tmp = th_autocovariances(dr,ivar,M_,options_,nodecomposition);

View File

@ -137,10 +137,10 @@ for file = 1:NumberOfDrawsFiles
dr = temp.pdraws{linee,2};
else
M_=set_parameters_locally(M_,temp.pdraws{linee,1});
[dr,info,M_.params] = compute_decision_rules(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
[dr,~,M_.params] = compute_decision_rules(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
end
if file==1 && linee==1
[tmp, stationary_vars] = th_autocovariances(dr,ivar,M_,options_,nodecomposition);
[~, stationary_vars] = th_autocovariances(dr,ivar,M_,options_,nodecomposition);
if isempty(stationary_vars)
fprintf('\ndsge_simulated_theoretical_variance_decomposition:: All requested endogenous variables have a unit root and thus infinite variance.\n')
fprintf('dsge_simulated_theoretical_variance_decomposition:: No decomposition is performed.\n')

View File

@ -201,14 +201,14 @@ if isequal(options_.mode_compute,0) && isempty(options_.mode_file) && ~options_.
end
else
if options_.occbin.smoother.status
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = occbin.DSGE_smoother(xparam1,gend,transpose(data),data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_,dataset_,dataset_info);
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,~,~,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = occbin.DSGE_smoother(xparam1,gend,transpose(data),data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_,dataset_,dataset_info);
if oo_.occbin.smoother.error_flag(1)==0
[oo_]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty);
else
fprintf('\nOccbin: smoother did not succeed. No results will be written to oo_.\n')
end
else
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = DsgeSmoother(xparam1,gend,transpose(data),data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,~,~,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = DsgeSmoother(xparam1,gend,transpose(data),data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
[oo_]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty);
end
end
@ -437,7 +437,7 @@ if issmc(options_) || (any(bayestopt_.pshape>0) && options_.mh_replic) || (any(
CutSample(M_, options_, dispString);
end
if options_.mh_posterior_mode_estimation || (issmc(options_) && options_.smc_posterior_mode_estimation)
[~, covariance, posterior_mode, ~] = compute_posterior_covariance_matrix(bayestopt_.name, M_.fname, M_.dname, options_);
[~, covariance, posterior_mode] = compute_posterior_covariance_matrix(bayestopt_.name, M_.fname, M_.dname, options_);
oo_ = fill_mh_mode(posterior_mode, sqrt(diag(covariance)), M_, options_, estim_params_, oo_, 'posterior');
%reset qz_criterium
options_.qz_criterium = qz_criterium_old;

View File

@ -345,7 +345,7 @@ if options_.analytic_derivation
else
steadystate_check_flag = 1;
end
[tmp1, params] = evaluate_steady_state(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_local,options_,steadystate_check_flag);
[~, params] = evaluate_steady_state(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_local,options_,steadystate_check_flag);
change_flag=any(find(params-M_local.params));
if change_flag
skipline()
@ -374,7 +374,7 @@ bayestopt_.jscale(k) = options_.mh_jscale;
% Build the dataset
if ~isempty(options_.datafile)
[pathstr,name,ext] = fileparts(options_.datafile);
[~,name] = fileparts(options_.datafile);
if strcmp(name,M_.fname)
error('Data-file and mod-file are not allowed to have the same name. Please change the name of the data file.')
end
@ -383,7 +383,7 @@ end
if isnan(options_.first_obs)
options_.first_obs=1;
end
[dataset_, dataset_info, newdatainterfaceflag] = makedataset(options_, options_.dsge_var*options_.dsge_varlag, gsa_flag);
[dataset_, dataset_info] = makedataset(options_, options_.dsge_var*options_.dsge_varlag, gsa_flag);
%set options for old interface from the ones for new interface
if ~isempty(dataset_)

View File

@ -34,7 +34,7 @@ function oo_=execute_prior_posterior_function(posterior_function_name,M_,options
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
[directory,basename,extension] = fileparts(posterior_function_name);
[~,basename,extension] = fileparts(posterior_function_name);
if isempty(extension)
extension = '.m';
end
@ -64,7 +64,7 @@ elseif strcmpi(type,'prior')
% Get informations about the prior distribution.
if isempty(bayestopt_)
if ~isempty(estim_params_) && ~(isfield(estim_params_,'nvx') && (size(estim_params_.var_exo,1)+size(estim_params_.var_endo,1)+size(estim_params_.corrx,1)+size(estim_params_.corrn,1)+size(estim_params_.param_vals,1))==0)
[xparam1,estim_params_,bayestopt_,lb,ub,M_] = set_prior(estim_params_,M_,options_);
[~,estim_params_,bayestopt_,~,~,M_] = set_prior(estim_params_,M_,options_);
else
error('The prior distributions are not properly set up.')
end

View File

@ -172,7 +172,7 @@ end
% display warning if some parameters are still NaN
test_for_deep_parameters_calibration(M_);
[lnprior,~,~,info]= priordens(xparam1,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
[~,~,~,info]= priordens(xparam1,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
if any(info)
fprintf('The prior density evaluated at the initial values is Inf for the following parameters: %s\n',bayestopt_.name{info,1})
error('The initial value of the prior is -Inf')

View File

@ -46,7 +46,7 @@ function [xparams, lpd, hessian_mat] = ...
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
[xparams, lpd, exitflag, hessian_mat] = dynare_minimize_objective('minus_logged_prior_density', ...
[xparams, lpd, ~, hessian_mat] = dynare_minimize_objective('minus_logged_prior_density', ...
iparams, ...
options_.mode_compute, ...
options_, ...

View File

@ -110,7 +110,7 @@ end
% In order to avoid overflow, we divide the numerator and the denominator
% of the Posterior Odds Ratio by the largest Marginal Posterior Density
lmpd = log(ModelPriors)+MarginalLogDensity;
[maxval,k] = max(lmpd);
maxval = max(lmpd);
elmpd = exp(lmpd-maxval);
% Now I display the posterior probabilities.

View File

@ -37,7 +37,7 @@ while look_for_admissible_initial_condition
xinit = xparam1+scale*randn(size(xparam1));
if all(xinit>Prior.p3) && all(xinit<Prior.p4)
M_ = set_all_parameters(xinit, estim_params_, M_);
[dr, INFO, M_, oo_] = resol(0, M_, options_, oo_);
[~, INFO, M_, oo_] = resol(0, M_, options_, oo_);
if ~INFO(1)
look_for_admissible_initial_condition = false;
end
@ -52,8 +52,7 @@ while look_for_admissible_initial_condition
end
% Maximization of the prior density
[xparams, lpd, hessian_mat] = ...
maximize_prior_density(xinit, pnames, options_, M_, Prior, estim_params_, oo_);
xparams = maximize_prior_density(xinit, pnames, options_, M_, Prior, estim_params_, oo_);
% Display results.
skipline(2)

View File

@ -336,7 +336,7 @@ if ~options_.nograph && ~options_.no_graph.posterior
fout = pm3_core(localVars,1,nvar,0);
else
globalVars = [];
[fout, nvar0, totCPU] = masterParallel(options_.parallel, 1, nvar, [],'pm3_core', localVars,globalVars, options_.parallel_info);
[~, nvar0] = masterParallel(options_.parallel, 1, nvar, [],'pm3_core', localVars,globalVars, options_.parallel_info);
end
end
else

View File

@ -52,14 +52,14 @@ end
switch type
case 'variance'
if nargin==narg1
[nvar,vartan,NumberOfFiles] = ...
[nvar,vartan] = ...
dsge_simulated_theoretical_covariance(SampleSize,arg3,M_,options_,oo_,'posterior');
end
oo_ = covariance_mc_analysis(SampleSize,'posterior',M_.dname,M_.fname,...
vartan,nvar,arg1,arg2,options_.mh_conf_sig,oo_,options_);
case 'decomposition'
if nargin==narg1
[nvar,vartan,NumberOfFiles] = ...
[~,vartan] = ...
dsge_simulated_theoretical_variance_decomposition(SampleSize,M_,options_,oo_,'posterior');
end
oo_ = variance_decomposition_mc_analysis(SampleSize,'posterior',M_.dname,M_.fname,...
@ -77,14 +77,14 @@ switch type
end
case 'correlation'
if nargin==narg1
[nvar,vartan,NumberOfFiles] = ...
[nvar,vartan] = ...
dsge_simulated_theoretical_correlation(SampleSize,arg3,M_,options_,oo_,'posterior');
end
oo_ = correlation_mc_analysis(SampleSize,'posterior',M_.dname,M_.fname,...
vartan,nvar,arg1,arg2,arg3,options_.mh_conf_sig,oo_,M_,options_);
case 'conditional decomposition'
if nargin==narg1
[nvar,vartan,NumberOfFiles] = ...
[~,vartan] = ...
dsge_simulated_theoretical_conditional_variance_decomposition(SampleSize,arg3,M_,options_,oo_,'posterior');
end
oo_ = conditional_variance_decomposition_mc_analysis(SampleSize,'posterior',M_.dname,M_.fname,...

View File

@ -91,9 +91,9 @@ switch posterior_sampling_method
blocked_draws_counter=blocked_draws_counter+1;
nxopt=length(indices(blocks==block_iter,1)); %get size of current block
par_start_current_block=current_draw(indices(blocks==block_iter,1));
[xopt_current_block, fval, exitflag, hess_mat_optimizer, options_, Scale] = dynare_minimize_objective(@TaRB_optimizer_wrapper,par_start_current_block,sampler_options.mode_compute,options_,[mh_bounds.lb(indices(blocks==block_iter,1),1) mh_bounds.ub(indices(blocks==block_iter,1),1)],bayestopt_.name,bayestopt_,[],...
current_draw,indices(blocks==block_iter,1),TargetFun,...% inputs for wrapper
varargin{:}); %inputs for objective
[xopt_current_block, ~, ~, ~, options_] = dynare_minimize_objective(@TaRB_optimizer_wrapper,par_start_current_block,sampler_options.mode_compute,options_,[mh_bounds.lb(indices(blocks==block_iter,1),1) mh_bounds.ub(indices(blocks==block_iter,1),1)],bayestopt_.name,bayestopt_,[],...
current_draw,indices(blocks==block_iter,1),TargetFun,...% inputs for wrapper
varargin{:}); %inputs for objective
%% covariance for proposal density
hessian_mat = reshape(hessian('TaRB_optimizer_wrapper',xopt_current_block, ...
options_.gstep,...
@ -186,4 +186,4 @@ switch posterior_sampling_method
par = last_draw;
logpost = last_posterior;
end
end
end

View File

@ -52,7 +52,7 @@ options_.prior_trunc = prior_trunc_backup ;
RESIZE = false;
for i=1:size(bayestopt_.name,1)
[Name,~] = get_the_name(i,1,M_,estim_params_,options_.varobs);
Name = get_the_name(i,1,M_,estim_params_,options_.varobs);
if length(Name)>size(T1,2)
resize = true;
else
@ -163,4 +163,4 @@ if ~isnumeric(UpperBound)
else
format_string = [ format_string , ' %6.4f \t'];
end
format_string = [ format_string , ' %6.4f \t %6.4f'];
format_string = [ format_string , ' %6.4f \t %6.4f'];

View File

@ -52,28 +52,28 @@ end
switch type
case 'variance'
if nargin==narg1
[nvar,vartan,NumberOfFiles] = ...
[nvar,vartan] = ...
dsge_simulated_theoretical_covariance(SampleSize,M_,options_,oo_,'prior');
end
oo_ = covariance_mc_analysis(SampleSize,'prior',M_.dname,M_.fname,...
vartan,nvar,arg1,arg2,options_.mh_conf_sig,oo_,options_);
case 'decomposition'
if nargin==narg1
[nvar,vartan,NumberOfFiles] = ...
[~,vartan] = ...
dsge_simulated_theoretical_variance_decomposition(SampleSize,M_,options_,oo_,'prior');
end
oo_ = variance_decomposition_mc_analysis(SampleSize,'prior',M_.dname,M_.fname,...
M_.exo_names,arg2,vartan,arg1,options_.mh_conf_sig,oo_,options_);
case 'correlation'
if nargin==narg1
[nvar,vartan,NumberOfFiles] = ...
[nvar,vartan] = ...
dsge_simulated_theoretical_correlation(SampleSize,arg3,M_,options_,oo_,'prior');
end
oo_ = correlation_mc_analysis(SampleSize,'prior',M_.dname,M_.fname,...
vartan,nvar,arg1,arg2,arg3,options_.mh_conf_sig,oo_,M_,options_);
case 'conditional decomposition'
if nargin==narg1
[nvar,vartan,NumberOfFiles] = ...
[~,vartan] = ...
dsge_simulated_theoretical_conditional_variance_decomposition(SampleSize,arg3,M_,options_,oo_,'prior');
end
oo_ = conditional_variance_decomposition_mc_analysis(SampleSize,'prior',M_.dname,M_.fname,...
@ -86,4 +86,4 @@ switch type
end
otherwise
disp('Not yet implemented')
end
end

View File

@ -368,7 +368,7 @@ for b=fpar:B
stock_smoothed_uncert(dr.order_var,dr.order_var,:,irun(13)) = state_uncertainty;
end
else
[~,~,SteadyState,info] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state);
[~,~,SteadyState] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state);
end
stock_param(irun(5),:) = deep;
stock_logpo(irun(5),1) = logpo;
@ -594,4 +594,4 @@ for iter=1:horizon
end
yf(dr.order_var,:,:) = yf;
yf=permute(yf,[2 1 3]);
yf=permute(yf,[2 1 3]);

View File

@ -95,9 +95,9 @@ if tt1
return
end
if nargout == 2
[tmp, dlprior(id1)]=lpdfgbeta(x(id1),p6(id1),p7(id1),p3(id1),p4(id1));
[~, dlprior(id1)]=lpdfgbeta(x(id1),p6(id1),p7(id1),p3(id1),p4(id1));
elseif nargout == 3
[tmp, dlprior(id1), d2lprior(id1)]=lpdfgbeta(x(id1),p6(id1),p7(id1),p3(id1),p4(id1));
[~, dlprior(id1), d2lprior(id1)]=lpdfgbeta(x(id1),p6(id1),p7(id1),p3(id1),p4(id1));
end
end
@ -110,18 +110,18 @@ if tt2
return
end
if nargout == 2
[tmp, dlprior(id2)]=lpdfgam(x(id2)-p3(id2),p6(id2),p7(id2));
[~, dlprior(id2)]=lpdfgam(x(id2)-p3(id2),p6(id2),p7(id2));
elseif nargout == 3
[tmp, dlprior(id2), d2lprior(id2)]=lpdfgam(x(id2)-p3(id2),p6(id2),p7(id2));
[~, dlprior(id2), d2lprior(id2)]=lpdfgam(x(id2)-p3(id2),p6(id2),p7(id2));
end
end
if tt3
logged_prior_density = logged_prior_density + sum(lpdfnorm(x(id3),p6(id3),p7(id3))) ;
if nargout == 2
[tmp, dlprior(id3)]=lpdfnorm(x(id3),p6(id3),p7(id3));
[~, dlprior(id3)]=lpdfnorm(x(id3),p6(id3),p7(id3));
elseif nargout == 3
[tmp, dlprior(id3), d2lprior(id3)]=lpdfnorm(x(id3),p6(id3),p7(id3));
[~, dlprior(id3), d2lprior(id3)]=lpdfnorm(x(id3),p6(id3),p7(id3));
end
end
@ -134,9 +134,9 @@ if tt4
return
end
if nargout == 2
[tmp, dlprior(id4)]=lpdfig1(x(id4)-p3(id4),p6(id4),p7(id4));
[~, dlprior(id4)]=lpdfig1(x(id4)-p3(id4),p6(id4),p7(id4));
elseif nargout == 3
[tmp, dlprior(id4), d2lprior(id4)]=lpdfig1(x(id4)-p3(id4),p6(id4),p7(id4));
[~, dlprior(id4), d2lprior(id4)]=lpdfig1(x(id4)-p3(id4),p6(id4),p7(id4));
end
end
@ -166,9 +166,9 @@ if tt6
return
end
if nargout == 2
[tmp, dlprior(id6)]=lpdfig2(x(id6)-p3(id6),p6(id6),p7(id6));
[~, dlprior(id6)]=lpdfig2(x(id6)-p3(id6),p6(id6),p7(id6));
elseif nargout == 3
[tmp, dlprior(id6), d2lprior(id6)]=lpdfig2(x(id6)-p3(id6),p6(id6),p7(id6));
[~, dlprior(id6), d2lprior(id6)]=lpdfig2(x(id6)-p3(id6),p6(id6),p7(id6));
end
end
@ -181,9 +181,9 @@ if tt8
return
end
if nargout==2
[tmp, dlprior(id8)] = lpdfgweibull(x(id8),p6(id8),p7(id8));
[~, dlprior(id8)] = lpdfgweibull(x(id8),p6(id8),p7(id8));
elseif nargout==3
[tmp, dlprior(id8), d2lprior(id8)] = lpdfgweibull(x(id8),p6(id8),p7(id8));
[~, dlprior(id8), d2lprior(id8)] = lpdfgweibull(x(id8),p6(id8),p7(id8));
end
end

View File

@ -36,7 +36,7 @@ function [mu,sigma,offset] = recursive_moments(m0,s0,data,offset)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
[T,n] = size(data);
[T,~] = size(data);
for t = 1:T
tt = t+offset;

View File

@ -96,7 +96,7 @@ TeX = options_.TeX;
str = sprintf(' Param. \t Lower Bound (95%%) \t Mean \t Upper Bound (95%%)');
for l=1:npar
[name,~] = get_the_name(l,TeX,M_,estim_params_,options_.varobs);
name = get_the_name(l,TeX,M_,estim_params_,options_.varobs);
str = sprintf('%s\n %s \t\t %5.4f \t\t %7.5f \t\t %5.4f', str, name, lb95_xparam(l), mean_xparam(l), ub95_xparam(l));
end
disp([str])
@ -104,8 +104,6 @@ disp('')
%% Plot parameters densities
[nbplt,nr,nc,lr,lc,nstar] = pltorg(npar);
if TeX
fidTeX = fopen([M_.fname '_param_density.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by DSMH.m (Dynare).\n');

View File

@ -68,7 +68,7 @@ else
end
%% Call Dynamic Function
[junk, g1] = feval([M_.fname '.dynamic'], ...
[~, g1] = feval([M_.fname '.dynamic'], ...
ones(max(max(M_.lead_lag_incidence)), 1), ...
ones(1, M_.exo_nbr), ...
M_.params, ...
@ -159,12 +159,12 @@ for i = 1:length(lhs)
if g1col ~= 0 && any(g1(:, g1col))
if rhsvars{i}.arRhsIdxs(j) > 0
% Fill AR
[lag, ndiffs] = findLagForVar(var, -rhsvars{i}.lags(j), 0, lhs);
lag = findLagForVar(var, -rhsvars{i}.lags(j), 0, lhs);
oo_.(model_type).(model_name).ar(i, rhsvars{i}.arRhsIdxs(j), lag) = ...
oo_.(model_type).(model_name).ar(i, rhsvars{i}.arRhsIdxs(j), lag) + g1(i, g1col);
elseif rhsvars{i}.ecRhsIdxs(j) > 0
% Fill EC
[lag, ndiffs] = findLagForVar(var, -rhsvars{i}.lags(j), 0, ecRhsVars);
lag = findLagForVar(var, -rhsvars{i}.lags(j), 0, ecRhsVars);
if lag==1
if size(oo_.(model_type).(model_name).ec, 3) < lag
oo_.(model_type).(model_name).ec(i, rhsvars{i}.ecRhsIdxs(j), lag) = 0;

View File

@ -28,7 +28,7 @@ function ext = get_file_extension(file)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
[dir, fname, ext] = fileparts(file);
[~, ~, ext] = fileparts(file);
if ~isempty(ext)
% Removes the leading dot.

View File

@ -58,7 +58,7 @@ if isfield(options, 'datafile')
end
if datafile
[directory,basename,extension] = fileparts(datafile);
[~,basename,extension] = fileparts(datafile);
% Auto-detect extension if not provided
if isempty(extension)
if exist([basename '.m'],'file')

View File

@ -118,11 +118,11 @@ if options_.occbin.smoother.status
bayestopt_.mf = bayestopt_.smoother_var_list(bayestopt_.smoother_mf);
end
else
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = ...
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,~,~,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = ...
occbin.DSGE_smoother(parameters,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_,dataset_,dataset_info);
end
else
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = ...
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,~,~,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = ...
DsgeSmoother(parameters,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_);
end
if ~(options_.occbin.smoother.status && options_.occbin.smoother.inversion_filter)

View File

@ -273,7 +273,7 @@ if t <= last
Hess = Hess + tmp{3};
end
else
[tmp, likk(s+1:end)] = kalman_filter_ss(Y, t, last, a, T, K, iF, log_dF, Z, pp, Zflag);
[~, likk(s+1:end)] = kalman_filter_ss(Y, t, last, a, T, K, iF, log_dF, Z, pp, Zflag);
end
end

View File

@ -218,7 +218,7 @@ if t <= last
Hess = Hess + tmp{3};
end
else
[tmp, likk(s+1:end)] = kalman_filter_ss(Y, t, last, a, T, K, iF, log(dF), Z, pp, Zflag);
[~, likk(s+1:end)] = kalman_filter_ss(Y, t, last, a, T, K, iF, log(dF), Z, pp, Zflag);
end
end

View File

@ -294,7 +294,7 @@ lik(1:s) = .5*lik(1:s);
% Call steady state Kalman filter if needed.
if t<=last
[tmp, lik(s+1:end)] = kalman_filter_ss(Y, t, last, a, T, K, iF, log_dF, Z, pp, Zflag);
[~, lik(s+1:end)] = kalman_filter_ss(Y, t, last, a, T, K, iF, log_dF, Z, pp, Zflag);
end
% Compute minus the log-likelihood.

View File

@ -260,7 +260,7 @@ if t <= last
Hess = Hess + tmp{3};
end
else
[tmp, lik(s+1:end,:)] = univariate_kalman_filter_ss(Y,t,last,a,P,kalman_tol,T,H,Z,pp,Zflag);
[~, lik(s+1:end,:)] = univariate_kalman_filter_ss(Y,t,last,a,P,kalman_tol,T,H,Z,pp,Zflag);
end
end

View File

@ -509,7 +509,7 @@ while notsteady && t<smpl
opts_simul.init_regime = []; %regimes_(t);
opts_simul.waitbar=0;
options_.occbin.simul=opts_simul;
[~, out, ss] = occbin.solver(M_,options_,dr,steady_state,exo_steady_state,exo_det_steady_state);
[~, out] = occbin.solver(M_,options_,dr,steady_state,exo_steady_state,exo_det_steady_state);
end
for jnk=1:nk
if filter_covariance_flag

View File

@ -52,20 +52,20 @@ if options_.occbin.smoother.status && options_.occbin.smoother.inversion_filter
end
else
if options_.occbin.smoother.status
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = occbin.DSGE_smoother(xparam1,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_,dataset_,dataset_info);
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,~,~,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = occbin.DSGE_smoother(xparam1,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_,dataset_,dataset_info);
if oo_.occbin.smoother.error_flag(1)==0
[oo_,yf]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty);
oo_ = store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty);
else
fprintf('\nOccbin: smoother did not succeed. No results will be written to oo_.\n')
end
else
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = DsgeSmoother(xparam1,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_);
[oo_,yf]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty);
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,~,~,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_] = DsgeSmoother(xparam1,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_);
oo_ = store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty);
end
[oo_,yf]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty);
end
if ~options_.nograph
[nbplt,nr,nc,lr,lc,nstar] = pltorg(M_.exo_nbr);
[nbplt,nr,nc,~,~,nstar] = pltorg(M_.exo_nbr);
if ~exist([M_.dname '/graphs'],'dir')
mkdir(M_.dname,'graphs');
end
@ -133,7 +133,7 @@ if estim_params_.nvn
end
end
if ~options_.nograph
[nbplt,nr,nc,lr,lc,nstar] = pltorg(number_of_plots_to_draw);
[nbplt,nr,nc,~,~,nstar] = pltorg(number_of_plots_to_draw);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([M_.dname, '/graphs/' M_.fname '_SmoothedObservationErrors.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by dynare_estimation_1.m (Dynare).\n');
@ -194,7 +194,7 @@ end
%% Historical and smoothed variabes
%%
if ~options_.nograph
[nbplt,nr,nc,lr,lc,nstar] = pltorg(n_varobs);
[nbplt,nr,nc,~,~,nstar] = pltorg(n_varobs);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([M_.dname, '/graphs/' M_.fname '_HistoricalAndSmoothedVariables.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by dynare_estimation_1.m (Dynare).\n');

View File

@ -43,7 +43,7 @@ fprintf(fid,'%s \n','\begin{document}');
%% Include LaTeX files from <fname>/latex/ directory, except the standalone ones
TeX_Files=dir([M_.dname filesep 'latex' filesep '*.tex']);
for ii=1:length(TeX_Files)
[pathstr,f_name,ext] = fileparts(TeX_Files(ii).name);
[~,f_name] = fileparts(TeX_Files(ii).name);
if ~strcmp(f_name, 'dynamic') && ...
~strcmp(f_name, 'static') && ...
~strcmp(f_name, 'original') && ...
@ -55,7 +55,7 @@ end
%% Output directory
TeX_Files=dir([M_.dname filesep 'Output' filesep M_.fname '*.tex']);
for ii=1:length(TeX_Files)
[pathstr,f_name,ext] = fileparts(TeX_Files(ii).name);
[~,f_name] = fileparts(TeX_Files(ii).name);
if ~strcmp(TeX_Files(ii).name,f_name_binder)
fprintf(fid,'%s \n',['\include{', M_.dname '/Output' '/',f_name,'}']);
end
@ -64,7 +64,7 @@ end
%% graphs directory
TeX_Files=dir([M_.dname filesep 'graphs' filesep M_.fname '*.tex']);
for ii=1:length(TeX_Files)
[pathstr,f_name,ext] = fileparts(TeX_Files(ii).name);
[~,f_name] = fileparts(TeX_Files(ii).name);
if ~strcmp(TeX_Files(ii).name,f_name_binder)
fprintf(fid,'%s \n',['\include{', M_.dname '/graphs' '/',f_name,'}']);
end
@ -73,7 +73,7 @@ end
%% Identification directory
TeX_Files=dir([M_.dname filesep 'identification' filesep M_.fname '*.tex']);
for ii=1:length(TeX_Files)
[pathstr,f_name,ext] = fileparts(TeX_Files(ii).name);
[~,f_name] = fileparts(TeX_Files(ii).name);
if ~strcmp(TeX_Files(ii).name,f_name_binder)
fprintf(fid,'%s \n',['\include{', M_.dname '/identification' '/',f_name,'}']);
end
@ -83,7 +83,7 @@ end
%% Identification/Output directory
TeX_Files=dir([M_.dname filesep 'identification' filesep 'Output' filesep M_.fname '*.tex']);
for ii=1:length(TeX_Files)
[pathstr,f_name,ext] = fileparts(TeX_Files(ii).name);
[~,f_name] = fileparts(TeX_Files(ii).name);
if ~strcmp(TeX_Files(ii).name,f_name_binder)
fprintf(fid,'%s \n',['\include{', M_.dname '/identification/Output' '/',f_name,'}']);
end
@ -92,7 +92,7 @@ end
%% GSA directory
TeX_Files=dir([M_.dname filesep 'gsa' filesep M_.fname '*.tex']);
for ii=1:length(TeX_Files)
[pathstr,f_name,ext] = fileparts(TeX_Files(ii).name);
[~,f_name] = fileparts(TeX_Files(ii).name);
if ~strcmp(TeX_Files(ii).name,f_name_binder)
fprintf(fid,'%s \n',['\include{', M_.dname '/gsa' '/',f_name,'}']);
end
@ -101,7 +101,7 @@ end
%% GSA/Output directory
TeX_Files=dir([M_.dname filesep 'gsa' filesep 'Output' filesep M_.fname '*.tex']);
for ii=1:length(TeX_Files)
[pathstr,f_name,ext] = fileparts(TeX_Files(ii).name);
[~,f_name] = fileparts(TeX_Files(ii).name);
if ~strcmp(TeX_Files(ii).name,f_name_binder)
fprintf(fid,'%s \n',['\include{', M_.dname '/gsa/Output' '/',f_name,'}']);
end
@ -122,14 +122,14 @@ for level1_iter = 1:numsubdir_level1
for level2_iter = 1:numsubdir_level2
TeX_Files=dir([M_.dname filesep 'gsa' filesep dirinfo_parent(level1_iter).name filesep dirinfo_subfolder(level2_iter).name filesep M_.fname '*.tex']);
for ii=1:length(TeX_Files)
[pathstr,f_name,ext] = fileparts(TeX_Files(ii).name);
[~,f_name] = fileparts(TeX_Files(ii).name);
if ~strcmp(TeX_Files(ii).name,f_name_binder)
fprintf(fid,'%s \n',['\include{', M_.dname '/gsa/',dirinfo_parent(level1_iter).name '/' dirinfo_subfolder(level2_iter).name ,'/',f_name,'}']);
end
end
TeX_Files=dir([M_.dname filesep 'gsa' filesep dirinfo_parent(level1_iter).name filesep dirinfo_subfolder(level2_iter).name filesep 'Output' filesep M_.fname '*.tex']);
for ii=1:length(TeX_Files)
[pathstr,f_name,ext] = fileparts(TeX_Files(ii).name);
[~,f_name] = fileparts(TeX_Files(ii).name);
if ~strcmp(TeX_Files(ii).name,f_name_binder)
fprintf(fid,'%s \n',['\include{', M_.dname '/gsa/', dirinfo_parent(level1_iter).name '/' dirinfo_subfolder(level2_iter).name, '/Output' '/',f_name,'}']);
end

View File

@ -57,7 +57,7 @@ x = endo_simul(:);
model_dynamic = str2func([M_.fname,'.dynamic']);
z = x(find(lead_lag_incidence'));
[res,A] = model_dynamic(z, exo_simul, params, steady_state,2);
[~,A] = model_dynamic(z, exo_simul, params, steady_state,2);
nnzA = nnz(A);
LB = repmat(lb,periods,1);

View File

@ -18,7 +18,7 @@ function o2WysrOISH = load_m_file_data_legacy(datafile, U7ORsJ0vy3)
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
cXDHdrXnqo5KwwVpTRuc6OprAW = datafile(1:end-2);
[pathtocXDHdrXnqo5KwwVpTRuc6OprAW,cXDHdrXnqo5KwwVpTRuc6OprAW,~] = fileparts(cXDHdrXnqo5KwwVpTRuc6OprAW);
[pathtocXDHdrXnqo5KwwVpTRuc6OprAW,cXDHdrXnqo5KwwVpTRuc6OprAW] = fileparts(cXDHdrXnqo5KwwVpTRuc6OprAW);
if ~isempty(pathtocXDHdrXnqo5KwwVpTRuc6OprAW)
% We need to change directory, first we keep the current directory in memory...

View File

@ -31,7 +31,7 @@ function sigma = long_run_variance(data,band)
verbose = 1;
if nargin<2
[T,m] = size(data);
[T,~] = size(data);
band = ceil(T^(1/4));
if verbose
disp(['Bandwidth parameter is equal to ' num2str(band) '.'])

View File

@ -60,7 +60,7 @@ try
eigval = ordeig(ss, tt);
select = abs(eigval) < qz_criterium;
sdim = sum(select);
[ss, tt, qq, zz] = ordqz(ss, tt, qq, zz, select);
[ss, tt, ~, zz] = ordqz(ss, tt, qq, zz, select);
eigval = ordeig(ss, tt);
catch
info = 1; % Not as precise as lapack's info!

View File

@ -153,10 +153,10 @@ exo = [oo_.exo_steady_state; oo_.exo_det_steady_state];
for b=1:nb
if options_.bytecode
if nb == 1
[res, jacob] = bytecode(M_, options_, dr.ys, exo, M_.params, dr.ys, 1, exo, ...
[~, jacob] = bytecode(M_, options_, dr.ys, exo, M_.params, dr.ys, 1, exo, ...
'evaluate', 'static');
else
[res, jacob] = bytecode(M_, options_, dr.ys, exo, M_.params, dr.ys, 1, exo, ...
[~, jacob] = bytecode(M_, options_, dr.ys, exo, M_.params, dr.ys, 1, exo, ...
'evaluate', 'static', 'block_decomposed', ['block=' ...
int2str(b)]);
end
@ -169,7 +169,7 @@ for b=1:nb
M_.block_structure_stat.block(b).g1_sparse_colptr, T);
n_vars_jacob=size(jacob,2);
else
[res, T_order, T] = feval([M_.fname '.sparse.static_resid'], dr.ys, exo, M_.params);
[~, T_order, T] = feval([M_.fname '.sparse.static_resid'], dr.ys, exo, M_.params);
jacob = feval([M_.fname '.sparse.static_g1'], dr.ys, exo, M_.params, M_.static_g1_sparse_rowval, M_.static_g1_sparse_colval, M_.static_g1_sparse_colptr, T_order, T);
n_vars_jacob=M_.endo_nbr;
end

View File

@ -40,7 +40,7 @@ switch order
if round(order)-order
error('The second input argument (order) has to be an integer!')
end
[T,n] = size(X);
[~,n] = size(X);
c = mean(X);
m = zeros(n,1);
for i=1:n

View File

@ -93,7 +93,7 @@ for i=M_.maximum_lag:-1:2
end
[A,B] = kalman_transition_matrix(oo_.dr,ikx',1:nx);
[vx, u] = lyapunov_symm(A,B*M_.Sigma_e*B',options_.lyapunov_fixed_point_tol,options_.qz_criterium,options_.lyapunov_complex_threshold,[],options_.debug);
[~, u] = lyapunov_symm(A,B*M_.Sigma_e*B',options_.lyapunov_fixed_point_tol,options_.qz_criterium,options_.lyapunov_complex_threshold,[],options_.debug);
iky = iv(ivar);
if ~isempty(u)
iky = iky(find(any(abs(ghx(iky,:)*u) < options_.schur_vec_tol,2)));

View File

@ -61,8 +61,6 @@ if isfield(oo_,[TYPE 'TheoreticalMoments'])
% INITIALIZATION:
oo_ = initialize_output_structure(var1,var2,nar,type,oo_);
delete([PATH fname '_' TYPE 'Correlations*'])
[nvar,vartan,NumberOfFiles] = ...
dsge_simulated_theoretical_correlation(SampleSize,nar,M_,options_,oo_,type);
else
if ~isnan(temporary_structure_2(nar))
%Nothing to do.
@ -143,4 +141,4 @@ switch moment
oo_.([type, 'TheoreticalMoments']).dsge.correlation.(moment).(var1).(var2)(lag,1) = {result};
otherwise
disp('fill_output_structure:: Unknown field!')
end
end

View File

@ -244,9 +244,9 @@ end
function y = get_filtered_time_series(y, m, options_)
if options_.hp_filter && ~options_.one_sided_hp_filter && ~options_.bandpass.indicator
[hptrend,y] = sample_hp_filter(y,options_.hp_filter);
[~,y] = sample_hp_filter(y,options_.hp_filter);
elseif ~options_.hp_filter && options_.one_sided_hp_filter && ~options_.bandpass.indicator
[hptrend,y] = one_sided_hp_filter(y,options_.one_sided_hp_filter);
[~,y] = one_sided_hp_filter(y,options_.one_sided_hp_filter);
elseif ~options_.hp_filter && ~options_.one_sided_hp_filter && options_.bandpass.indicator
data_temp=dseries(y,'0q1');
data_temp=baxter_king_filter(data_temp,options_.bandpass.passband(1),options_.bandpass.passband(2),options_.bandpass.K);

View File

@ -89,7 +89,7 @@ vlog_Y_a = -0.5*nvar*fss*log(2*pi) + fss*log(abs(det(A0xhat))) + Yexpt
logMarLHres = 0; % Initialize log of the marginal likelihood (restricted or constant parameters).
for ki=1:fss %ndobs+1:fss % Forward recursion to get the marginal likelihood. See F on p.19 and pp. 48-49.
%---- Restricted log marginal likelihood function (constant parameters).
[A0l,A0u] = lu(A0xhat);
[~,A0u] = lu(A0xhat);
ada = sum(log(abs(diag(A0u)))); % log|A0|
termexp = y(ki,:)*A0xhat - phi(ki,:)*Apxhat; % 1-by-nvar
logMarLHres = logMarLHres - (0.5*nvar)*log(2*pi) + ada - 0.5*termexp*termexp'; % log value
@ -148,7 +148,7 @@ for k=1:nvar
%------ Computing p(a0_k|Y,a_others) at some point such as the peak along the dimensions of indx_ks.
Vk = Tinv{k}\Wcell{k}; %V_k on p.71 of Forecast (II).
gbeta = Vk\bk; % inv(V_k)*b_k on p.71 of Forecast (II) where alpha_k = b_k in our notation.
[Vtq,Vtr]=qr(Vk',0); %To get inv(V_k)'*inv(V_k) in (*) on p.71 of Forecast (II).
[~,Vtr]=qr(Vk',0); %To get inv(V_k)'*inv(V_k) in (*) on p.71 of Forecast (II).
%
vlog(draws) = 0.5*(fss+nk)*log(fss)-log(abs(det(Vk)))-0.5*(nk-1)*log(2*pi)-...
0.5*(fss+1)*log(2)-gammaln(0.5*(fss+1))+fss*log(abs(gbeta(1)))-...
@ -164,12 +164,12 @@ for k=1:nvar
else
skipline()
disp('The last(6th) column or equation in A0 with no Gibbs draws')
[A0gbs1, Wcell] = fn_gibbsrvar(A0gbs0,UT,nvar,fss,n0,indx_ks)
[~, Wcell] = fn_gibbsrvar(A0gbs0,UT,nvar,fss,n0,indx_ks)
%------ 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.
Vk = Tinv{k}\Wcell{k}; %V_k on p.71 of Forecast (II).
gbeta = Vk\bk; % inv(V_k)*b_k on p.71 of Forecast (II) where alpha_k = b_k in our notation.
[Vtq,Vtr]=qr(Vk',0); %To get inv(V_k)'*inv(V_k) in (*) on p.71 of Forecast (II).
[~,Vtr]=qr(Vk',0); %To get inv(V_k)'*inv(V_k) in (*) on p.71 of Forecast (II).
%
vloglast = 0.5*(fss+nk)*log(fss)-log(abs(det(Vk)))-0.5*(nk-1)*log(2*pi)-...
0.5*(fss+1)*log(2)-gammaln(0.5*(fss+1))+fss*log(abs(gbeta(1)))-...

View File

@ -209,7 +209,7 @@ nexo=1;
% Arranged data information, WITHOUT dummy obs when 0 after mu is used.
% See fn_rnrprior_covres_dobs.m for using the dummy observations as part of
% an explicit prior.
[xtx,xty,yty,fss,phi,y,ncoef,xr,Bh] = fn_dataxy(nvar,options_.ms.nlags,xdgel,mu,0,nexo);
[xtx,xty,yty,fss,phi,y,ncoef] = fn_dataxy(nvar,options_.ms.nlags,xdgel,mu,0,nexo);
%======================================================================
@ -239,7 +239,7 @@ if indxPrior
%*** Obtains asymmetric prior (with no linear restrictions) with dummy observations as part of an explicit prior (i.e,
% reflected in Hpmulti and Hpinvmulti). See Forecast II, pp.69a-69b for details.
if 1 % Liquidity effect prior on both MS and MD equations.
[Pi,H0multi,Hpmulti,H0invmulti,Hpinvmulti] = fn_rnrprior_covres_dobs(nvar,q_m,options_.ms.nlags,xdgel,mu,indxDummy,hpmsmd,indxmsmdeqn);
[Pi,H0multi,Hpmulti] = fn_rnrprior_covres_dobs(nvar,q_m,options_.ms.nlags,xdgel,mu,indxDummy,hpmsmd,indxmsmdeqn);
else
[Pi,H0multi,Hpmulti,H0invmulti,Hpinvmulti] = fn_rnrprior(nvar,q_m,options_.ms.nlags,xdgel,mu);
end
@ -268,12 +268,12 @@ else
crit = 1.0e-9;
nit = 10000;
%
[fhat,xhat,grad,Hhat,itct,fcount,retcodehat] = csminwel('fn_a0freefun',x,H0,'fn_a0freegrad',crit,nit,Ui,nvar,n0,fss,H0inv);
[~,xhat] = csminwel('fn_a0freefun',x,H0,'fn_a0freegrad',crit,nit,Ui,nvar,n0,fss,H0inv);
A0hat = fn_tran_b2a(xhat,Ui,nvar,n0);
xhat = fn_tran_a2b(A0hat,Ui,nvar,n0);
[Aphat,ghat] = fn_gfmean(xhat,Pmat,Vi,nvar,ncoef,n0,np);
Aphat = fn_gfmean(xhat,Pmat,Vi,nvar,ncoef,n0,np);
if indxC0Pres
Fhatur0P = Fhat; % ur: unrestriced across A0 and A+
for ki = 1:size(ixmC0Pres,1) % loop through the number of equations in which

View File

@ -28,7 +28,7 @@ function plot_ms_probabilities(computed_probabilities, options_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
[T,num_grand_regimes] = size(computed_probabilities);
[T,~] = size(computed_probabilities);
num_chains = length(options_.ms.ms_chain);
for i=1:num_chains
chains(i).num_regimes = length(options_.ms.ms_chain(i).regime);

View File

@ -48,7 +48,7 @@ end
nvar = length(options_.varobs); % number of endogenous variables
nexo = 1;
[Uiconst,Viconst,n0,np,ixmC0Pres,Qi,Ri] = exclusions(nvar,nexo,options_.ms );
[~,~,~,~,~,Qi,Ri] = exclusions(nvar,nexo,options_.ms );
% order column constraints by rank
QQranks = zeros(nvar,2);

View File

@ -111,9 +111,9 @@ for t=1:sample_size
if pruning
yhat_ = bsxfun(@minus,StateVectors_,state_variables_steady_state_);
if order == 2
[tmp, tmp_] = local_state_space_iteration_2(yhat,zeros(number_of_structural_innovations,number_of_particles),ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,steadystate,ThreadsOptions.local_state_space_iteration_2);
tmp = local_state_space_iteration_2(yhat,zeros(number_of_structural_innovations,number_of_particles),ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,steadystate,ThreadsOptions.local_state_space_iteration_2);
elseif order == 3
[tmp, tmp_] = local_state_space_iteration_3(yhat_, zeros(number_of_structural_innovations,number_of_particles), ghx, ghu, ghxx, ghuu, ghxu, ghs2, ghxxx, ghuuu, ghxxu, ghxuu, ghxss, ghuss, steadystate, ThreadsOptions.local_state_space_iteration_3, pruning);
tmp = local_state_space_iteration_3(yhat_, zeros(number_of_structural_innovations,number_of_particles), ghx, ghu, ghxx, ghuu, ghxu, ghs2, ghxxx, ghuuu, ghxxu, ghxuu, ghxss, ghuss, steadystate, ThreadsOptions.local_state_space_iteration_3, pruning);
else
error('Pruning is not available for orders > 3');
end

View File

@ -17,7 +17,7 @@ function [StateMu,StateSqrtP,StateWeights] = fit_gaussian_mixture(X,X_weights,St
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
[dim,Ndata] = size(X);
[~,Ndata] = size(X);
M = size(StateMu,2) ;
if check % Ensure that covariances don't collapse
MIN_COVAR_SQRT = sqrt(eps);
@ -26,7 +26,7 @@ end
eold = -Inf;
for n=1:niters
% Calculate posteriors based on old parameters
[prior,likelihood,marginal,posterior] = probability3(StateMu,StateSqrtP,StateWeights,X,X_weights);
[~,~,marginal,posterior] = probability3(StateMu,StateSqrtP,StateWeights,X,X_weights);
e = sum(log(marginal));
if (n > 1 && abs((e - eold)/eold) < crit)
return;
@ -40,7 +40,7 @@ for n=1:niters
diffs = bsxfun(@minus,X,StateMu(:,j));
tpost = (1/sqrt(new_pr(j)))*sqrt(posterior(j,:));
diffs = bsxfun(@times,diffs,tpost);
[foo,tcov] = qr2(diffs',0);
[~,tcov] = qr2(diffs',0);
StateSqrtP(:,:,j) = tcov';
if check
if min(abs(diag(StateSqrtP(:,:,j)))) < MIN_COVAR_SQRT

View File

@ -32,7 +32,7 @@ for iter=1:300
for i=1:g
dist(i,:) = sum(bsxfun(@power,bsxfun(@minus,x,c(:,i)),2));
end
[rien,ind] = min(dist) ;
[~,ind] = min(dist) ;
if isequal(ind,indold)
break ;
end

View File

@ -172,11 +172,11 @@ for t=1:sample_size
if pruning
yhat_ = bsxfun(@minus,StateVectors_(:,i),state_variables_steady_state_);
if order == 2
[tmp, ~] = local_state_space_iteration_2(yhat, zeros(number_of_structural_innovations, 1), ghx, ghu, constant, ghxx, ghuu, ghxu, yhat_, steadystate, options_.threads.local_state_space_iteration_2);
tmp = local_state_space_iteration_2(yhat, zeros(number_of_structural_innovations, 1), ghx, ghu, constant, ghxx, ghuu, ghxu, yhat_, steadystate, options_.threads.local_state_space_iteration_2);
elseif order == 3
[tmp, tmp_] = local_state_space_iteration_3(yhat_, zeros(number_of_structural_innovations, 1), ghx, ghu, ghxx, ghuu, ghxu, ghs2, ghxxx, ghuuu, ghxxu, ghxuu, ghxss, ghuss, steadystate, options_.threads.local_state_space_iteration_3, pruning);
tmp = local_state_space_iteration_3(yhat_, zeros(number_of_structural_innovations, 1), ghx, ghu, ghxx, ghuu, ghxu, ghs2, ghxxx, ghuuu, ghxxu, ghxuu, ghxss, ghuss, steadystate, options_.threads.local_state_space_iteration_3, pruning);
else
error('Pruning is not available for orders > 3');
error('Pruning is not available for orders > 3');
end
else
if order == 2

View File

@ -58,7 +58,7 @@ function T = reduced_rank_cholesky(X)
if X_is_not_positive_definite
n = length(X);
[U,D] = eig(X);
[tmp,max_elements_indices] = max(abs(U),[],1);
[~,max_elements_indices] = max(abs(U),[],1);
negloc = (U(max_elements_indices+(0:n:(n-1)*n))<0);
U(:,negloc) = -U(:,negloc);
D = diag(D);

View File

@ -78,7 +78,7 @@ elseif options_.steadystate_flag
end
end
ys_init(k_inst) = inst_val;
[xx,params] = evaluate_steady_state_file(ys_init,exo_ss,M_,options_,~options_.steadystate.nocheck); %run steady state file again to update parameters
[~,params] = evaluate_steady_state_file(ys_init,exo_ss,M_,options_,~options_.steadystate.nocheck); %run steady state file again to update parameters
[~,~,steady_state] = nl_func(inst_val); %compute and return steady state
else
xx = ys_init(1:M_.orig_endo_nbr);
@ -149,7 +149,7 @@ resids1 = y+A*mult;
if inst_nbr == 1
r1 = sqrt(resids1'*resids1);
else
[q,r,e] = qr([A y]');
[~,r] = qr([A y]');
k = size(A,1)+(1-inst_nbr:0);
r1 = r(end,k)';
end
@ -167,7 +167,7 @@ end
function result = check_static_model(ys,exo_ss,M_,options_)
result = false;
if (options_.bytecode)
[res, ~] = bytecode('static', M_, options, ys, exo_ss, M_.params, 'evaluate');
res = bytecode('static', M_, options, ys, exo_ss, M_.params, 'evaluate');
else
res = feval([M_.fname '.sparse.static_resid'], ys, exo_ss, M_.params);
end

View File

@ -53,7 +53,7 @@ A22 = A2(il,:);
B1 = B(nil,:);
B2 = B(il,:);
[Q1,R1,E1] = qr([A12; A22]);
[Q1,R1] = qr([A12; A22]);
n1 = sum(abs(diag(R1)) > 1e-8);
Q1_12 = Q1(1:nm_nbr,n1+1:end);

View File

@ -31,7 +31,7 @@ function [fval, grad, hess, exit_flag]=analytic_gradient_wrapper(x, fcn, varargi
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
[fval, info, exit_flag, grad, hess] = fcn(x, varargin{:});
[fval, ~, exit_flag, grad, hess] = fcn(x, varargin{:});
if size(grad,2)==1
grad=grad'; %should be row vector for Matlab; exception lsqnonlin where Jacobian is required
end

View File

@ -684,7 +684,7 @@ while irun <= myeval(opts.Restarts) % for-loop does not work with resume
for namecell = filenames(:)'
name = namecell{:};
[fid, err] = fopen(['./' filenameprefix name '.dat'], 'w');
fid = fopen(['./' filenameprefix name '.dat'], 'w');
if fid < 1 % err ~= 0
warning(['could not open ' filenameprefix name '.dat']);
filenames(find(strcmp(filenames,name))) = [];
@ -1151,7 +1151,7 @@ while irun <= myeval(opts.Restarts) % for-loop does not work with resume
% TODO: this is not in compliance with the paper Hansen&Ros2010,
% where simply arnorms = arnorms(end:-1:1) ?
[arnorms, idxnorms] = sort(sqrt(sum(arzneg.^2, 1)));
[ignore, idxnorms] = sort(idxnorms); % inverse index
[~, idxnorms] = sort(idxnorms); % inverse index
arnormfacs = arnorms(end:-1:1) ./ arnorms;
% arnormfacs = arnorms(randperm(neg.mu)) ./ arnorms;
arnorms = arnorms(end:-1:1); % for the record
@ -1596,7 +1596,7 @@ while irun <= myeval(opts.Restarts) % for-loop does not work with resume
for namecell = filenames(:)'
name = namecell{:};
[fid, err] = fopen(['./' filenameprefix name '.dat'], 'a');
fid = fopen(['./' filenameprefix name '.dat'], 'a');
if fid < 1 % err ~= 0
warning(['could not open ' filenameprefix name '.dat']);
else
@ -1981,7 +1981,7 @@ end
% sort inar
if nargin < 3 || isempty(idx)
[sar, idx] = sort(inar);
sar = sort(inar);
else
sar = inar(idx);
end
@ -2070,8 +2070,8 @@ end
%%% compute rank changes into rankDelta
% compute ranks
[ignore, idx] = sort([arf1 arf2]);
[ignore, ranks] = sort(idx);
[~, idx] = sort([arf1 arf2]);
[~, ranks] = sort(idx);
ranks = reshape(ranks, lam, 2)';
rankDelta = ranks(1,:) - ranks(2,:) - sign(ranks(1,:) - ranks(2,:));
@ -2199,7 +2199,7 @@ end
% plot fitness etc
foffset = 1e-99;
dfit = d.f(:,6)-min(d.f(:,6));
[ignore, idxbest] = min(dfit);
[~, idxbest] = min(dfit);
dfit(dfit<1e-98) = NaN;
subplot(2,2,1); hold off;
dd = abs(d.f(:,7:8)) + foffset;
@ -2256,7 +2256,7 @@ ax(2) = max(minxend, ax(2));
axis(ax);
% add some annotation lines
[ignore, idx] = sort(d.x(end,6:end));
[~, idx] = sort(d.x(end,6:end));
% choose no more than 25 indices
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);
@ -2300,7 +2300,7 @@ ax = axis;
ax(2) = max(minxend, ax(2));
axis(ax);
% add some annotation lines
[ignore, idx] = sort(d.std(end,6:end));
[~, idx] = sort(d.std(end,6:end));
% choose no more than 25 indices
idxs = round(linspace(1, size(d.x,2)-5, min(size(d.x,2)-5, 25)));
yy = repmat(NaN, 2, size(d.std,2)-5);
@ -2380,15 +2380,14 @@ function f=fmixranks(x)
N = size(x,1);
f=(10.^(0*(0:(N-1))/(N-1))*x.^2).^0.5;
if size(x, 2) > 1 % compute ranks, if it is a population
[ignore, idx] = sort(f);
[ignore, ranks] = sort(idx);
[~, idx] = sort(f);
k = 9; % number of solutions randomly permuted, lambda/2-1
% works still quite well (two time slower)
for i = k+1:k-0:size(x,2)
idx(i-k+(1:k)) = idx(i-k+randperm(k));
end
%disp([ranks' f'])
[ignore, ranks] = sort(idx);
[~, ranks] = sort(idx);
%disp([ranks' f'])
%pause
f = ranks+1e-9*randn(1,1);

View File

@ -107,23 +107,23 @@ switch minimizer_algorithm
if options_.analytic_derivation || (isfield(options_,'mom') && options_.mom.analytic_jacobian==1) %use wrapper
func = @(x) analytic_gradient_wrapper(x,objective_function,varargin{:});
if ~isoctave
[opt_par_values,fval,exitflag,output,lamdba,grad,hessian_mat] = ...
[opt_par_values,fval,exitflag,~,~,~,hessian_mat] = ...
fmincon(func,start_par_value,[],[],[],[],bounds(:,1),bounds(:,2),[],optim_options);
else
% Under Octave, use a wrapper, since fmincon() does not have an 11th
% arg. Also, only the first 4 output arguments are available.
[opt_par_values,fval,exitflag,output] = ...
[opt_par_values,fval,exitflag] = ...
fmincon(func,start_par_value,[],[],[],[],bounds(:,1),bounds(:,2),[],optim_options);
end
else
if ~isoctave
[opt_par_values,fval,exitflag,output,lamdba,grad,hessian_mat] = ...
[opt_par_values,fval,exitflag,~,~,~,hessian_mat] = ...
fmincon(objective_function,start_par_value,[],[],[],[],bounds(:,1),bounds(:,2),[],optim_options,varargin{:});
else
% Under Octave, use a wrapper, since fmincon() does not have an 11th
% arg. Also, only the first 4 output arguments are available.
func = @(x) objective_function(x,varargin{:});
[opt_par_values,fval,exitflag,output] = ...
[opt_par_values,fval,exitflag] = ...
fmincon(func,start_par_value,[],[],[],[],bounds(:,1),bounds(:,2),[],optim_options);
end
end
@ -177,7 +177,7 @@ switch minimizer_algorithm
end
sa_options.initial_step_length= sa_options.initial_step_length*ones(npar,1); %bring step length to correct vector size
sa_options.step_length_c= sa_options.step_length_c*ones(npar,1); %bring step_length_c to correct vector size
[opt_par_values, fval,exitflag, n_accepted_draws, n_total_draws, n_out_of_bounds_draws, t, vm] =...
[opt_par_values, fval,exitflag] =...
simulated_annealing(objective_function,start_par_value,sa_options,LB,UB,varargin{:});
case 3
if isoctave && ~user_has_octave_forge_package('optim')
@ -269,7 +269,7 @@ switch minimizer_algorithm
analytic_grad=[];
end
% Call csminwell.
[fval,opt_par_values,grad,inverse_hessian_mat,itct,fcount,exitflag] = ...
[fval,opt_par_values,~,inverse_hessian_mat,~,~,exitflag] = ...
csminwel1(objective_function, start_par_value, H0, analytic_grad, crit, nit, numgrad, epsilon, Verbose, Save_files, varargin{:});
hessian_mat=inv(inverse_hessian_mat);
case 5
@ -337,7 +337,7 @@ switch minimizer_algorithm
hess_info.robust=robust;
% here we force 7th input argument (flagg) to be 0, since outer product
% gradient Hessian is handled in dynare_estimation_1
[opt_par_values,hessian_mat,gg,fval,invhess,new_rat_hess_info] = newrat(objective_function,start_par_value,bounds,analytic_grad,crit,nit,0,Verbose,Save_files,hess_info,prior_information.p2,options_.gradient_epsilon,parameter_names,varargin{:}); %hessian_mat is the plain outer product gradient Hessian
[opt_par_values,hessian_mat,~,fval,~,new_rat_hess_info] = newrat(objective_function,start_par_value,bounds,analytic_grad,crit,nit,0,Verbose,Save_files,hess_info,prior_information.p2,options_.gradient_epsilon,parameter_names,varargin{:}); %hessian_mat is the plain outer product gradient Hessian
new_rat_hess_info.new_rat_hess_info = new_rat_hess_info;
new_rat_hess_info.newratflag = newratflag;
if options_.analytic_derivation
@ -453,7 +453,7 @@ switch minimizer_algorithm
end
warning('off','CMAES:NonfinitenessRange');
warning('off','CMAES:InitialSigma');
[x, fval, COUNTEVAL, STOPFLAG, OUT, BESTEVER] = cmaes(func2str(objective_function),start_par_value,H0,cmaesOptions,varargin{:});
[~, ~, ~, ~, ~, BESTEVER] = cmaes(func2str(objective_function),start_par_value,H0,cmaesOptions,varargin{:});
opt_par_values=BESTEVER.x;
fval=BESTEVER.f;
case 10
@ -498,7 +498,7 @@ switch minimizer_algorithm
case 11
options_.cova_compute = 0;
subvarargin = [varargin(1), varargin(3:6), varargin(8)];
[opt_par_values, stdh, lb_95, ub_95, med_param] = online_auxiliary_filter(start_par_value, subvarargin{:});
opt_par_values = online_auxiliary_filter(start_par_value, subvarargin{:});
case 12
if isoctave
error('Option mode_compute=12 is not available under Octave')
@ -512,10 +512,10 @@ switch minimizer_algorithm
if ~isempty(options_.optim_opt)
options_list = read_key_value_string(options_.optim_opt);
SupportedListOfOptions = {'CreationFcn', 'Display', 'DisplayInterval', 'FunctionTolerance', ...
'FunValCheck', 'HybridFcn', 'InertiaRange', 'InitialSwarmMatrix', 'InitialSwarmSpan', ...
'MaxIterations', 'MaxStallIterations', 'MaxStallTime', 'MaxTime', ...
'MinNeighborsFraction', 'ObjectiveLimit', 'OutputFcn', 'PlotFcn', 'SelfAdjustmentWeight', ...
'SocialAdjustmentWeight', 'SwarmSize', 'UseParallel', 'UseVectorized'};
'FunValCheck', 'HybridFcn', 'InertiaRange', 'InitialSwarmMatrix', 'InitialSwarmSpan', ...
'MaxIterations', 'MaxStallIterations', 'MaxStallTime', 'MaxTime', ...
'MinNeighborsFraction', 'ObjectiveLimit', 'OutputFcn', 'PlotFcn', 'SelfAdjustmentWeight', ...
'SocialAdjustmentWeight', 'SwarmSize', 'UseParallel', 'UseVectorized'};
for i=1:rows(options_list)
if ismember(options_list{i,1}, SupportedListOfOptions)
particleswarmOptions = optimoptions(particleswarmOptions, options_list{i,1}, options_list{i,2});
@ -537,7 +537,7 @@ switch minimizer_algorithm
FVALS = zeros(particleswarmOptions.SwarmSize, 1);
while p<=particleswarmOptions.SwarmSize
candidate = rand(numberofvariables, 1).*(UB-LB)+LB;
[fval, info, exit_flag] = objfun(candidate);
[fval, ~, exit_flag] = objfun(candidate);
if exit_flag
particleswarmOptions.InitialSwarmMatrix(p,:) = transpose(candidate);
FVALS(p) = fval;
@ -552,7 +552,7 @@ switch minimizer_algorithm
% Define penalized objective.
objfun = @(x) penalty_objective_function(x, objective_function, penalty, varargin{:});
% Minimize the penalized objective (note that the penalty is not updated).
[opt_par_values, fval, exitflag, output] = particleswarm(objfun, length(start_par_value), LB, UB, particleswarmOptions);
[opt_par_values, fval, exitflag] = particleswarm(objfun, length(start_par_value), LB, UB, particleswarmOptions);
opt_par_values = opt_par_values(:);
case 13
% Matlab's lsqnonlin (Optimization toolbox needed).
@ -586,15 +586,15 @@ switch minimizer_algorithm
optim_options.SpecifyObjectiveGradient = true;
end
func = @(x) analytic_gradient_wrapper(x,objective_function,varargin{:});
[opt_par_values,Resnorm,fval,exitflag,OUTPUT,LAMBDA,JACOB] = ...
[opt_par_values,~,fval,exitflag] = ...
lsqnonlin(func,start_par_value,bounds(:,1),bounds(:,2),optim_options);
else
if ~isoctave
[opt_par_values,Resnorm,fval,exitflag,OUTPUT,LAMBDA,JACOB] = lsqnonlin(objective_function,start_par_value,bounds(:,1),bounds(:,2),optim_options,varargin{:});
[opt_par_values,~,fval,exitflag] = lsqnonlin(objective_function,start_par_value,bounds(:,1),bounds(:,2),optim_options,varargin{:});
else
% Under Octave, use a wrapper, since lsqnonlin() does not have a 6th arg
func = @(x)objective_function(x,varargin{:});
[opt_par_values,Resnorm,fval,exitflag,OUTPUT,LAMBDA,JACOB] = lsqnonlin(func,start_par_value,bounds(:,1),bounds(:,2),optim_options);
[opt_par_values,~,fval,exitflag] = lsqnonlin(func,start_par_value,bounds(:,1),bounds(:,2),optim_options);
end
end
case 101
@ -656,7 +656,7 @@ switch minimizer_algorithm
end
end
func = @(x)objective_function(x,varargin{:});
[opt_par_values,fval,exitflag,output] = simulannealbnd(func,start_par_value,bounds(:,1),bounds(:,2),optim_options);
[opt_par_values,fval,exitflag] = simulannealbnd(func,start_par_value,bounds(:,1),bounds(:,2),optim_options);
otherwise
if ischar(minimizer_algorithm)
if exist(minimizer_algorithm)

View File

@ -318,7 +318,7 @@ elseif options.solve_algo == 11
mcp_data.func = f;
mcp_data.args = varargin;
try
[x, fval, jac, mu] = pathmcp(x,omcppath.lb,omcppath.ub,'mcp_func',omcppath.A,omcppath.b,omcppath.t,omcppath.mu0);
x = pathmcp(x,omcppath.lb,omcppath.ub,'mcp_func',omcppath.A,omcppath.b,omcppath.t,omcppath.mu0);
catch
errorflag = true;
end

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