Modernization: use tilde (~) syntax for ignored output arguments
parent
ce49cd95df
commit
7a75872f72
|
@ -194,7 +194,7 @@ while fpar<B
|
||||||
end
|
end
|
||||||
if MAX_nirfs_dsgevar
|
if MAX_nirfs_dsgevar
|
||||||
IRUN = IRUN+1;
|
IRUN = IRUN+1;
|
||||||
[fval,info,junk1,junk2,junk3,junk3,junk4,PHI,SIGMAu,iXX] = dsge_var_likelihood(deep',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
|
[fval,info,~,~,~,~,~,PHI,SIGMAu,iXX] = dsge_var_likelihood(deep',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
|
||||||
dsge_prior_weight = M_.params(strmatch('dsge_prior_weight', M_.param_names));
|
dsge_prior_weight = M_.params(strmatch('dsge_prior_weight', M_.param_names));
|
||||||
DSGE_PRIOR_WEIGHT = floor(dataset_.nobs*(1+dsge_prior_weight));
|
DSGE_PRIOR_WEIGHT = floor(dataset_.nobs*(1+dsge_prior_weight));
|
||||||
SIGMA_inv_upper_chol = chol(inv(SIGMAu*dataset_.nobs*(dsge_prior_weight+1)));
|
SIGMA_inv_upper_chol = chol(inv(SIGMAu*dataset_.nobs*(dsge_prior_weight+1)));
|
||||||
|
|
|
@ -93,7 +93,7 @@ for j=1:nvar
|
||||||
d0={};
|
d0={};
|
||||||
z1 = squeeze(z(i_var(j),:,:));
|
z1 = squeeze(z(i_var(j),:,:));
|
||||||
if screen_shocks
|
if screen_shocks
|
||||||
[junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
|
[~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
|
||||||
labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
|
labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
|
||||||
zres = sum(z1(isort(17:end),:),1);
|
zres = sum(z1(isort(17:end),:),1);
|
||||||
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
|
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
|
||||||
|
|
|
@ -128,7 +128,7 @@ if realtime_==0
|
||||||
myopts=options_;
|
myopts=options_;
|
||||||
myopts.plot_shock_decomp.type='qoq';
|
myopts.plot_shock_decomp.type='qoq';
|
||||||
myopts.plot_shock_decomp.realtime=0;
|
myopts.plot_shock_decomp.realtime=0;
|
||||||
[z, junk] = plot_shock_decomposition(M_,oo_,myopts,[]);
|
[z, ~] = plot_shock_decomposition(M_,oo_,myopts,[]);
|
||||||
else
|
else
|
||||||
z = oo_;
|
z = oo_;
|
||||||
end
|
end
|
||||||
|
@ -287,7 +287,7 @@ if isstruct(aux)
|
||||||
yaux=aux.y;
|
yaux=aux.y;
|
||||||
end
|
end
|
||||||
|
|
||||||
[nvar , nterms, junk] = size(z);
|
[nvar, nterms, ~] = size(z);
|
||||||
for j=1:nvar
|
for j=1:nvar
|
||||||
for k =1:nterms
|
for k =1:nterms
|
||||||
ztmp = squeeze(z(j,k,min((t0-3):-4:1):end));
|
ztmp = squeeze(z(j,k,min((t0-3):-4:1):end));
|
||||||
|
|
|
@ -40,7 +40,7 @@ irf = icc1+(options_.periods-1)*ny ;
|
||||||
d1 = zeros(options_.periods*ny,1) ;
|
d1 = zeros(options_.periods*ny,1) ;
|
||||||
|
|
||||||
ofs = (((options_.periods-1)*ny+1)-1)*jcf*8 ;
|
ofs = (((options_.periods-1)*ny+1)-1)*jcf*8 ;
|
||||||
junk = fseek(fid,ofs,-1) ;
|
[~] = fseek(fid,ofs,-1) ;
|
||||||
c = fread(fid,[jcf,ny],'float64')';
|
c = fread(fid,[jcf,ny],'float64')';
|
||||||
|
|
||||||
d1(ir) = c(:,jcf) ;
|
d1(ir) = c(:,jcf) ;
|
||||||
|
@ -52,7 +52,7 @@ while i <= M_.maximum_lead || i <= options_.periods
|
||||||
irf1 = selif(irf,irf<=options_.periods*ny) ;
|
irf1 = selif(irf,irf<=options_.periods*ny) ;
|
||||||
|
|
||||||
ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ;
|
ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ;
|
||||||
junk = fseek(fid,ofs,-1) ;
|
[~] = fseek(fid,ofs,-1) ;
|
||||||
c = fread(fid,[jcf,ny],'float64')' ;
|
c = fread(fid,[jcf,ny],'float64')' ;
|
||||||
|
|
||||||
d1(ir) = c(:,jcf) - c(:,1:size(irf1,1))*d1(irf1) ;
|
d1(ir) = c(:,jcf) - c(:,1:size(irf1,1))*d1(irf1) ;
|
||||||
|
@ -64,7 +64,7 @@ end
|
||||||
while i <= options_.periods
|
while i <= options_.periods
|
||||||
|
|
||||||
ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ;
|
ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ;
|
||||||
junk = fseek(fid,ofs,-1) ;
|
[~] = fseek(fid,ofs,-1) ;
|
||||||
c = fread(fid,[jcf,ny],'float64')' ;
|
c = fread(fid,[jcf,ny],'float64')' ;
|
||||||
|
|
||||||
d1(ir) = c(:,jcf)-c(:,icf)*d1(irf) ;
|
d1(ir) = c(:,jcf)-c(:,icf)*d1(irf) ;
|
||||||
|
|
|
@ -32,7 +32,7 @@ function varlist = check_list_of_variables(options_, M_, varlist)
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
% Get uniques
|
% Get uniques
|
||||||
[junk1, junk2, index_uniques] = varlist_indices(varlist, M_.endo_names);
|
[~, ~, index_uniques] = varlist_indices(varlist, M_.endo_names);
|
||||||
varlist = varlist(index_uniques);
|
varlist = varlist(index_uniques);
|
||||||
|
|
||||||
msg = false;
|
msg = false;
|
||||||
|
|
|
@ -387,7 +387,7 @@ if ~strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
|
||||||
end
|
end
|
||||||
|
|
||||||
if options_.load_mh_file && posterior_sampler_options.use_mh_covariance_matrix
|
if options_.load_mh_file && posterior_sampler_options.use_mh_covariance_matrix
|
||||||
[junk, invhess] = compute_mh_covariance_matrix;
|
[~, invhess] = compute_mh_covariance_matrix;
|
||||||
posterior_sampler_options.invhess = invhess;
|
posterior_sampler_options.invhess = invhess;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ if strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
|
||||||
error('check_posterior_sampler_options:: This error should not occur, please contact developers.')
|
error('check_posterior_sampler_options:: This error should not occur, please contact developers.')
|
||||||
end
|
end
|
||||||
% % % if options_.load_mh_file && options_.use_mh_covariance_matrix,
|
% % % if options_.load_mh_file && options_.use_mh_covariance_matrix,
|
||||||
% % % [junk, invhess] = compute_mh_covariance_matrix;
|
% % % [~, invhess] = compute_mh_covariance_matrix;
|
||||||
% % % posterior_sampler_options.invhess = invhess;
|
% % % posterior_sampler_options.invhess = invhess;
|
||||||
% % % end
|
% % % end
|
||||||
[V1, D]=eig(invhess);
|
[V1, D]=eig(invhess);
|
||||||
|
|
|
@ -63,7 +63,7 @@ end
|
||||||
%call steady_state_file if present to update parameters
|
%call steady_state_file if present to update parameters
|
||||||
if options_.steadystate_flag
|
if options_.steadystate_flag
|
||||||
% explicit steady state file
|
% explicit steady state file
|
||||||
[junk,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ...
|
[~,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ...
|
||||||
options_,0);
|
options_,0);
|
||||||
end
|
end
|
||||||
[U,Uy,W] = feval([M_.fname,'.objective.static'],zeros(endo_nbr,1),[], M_.params);
|
[U,Uy,W] = feval([M_.fname,'.objective.static'],zeros(endo_nbr,1),[], M_.params);
|
||||||
|
@ -129,7 +129,7 @@ iter=1;
|
||||||
for j=1:numel(Indices)
|
for j=1:numel(Indices)
|
||||||
eval(['A',Indices{j},'=zeros(eq_nbr,endo_nbr);'])
|
eval(['A',Indices{j},'=zeros(eq_nbr,endo_nbr);'])
|
||||||
if strcmp(Indices{j},'0')||(strcmp(Indices{j},'lag') && MaxLag)||(strcmp(Indices{j},'lead') && MaxLead)
|
if strcmp(Indices{j},'0')||(strcmp(Indices{j},'lag') && MaxLag)||(strcmp(Indices{j},'lead') && MaxLead)
|
||||||
[junk,row,col]=find(lead_lag_incidence(iter,:));
|
[~,row,col]=find(lead_lag_incidence(iter,:));
|
||||||
eval(['A',Indices{j},'(:,row)=jacobia_(:,col);'])
|
eval(['A',Indices{j},'(:,row)=jacobia_(:,col);'])
|
||||||
iter=iter+1;
|
iter=iter+1;
|
||||||
end
|
end
|
||||||
|
|
|
@ -409,7 +409,7 @@ for i = 1:Size
|
||||||
index_c = lead_lag_incidence(2,:); % Index of all endogenous variables present at time=t
|
index_c = lead_lag_incidence(2,:); % Index of all endogenous variables present at time=t
|
||||||
index_s = lead_lag_incidence(2,1:n_static); % Index of all static endogenous variables present at time=t
|
index_s = lead_lag_incidence(2,1:n_static); % Index of all static endogenous variables present at time=t
|
||||||
if n_static > 0
|
if n_static > 0
|
||||||
[Q, junk] = qr(jacob(:,index_s));
|
[Q, ~] = qr(jacob(:,index_s));
|
||||||
aa = Q'*jacob;
|
aa = Q'*jacob;
|
||||||
else
|
else
|
||||||
aa = jacob;
|
aa = jacob;
|
||||||
|
@ -476,7 +476,7 @@ for i = 1:Size
|
||||||
if isfield(options_,'indeterminacy_continuity')
|
if isfield(options_,'indeterminacy_continuity')
|
||||||
if options_.indeterminacy_msv == 1
|
if options_.indeterminacy_msv == 1
|
||||||
[ss,tt,w,q] = qz(E',D');
|
[ss,tt,w,q] = qz(E',D');
|
||||||
[ss,tt,w,junk] = reorder(ss,tt,w,q);
|
[ss,tt,w,~] = reorder(ss,tt,w,q);
|
||||||
ss = ss';
|
ss = ss';
|
||||||
tt = tt';
|
tt = tt';
|
||||||
w = w';
|
w = w';
|
||||||
|
|
|
@ -111,7 +111,7 @@ switch pshape(indx)
|
||||||
end
|
end
|
||||||
|
|
||||||
if pshape(indx) ~= 5
|
if pshape(indx) ~= 5
|
||||||
[junk,k1] = max(dens);
|
[~,k1] = max(dens);
|
||||||
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;
|
||||||
|
|
|
@ -124,7 +124,7 @@ if isempty(reorder_jacobian_columns)
|
||||||
nsfwrd)))];
|
nsfwrd)))];
|
||||||
index_e2 = npred+nboth+(1:nboth);
|
index_e2 = npred+nboth+(1:nboth);
|
||||||
|
|
||||||
[junk,cols_b] = find(lead_lag_incidence(maximum_lag+1, order_var));
|
[~,cols_b] = find(lead_lag_incidence(maximum_lag+1, order_var));
|
||||||
|
|
||||||
reorder_jacobian_columns = [nonzeros(lead_lag_incidence(:,order_var)'); ...
|
reorder_jacobian_columns = [nonzeros(lead_lag_incidence(:,order_var)'); ...
|
||||||
nz+(1:exo_nbr)'];
|
nz+(1:exo_nbr)'];
|
||||||
|
@ -138,7 +138,7 @@ dr.state_var = state_var;
|
||||||
jacobia = jacobia(:,reorder_jacobian_columns);
|
jacobia = jacobia(:,reorder_jacobian_columns);
|
||||||
|
|
||||||
if nstatic > 0
|
if nstatic > 0
|
||||||
[Q, junk] = qr(jacobia(:,index_s));
|
[Q, ~] = qr(jacobia(:,index_s));
|
||||||
aa = Q'*jacobia;
|
aa = Q'*jacobia;
|
||||||
else
|
else
|
||||||
aa = jacobia;
|
aa = jacobia;
|
||||||
|
|
|
@ -75,7 +75,7 @@ elseif options_.steadystate_flag
|
||||||
ys_init(k_inst) = inst_val;
|
ys_init(k_inst) = inst_val;
|
||||||
exo_ss = [oo.exo_steady_state oo.exo_det_steady_state];
|
exo_ss = [oo.exo_steady_state oo.exo_det_steady_state];
|
||||||
[xx,params] = evaluate_steady_state_file(ys_init,exo_ss,M,options_,~options_.steadystate.nocheck); %run steady state file again to update parameters
|
[xx,params] = evaluate_steady_state_file(ys_init,exo_ss,M,options_,~options_.steadystate.nocheck); %run steady state file again to update parameters
|
||||||
[junk,junk,steady_state] = nl_func(inst_val); %compute and return steady state
|
[~,~,steady_state] = nl_func(inst_val); %compute and return steady state
|
||||||
else
|
else
|
||||||
n_var = M.orig_endo_nbr;
|
n_var = M.orig_endo_nbr;
|
||||||
xx = oo.steady_state(1:n_var);
|
xx = oo.steady_state(1:n_var);
|
||||||
|
@ -85,7 +85,7 @@ else
|
||||||
if info1~=0
|
if info1~=0
|
||||||
check=81;
|
check=81;
|
||||||
end
|
end
|
||||||
[junk,junk,steady_state] = nl_func(xx);
|
[~,~,steady_state] = nl_func(xx);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,8 +194,8 @@ end
|
||||||
function result = check_static_model(ys,M,options_,oo)
|
function result = check_static_model(ys,M,options_,oo)
|
||||||
result = false;
|
result = false;
|
||||||
if (options_.bytecode)
|
if (options_.bytecode)
|
||||||
[chck, res, junk] = bytecode('static',ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
|
[chck, res, ~] = bytecode('static',ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
|
||||||
M.params, 'evaluate');
|
M.params, 'evaluate');
|
||||||
else
|
else
|
||||||
res = feval([M.fname '.static'],ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
|
res = feval([M.fname '.static'],ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
|
||||||
M.params);
|
M.params);
|
||||||
|
|
|
@ -88,7 +88,7 @@ exo_nbr = M.exo_nbr;
|
||||||
|
|
||||||
M.var_order_endo_names = M.endo_names(dr.order_var);
|
M.var_order_endo_names = M.endo_names(dr.order_var);
|
||||||
|
|
||||||
[junk,dr.i_fwrd_g,i_fwrd_f] = find(lead_lag_incidence(3,order_var));
|
[~,dr.i_fwrd_g,i_fwrd_f] = find(lead_lag_incidence(3,order_var));
|
||||||
dr.i_fwrd_f = i_fwrd_f;
|
dr.i_fwrd_f = i_fwrd_f;
|
||||||
nd = nnz(lead_lag_incidence) + M.exo_nbr;
|
nd = nnz(lead_lag_incidence) + M.exo_nbr;
|
||||||
dr.nd = nd;
|
dr.nd = nd;
|
||||||
|
|
|
@ -105,7 +105,7 @@ k1 = find(kstate(:,2) == M_.maximum_endo_lag+2);
|
||||||
% Jacobian with respect to the variables with the highest lead
|
% Jacobian with respect to the variables with the highest lead
|
||||||
fyp = jacobia(:,kstate(k1,3)+nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1,:)));
|
fyp = jacobia(:,kstate(k1,3)+nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1,:)));
|
||||||
B(:,nstatic+M_.npred+1:end) = fyp;
|
B(:,nstatic+M_.npred+1:end) = fyp;
|
||||||
[junk,k1,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+M_.maximum_endo_lead+1,order_var));
|
[~,k1,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+M_.maximum_endo_lead+1,order_var));
|
||||||
A(1:M_.endo_nbr,nstatic+1:nstatic+nspred)=...
|
A(1:M_.endo_nbr,nstatic+1:nstatic+nspred)=...
|
||||||
A(1:M_.endo_nbr,nstatic+[1:nspred])+fyp*gx1(k1,1:nspred);
|
A(1:M_.endo_nbr,nstatic+[1:nspred])+fyp*gx1(k1,1:nspred);
|
||||||
C = Gy;
|
C = Gy;
|
||||||
|
@ -162,7 +162,7 @@ kp = sum(kstate(:,2) <= M_.maximum_endo_lag+1);
|
||||||
E1 = [eye(nspred); zeros(kp-nspred,nspred)];
|
E1 = [eye(nspred); zeros(kp-nspred,nspred)];
|
||||||
H = E1;
|
H = E1;
|
||||||
hxx = dr.ghxx(nstatic+[1:nspred],:);
|
hxx = dr.ghxx(nstatic+[1:nspred],:);
|
||||||
[junk,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,order_var));
|
[~,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,order_var));
|
||||||
k3 = nnz(M_.lead_lag_incidence(1:M_.maximum_endo_lag+1,:))+(1:M_.nsfwrd)';
|
k3 = nnz(M_.lead_lag_incidence(1:M_.maximum_endo_lag+1,:))+(1:M_.nsfwrd)';
|
||||||
[B1, err] = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kh(k3,k3)),gu(k2a,:),threads_BC);
|
[B1, err] = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kh(k3,k3)),gu(k2a,:),threads_BC);
|
||||||
mexErrCheck('sparse_hessian_times_B_kronecker_C', err);
|
mexErrCheck('sparse_hessian_times_B_kronecker_C', err);
|
||||||
|
|
|
@ -191,7 +191,7 @@ end
|
||||||
if ispc
|
if ispc
|
||||||
arch = getenv('PROCESSOR_ARCHITECTURE');
|
arch = getenv('PROCESSOR_ARCHITECTURE');
|
||||||
else
|
else
|
||||||
[junk, arch] = system('uname -m');
|
[~, arch] = system('uname -m');
|
||||||
end
|
end
|
||||||
|
|
||||||
if isempty(strfind(arch, '64'))
|
if isempty(strfind(arch, '64'))
|
||||||
|
|
|
@ -235,8 +235,8 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
|
||||||
if options_.analytic_derivation && strcmp(func2str(objective_function),'dsge_likelihood')
|
if options_.analytic_derivation && strcmp(func2str(objective_function),'dsge_likelihood')
|
||||||
ana_deriv_old = options_.analytic_derivation;
|
ana_deriv_old = options_.analytic_derivation;
|
||||||
options_.analytic_derivation = 2;
|
options_.analytic_derivation = 2;
|
||||||
[junk1, junk2,junk3, junk4, hh] = feval(objective_function,xparam1, ...
|
[~,~,~,~,hh] = feval(objective_function,xparam1, ...
|
||||||
dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
|
dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
|
||||||
options_.analytic_derivation = ana_deriv_old;
|
options_.analytic_derivation = ana_deriv_old;
|
||||||
elseif ~isnumeric(options_.mode_compute) || ~(isequal(options_.mode_compute,5) && newratflag~=1 && strcmp(func2str(objective_function),'dsge_likelihood'))
|
elseif ~isnumeric(options_.mode_compute) || ~(isequal(options_.mode_compute,5) && newratflag~=1 && strcmp(func2str(objective_function),'dsge_likelihood'))
|
||||||
% with flag==0, we force to use the hessian from outer product gradient of optimizer 5
|
% with flag==0, we force to use the hessian from outer product gradient of optimizer 5
|
||||||
|
@ -373,9 +373,8 @@ if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
|
||||||
skipline()
|
skipline()
|
||||||
end
|
end
|
||||||
if options_.dsge_var
|
if options_.dsge_var
|
||||||
[junk1,junk2,junk3,junk4,junk5,junk6,junk7,oo_.dsge_var.posterior_mode.PHI_tilde,oo_.dsge_var.posterior_mode.SIGMA_u_tilde,oo_.dsge_var.posterior_mode.iXX,oo_.dsge_var.posterior_mode.prior] =...
|
[~,~,~,~,~,~,~,oo_.dsge_var.posterior_mode.PHI_tilde,oo_.dsge_var.posterior_mode.SIGMA_u_tilde,oo_.dsge_var.posterior_mode.iXX,oo_.dsge_var.posterior_mode.prior] =...
|
||||||
feval(objective_function,xparam1,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
|
feval(objective_function,xparam1,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
|
||||||
clear('junk1','junk2','junk3','junk4','junk5','junk6','junk7');
|
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif ~any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
|
elseif ~any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
|
||||||
|
@ -519,7 +518,7 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
|
||||||
oo_.posterior.metropolis=oo_load_mh.oo_.posterior.metropolis;
|
oo_.posterior.metropolis=oo_load_mh.oo_.posterior.metropolis;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
[error_flag,junk,options_]= metropolis_draw(1,options_,estim_params_,M_);
|
[error_flag,~,options_]= metropolis_draw(1,options_,estim_params_,M_);
|
||||||
if options_.bayesian_irf
|
if options_.bayesian_irf
|
||||||
if error_flag
|
if error_flag
|
||||||
error('Estimation::mcmc: I cannot compute the posterior IRFs!')
|
error('Estimation::mcmc: I cannot compute the posterior IRFs!')
|
||||||
|
|
|
@ -454,38 +454,38 @@ if options_.block == 1
|
||||||
% Set restrict_state to postion of observed + state variables in expanded state vector.
|
% Set restrict_state to postion of observed + state variables in expanded state vector.
|
||||||
oo_.dr.restrict_var_list = [k1(i_posA) M_.state_var(sort(i_posB))];
|
oo_.dr.restrict_var_list = [k1(i_posA) M_.state_var(sort(i_posB))];
|
||||||
% set mf0 to positions of state variables in restricted state vector for likelihood computation.
|
% set mf0 to positions of state variables in restricted state vector for likelihood computation.
|
||||||
[junk,bayestopt_.mf0] = ismember(M_.state_var',oo_.dr.restrict_var_list);
|
[~,bayestopt_.mf0] = ismember(M_.state_var',oo_.dr.restrict_var_list);
|
||||||
% Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
|
% Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
|
||||||
[junk,bayestopt_.mf1] = ismember(k1,oo_.dr.restrict_var_list);
|
[~,bayestopt_.mf1] = ismember(k1,oo_.dr.restrict_var_list);
|
||||||
% Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
|
% Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
|
||||||
bayestopt_.mf2 = var_obs_index_dr;
|
bayestopt_.mf2 = var_obs_index_dr;
|
||||||
bayestopt_.mfys = k1;
|
bayestopt_.mfys = k1;
|
||||||
oo_.dr.restrict_columns = [size(i_posA,1)+(1:size(M_.state_var,2))];
|
oo_.dr.restrict_columns = [size(i_posA,1)+(1:size(M_.state_var,2))];
|
||||||
[k2, i_posA, i_posB] = union(k3p, M_.state_var', 'rows');
|
[k2, i_posA, i_posB] = union(k3p, M_.state_var', 'rows');
|
||||||
bayestopt_.smoother_var_list = [k3p(i_posA); M_.state_var(sort(i_posB))'];
|
bayestopt_.smoother_var_list = [k3p(i_posA); M_.state_var(sort(i_posB))'];
|
||||||
[junk,junk,bayestopt_.smoother_saved_var_list] = intersect(k3p,bayestopt_.smoother_var_list(:));
|
[~,~,bayestopt_.smoother_saved_var_list] = intersect(k3p,bayestopt_.smoother_var_list(:));
|
||||||
[junk,ic] = intersect(bayestopt_.smoother_var_list,M_.state_var);
|
[~,ic] = intersect(bayestopt_.smoother_var_list,M_.state_var);
|
||||||
bayestopt_.smoother_restrict_columns = ic;
|
bayestopt_.smoother_restrict_columns = ic;
|
||||||
[junk,bayestopt_.smoother_mf] = ismember(k1, bayestopt_.smoother_var_list);
|
[~,bayestopt_.smoother_mf] = ismember(k1, bayestopt_.smoother_var_list);
|
||||||
else
|
else
|
||||||
% Define union of observed and state variables
|
% Define union of observed and state variables
|
||||||
k2 = union(var_obs_index_dr,[M_.nstatic+1:M_.nstatic+M_.nspred]', 'rows');
|
k2 = union(var_obs_index_dr,[M_.nstatic+1:M_.nstatic+M_.nspred]', 'rows');
|
||||||
% Set restrict_state to postion of observed + state variables in expanded state vector.
|
% Set restrict_state to postion of observed + state variables in expanded state vector.
|
||||||
oo_.dr.restrict_var_list = k2;
|
oo_.dr.restrict_var_list = k2;
|
||||||
% set mf0 to positions of state variables in restricted state vector for likelihood computation.
|
% set mf0 to positions of state variables in restricted state vector for likelihood computation.
|
||||||
[junk,bayestopt_.mf0] = ismember([M_.nstatic+1:M_.nstatic+M_.nspred]',k2);
|
[~,bayestopt_.mf0] = ismember([M_.nstatic+1:M_.nstatic+M_.nspred]',k2);
|
||||||
% Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
|
% Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
|
||||||
[junk,bayestopt_.mf1] = ismember(var_obs_index_dr,k2);
|
[~,bayestopt_.mf1] = ismember(var_obs_index_dr,k2);
|
||||||
% Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
|
% Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
|
||||||
bayestopt_.mf2 = var_obs_index_dr;
|
bayestopt_.mf2 = var_obs_index_dr;
|
||||||
bayestopt_.mfys = k1;
|
bayestopt_.mfys = k1;
|
||||||
[junk,ic] = intersect(k2,nstatic+(1:npred)');
|
[~,ic] = intersect(k2,nstatic+(1:npred)');
|
||||||
oo_.dr.restrict_columns = [ic; length(k2)+(1:nspred-npred)'];
|
oo_.dr.restrict_columns = [ic; length(k2)+(1:nspred-npred)'];
|
||||||
bayestopt_.smoother_var_list = union(k2,k3);
|
bayestopt_.smoother_var_list = union(k2,k3);
|
||||||
[junk,junk,bayestopt_.smoother_saved_var_list] = intersect(k3,bayestopt_.smoother_var_list(:));
|
[~,~,bayestopt_.smoother_saved_var_list] = intersect(k3,bayestopt_.smoother_var_list(:));
|
||||||
[junk,ic] = intersect(bayestopt_.smoother_var_list,nstatic+(1:npred)');
|
[~,ic] = intersect(bayestopt_.smoother_var_list,nstatic+(1:npred)');
|
||||||
bayestopt_.smoother_restrict_columns = ic;
|
bayestopt_.smoother_restrict_columns = ic;
|
||||||
[junk,bayestopt_.smoother_mf] = ismember(var_obs_index_dr, bayestopt_.smoother_var_list);
|
[~,bayestopt_.smoother_mf] = ismember(var_obs_index_dr, bayestopt_.smoother_var_list);
|
||||||
end
|
end
|
||||||
|
|
||||||
if options_.analytic_derivation
|
if options_.analytic_derivation
|
||||||
|
|
|
@ -52,11 +52,11 @@ for i=1:m
|
||||||
else
|
else
|
||||||
h = H(:,i);
|
h = H(:,i);
|
||||||
end
|
end
|
||||||
[Fh,junk1,junk2,flag] = feval(fcn, x+transpose(h), varargin{:});
|
[Fh,~,~,flag] = feval(fcn, x+transpose(h), varargin{:});
|
||||||
if flag
|
if flag
|
||||||
G(:,i) = (Fh-F)/epsilon;
|
G(:,i) = (Fh-F)/epsilon;
|
||||||
else
|
else
|
||||||
[Fh,junk1,junk2,flag] = feval(fcn, x-transpose(h), varargin{:});
|
[Fh,~,~,flag] = feval(fcn, x-transpose(h), varargin{:});
|
||||||
if flag
|
if flag
|
||||||
G(:,i) = (F-Fh)/epsilon;
|
G(:,i) = (F-Fh)/epsilon;
|
||||||
else
|
else
|
||||||
|
|
|
@ -307,7 +307,7 @@ if M.static_and_dynamic_models_differ
|
||||||
z = repmat(ys,1,M.maximum_lead + M.maximum_lag + 1);
|
z = repmat(ys,1,M.maximum_lead + M.maximum_lag + 1);
|
||||||
zx = repmat([exo_ss'], M.maximum_lead + M.maximum_lag + 1, 1);
|
zx = repmat([exo_ss'], M.maximum_lead + M.maximum_lag + 1, 1);
|
||||||
if options.bytecode
|
if options.bytecode
|
||||||
[chck, r, junk]= bytecode('dynamic','evaluate', z, zx, M.params, ys, 1);
|
[chck, r, ~]= bytecode('dynamic','evaluate', z, zx, M.params, ys, 1);
|
||||||
mexErrCheck('bytecode', chck);
|
mexErrCheck('bytecode', chck);
|
||||||
elseif options.block
|
elseif options.block
|
||||||
[r, oo.dr] = feval([M.fname '.dynamic'], z', zx, M.params, ys, M.maximum_lag+1, oo.dr);
|
[r, oo.dr] = feval([M.fname '.dynamic'], z', zx, M.params, ys, M.maximum_lag+1, oo.dr);
|
||||||
|
|
|
@ -55,7 +55,7 @@ if strcmpi(type,'posterior')
|
||||||
CutSample(M_, options_, estim_params_);
|
CutSample(M_, options_, estim_params_);
|
||||||
%% initialize metropolis draws
|
%% initialize metropolis draws
|
||||||
options_.sub_draws=n_draws; %set draws for sampling; changed value is not returned to base workspace
|
options_.sub_draws=n_draws; %set draws for sampling; changed value is not returned to base workspace
|
||||||
[error_flag,junk,options_]= metropolis_draw(1,options_,estim_params_,M_);
|
[error_flag,~,options_]= metropolis_draw(1,options_,estim_params_,M_);
|
||||||
if error_flag
|
if error_flag
|
||||||
error('EXECUTE_POSTERIOR_FUNCTION: The draws could not be initialized')
|
error('EXECUTE_POSTERIOR_FUNCTION: The draws could not be initialized')
|
||||||
end
|
end
|
||||||
|
|
|
@ -319,8 +319,8 @@ if nargout > 5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
[junk,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ...
|
[~,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ...
|
||||||
oo_.dr.order_var));
|
oo_.dr.order_var));
|
||||||
GAM0 = zeros(M_.endo_nbr,M_.endo_nbr);
|
GAM0 = zeros(M_.endo_nbr,M_.endo_nbr);
|
||||||
Dg0 = zeros(M_.endo_nbr,M_.endo_nbr,param_nbr);
|
Dg0 = zeros(M_.endo_nbr,M_.endo_nbr,param_nbr);
|
||||||
GAM0(:,cols_b) = g1(:,cols_j);
|
GAM0(:,cols_b) = g1(:,cols_j);
|
||||||
|
|
|
@ -43,7 +43,7 @@ bk_number = record.Nblck ;
|
||||||
predicted_mhname = [ BaseName '_mh' int2str(mh_number) '_blck' int2str(bk_number) '.mat' ] ;
|
predicted_mhname = [ BaseName '_mh' int2str(mh_number) '_blck' int2str(bk_number) '.mat' ] ;
|
||||||
|
|
||||||
all_mh_files = dir([BaseName '_mh*_blck*' ]);
|
all_mh_files = dir([BaseName '_mh*_blck*' ]);
|
||||||
[junk,idx] = sort([all_mh_files.datenum]);
|
[~,idx] = sort([all_mh_files.datenum]);
|
||||||
mhname = all_mh_files(idx(end)).name;
|
mhname = all_mh_files(idx(end)).name;
|
||||||
|
|
||||||
if ~strcmpi(mhname,predicted_mhname)
|
if ~strcmpi(mhname,predicted_mhname)
|
||||||
|
|
|
@ -130,8 +130,8 @@ set_dynare_seed('default');
|
||||||
|
|
||||||
|
|
||||||
% Create directories
|
% Create directories
|
||||||
[junk,junk]=mkdir(M_.fname);
|
[~,~]=mkdir(M_.fname);
|
||||||
[junk,junk]=mkdir([M_.fname filesep 'Output']);
|
[~,~]=mkdir([M_.fname filesep 'Output']);
|
||||||
|
|
||||||
% Load user configuration file.
|
% Load user configuration file.
|
||||||
if isfield(options_, 'global_init_file')
|
if isfield(options_, 'global_init_file')
|
||||||
|
|
|
@ -108,7 +108,7 @@ comp_nbr0=comp_nbr;
|
||||||
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
|
||||||
[junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
|
[~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
|
||||||
labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
|
labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
|
||||||
zres = sum(z1(isort(17:end),:),1);
|
zres = sum(z1(isort(17:end),:),1);
|
||||||
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
|
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
|
||||||
|
|
|
@ -135,7 +135,7 @@ comp_nbr0=comp_nbr;
|
||||||
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,
|
||||||
[junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
|
[~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
|
||||||
labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
|
labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
|
||||||
zres = sum(z1(isort(17:end),:),1);
|
zres = sum(z1(isort(17:end),:),1);
|
||||||
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
|
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
|
||||||
|
|
|
@ -49,7 +49,7 @@ if init
|
||||||
pdraw = zeros(npar,1);
|
pdraw = zeros(npar,1);
|
||||||
lbcum = zeros(npar,1);
|
lbcum = zeros(npar,1);
|
||||||
ubcum = ones(npar,1);
|
ubcum = ones(npar,1);
|
||||||
[junk1,junk2,junk3,lb,ub,junk4] = 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)
|
if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0)
|
||||||
% Set prior bounds
|
% Set prior bounds
|
||||||
bounds = prior_bounds(bayestopt_, options_.prior_trunc);
|
bounds = prior_bounds(bayestopt_, options_.prior_trunc);
|
||||||
|
|
|
@ -92,7 +92,7 @@ p2 = bayestopt_.p2(nshock+1:end);
|
||||||
p3 = bayestopt_.p3(nshock+1:end);
|
p3 = bayestopt_.p3(nshock+1:end);
|
||||||
p4 = bayestopt_.p4(nshock+1:end);
|
p4 = bayestopt_.p4(nshock+1:end);
|
||||||
|
|
||||||
[junk1,junk2,junk3,lb,ub,junk4] = 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)
|
if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0)
|
||||||
% Set prior bounds
|
% Set prior bounds
|
||||||
bounds = prior_bounds(bayestopt_, options_.prior_trunc);
|
bounds = prior_bounds(bayestopt_, options_.prior_trunc);
|
||||||
|
|
|
@ -198,7 +198,7 @@ if info(1)==0
|
||||||
if isoctave || matlab_ver_less_than('8.3')
|
if isoctave || matlab_ver_less_than('8.3')
|
||||||
[V,D]=eig(cc);
|
[V,D]=eig(cc);
|
||||||
%fix for older Matlab versions that do not support computing left eigenvalues, see http://mathworks.com/help/releases/R2012b/matlab/ref/eig.html
|
%fix for older Matlab versions that do not support computing left eigenvalues, see http://mathworks.com/help/releases/R2012b/matlab/ref/eig.html
|
||||||
[W,junk] = eig(cc.');
|
[W,~] = eig(cc.');
|
||||||
W = conj(W);
|
W = conj(W);
|
||||||
else
|
else
|
||||||
[V,D,W]=eig(cc);
|
[V,D,W]=eig(cc);
|
||||||
|
|
|
@ -74,7 +74,7 @@ end
|
||||||
if ~isfield(oo_,'initval_decomposition')
|
if ~isfield(oo_,'initval_decomposition')
|
||||||
options_.selected_variables_only = 0; %make sure all variables are stored
|
options_.selected_variables_only = 0; %make sure all variables are stored
|
||||||
options_.plot_priors=0;
|
options_.plot_priors=0;
|
||||||
[oo,M,junk1,junk2,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
|
[oo,M,~,~,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
|
||||||
|
|
||||||
% reduced form
|
% reduced form
|
||||||
dr = oo.dr;
|
dr = oo.dr;
|
||||||
|
|
|
@ -66,7 +66,7 @@ if isfield(EstimatedParameters,'param_vals') && ~isempty(EstimatedParameters.par
|
||||||
%check whether steady state file changes estimated parameters
|
%check whether steady state file changes estimated parameters
|
||||||
Model_par_varied=Model; %store Model structure
|
Model_par_varied=Model; %store Model structure
|
||||||
Model_par_varied.params(EstimatedParameters.param_vals(:,1))=Model_par_varied.params(EstimatedParameters.param_vals(:,1))*1.01; %vary parameters
|
Model_par_varied.params(EstimatedParameters.param_vals(:,1))=Model_par_varied.params(EstimatedParameters.param_vals(:,1))*1.01; %vary parameters
|
||||||
[junk, new_steady_params_2] = evaluate_steady_state(DynareResults.steady_state,Model_par_varied,DynareOptions,DynareResults,DynareOptions.diffuse_filter==0);
|
[~, new_steady_params_2] = evaluate_steady_state(DynareResults.steady_state,Model_par_varied,DynareOptions,DynareResults,DynareOptions.diffuse_filter==0);
|
||||||
|
|
||||||
changed_par_indices=find((old_steady_params(EstimatedParameters.param_vals(:,1))-new_steady_params(EstimatedParameters.param_vals(:,1))) ...
|
changed_par_indices=find((old_steady_params(EstimatedParameters.param_vals(:,1))-new_steady_params(EstimatedParameters.param_vals(:,1))) ...
|
||||||
| (Model_par_varied.params(EstimatedParameters.param_vals(:,1))-new_steady_params_2(EstimatedParameters.param_vals(:,1))));
|
| (Model_par_varied.params(EstimatedParameters.param_vals(:,1))-new_steady_params_2(EstimatedParameters.param_vals(:,1))));
|
||||||
|
@ -105,7 +105,7 @@ end
|
||||||
% display warning if some parameters are still NaN
|
% display warning if some parameters are still NaN
|
||||||
test_for_deep_parameters_calibration(Model);
|
test_for_deep_parameters_calibration(Model);
|
||||||
|
|
||||||
[lnprior, junk1,junk2,info]= priordens(xparam1,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4);
|
[lnprior,~,~,info]= priordens(xparam1,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4);
|
||||||
if info
|
if info
|
||||||
fprintf('The prior density evaluated at the initial values is Inf for the following parameters: %s\n',BayesInfo.name{info,1})
|
fprintf('The prior density evaluated at the initial values is Inf for the following parameters: %s\n',BayesInfo.name{info,1})
|
||||||
error('The initial value of the prior is -Inf')
|
error('The initial value of the prior is -Inf')
|
||||||
|
|
|
@ -114,9 +114,9 @@ while t <= last
|
||||||
tmp = (a+K*v);
|
tmp = (a+K*v);
|
||||||
if analytic_derivation
|
if analytic_derivation
|
||||||
if analytic_derivation==2
|
if analytic_derivation==2
|
||||||
[Da,junk,DLIKt,D2a,junk2, Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady,D2a,D2Yss,D2T,[],[]);
|
[Da,~,DLIKt,D2a,~, Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady,D2a,D2Yss,D2T,[],[]);
|
||||||
else
|
else
|
||||||
[Da,junk,DLIKt,Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady);
|
[Da,~,DLIKt,Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady);
|
||||||
end
|
end
|
||||||
DLIK = DLIK + DLIKt;
|
DLIK = DLIK + DLIKt;
|
||||||
if analytic_derivation==2 || asy_hess
|
if analytic_derivation==2 || asy_hess
|
||||||
|
|
|
@ -153,7 +153,7 @@ while t<=last
|
||||||
end
|
end
|
||||||
if analytic_derivation
|
if analytic_derivation
|
||||||
if analytic_derivation==2
|
if analytic_derivation==2
|
||||||
[Da,junk,D2a] = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0,D2a,D2P,D2T);
|
[Da,~,D2a] = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0,D2a,D2P,D2T);
|
||||||
else
|
else
|
||||||
Da = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0);
|
Da = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0);
|
||||||
end
|
end
|
||||||
|
|
|
@ -392,7 +392,7 @@ while (k < kmax) && (Psix > eps2)
|
||||||
Fx = Fxnew;
|
Fx = Fxnew;
|
||||||
Phix = Phixnew;
|
Phix = Phixnew;
|
||||||
Psix = Psixnew;
|
Psix = Psixnew;
|
||||||
[junk,DFx] = feval(FUN,x,varargin{:});
|
[~,DFx] = feval(FUN,x,varargin{:});
|
||||||
DPhix = DPhi(x,Fx,DFx,lb,ub,lambda1,lambda2,n,Indexset);
|
DPhix = DPhi(x,Fx,DFx,lb,ub,lambda1,lambda2,n,Indexset);
|
||||||
DPsix = DPhix'*Phix;
|
DPsix = DPhix'*Phix;
|
||||||
normDPsix = norm(DPsix);
|
normDPsix = norm(DPsix);
|
||||||
|
|
|
@ -18,7 +18,7 @@ function o2WysrOISH = load_m_file_data_legacy(datafile, U7ORsJ0vy3) % --*-- Uni
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
cXDHdrXnqo5KwwVpTRuc6OprAW = datafile(1:end-2);
|
cXDHdrXnqo5KwwVpTRuc6OprAW = datafile(1:end-2);
|
||||||
[pathtocXDHdrXnqo5KwwVpTRuc6OprAW,cXDHdrXnqo5KwwVpTRuc6OprAW,junk] = fileparts(cXDHdrXnqo5KwwVpTRuc6OprAW);
|
[pathtocXDHdrXnqo5KwwVpTRuc6OprAW,cXDHdrXnqo5KwwVpTRuc6OprAW,~] = fileparts(cXDHdrXnqo5KwwVpTRuc6OprAW);
|
||||||
|
|
||||||
if ~isempty(pathtocXDHdrXnqo5KwwVpTRuc6OprAW)
|
if ~isempty(pathtocXDHdrXnqo5KwwVpTRuc6OprAW)
|
||||||
% We need to change directory, first we keep the current directory in memory...
|
% We need to change directory, first we keep the current directory in memory...
|
||||||
|
@ -38,7 +38,7 @@ if ~isempty(pathtocXDHdrXnqo5KwwVpTRuc6OprAW)
|
||||||
end
|
end
|
||||||
|
|
||||||
% Clear all the variables except the ones defined in the script.
|
% Clear all the variables except the ones defined in the script.
|
||||||
clear('pathtocXDHdrXnqo5KwwVpTRuc6OprAW', 'cXDHdrXnqo5KwwVpTRuc6OprAW', 'junk');
|
clear('pathtocXDHdrXnqo5KwwVpTRuc6OprAW', 'cXDHdrXnqo5KwwVpTRuc6OprAW');
|
||||||
|
|
||||||
% Get the list of variables in the script.
|
% Get the list of variables in the script.
|
||||||
mj6F4eU1BN = whos();
|
mj6F4eU1BN = whos();
|
||||||
|
|
|
@ -204,22 +204,22 @@ z = repmat(dr.ys,1,klen);
|
||||||
if ~options.block
|
if ~options.block
|
||||||
if options.order == 1
|
if options.order == 1
|
||||||
if (options.bytecode)
|
if (options.bytecode)
|
||||||
[chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
|
[chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
|
||||||
M.params, dr.ys, 1);
|
M.params, dr.ys, 1);
|
||||||
jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd];
|
jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd];
|
||||||
else
|
else
|
||||||
[junk,jacobia_] = feval([M.fname '.dynamic'],z(iyr0),exo_simul, ...
|
[~,jacobia_] = feval([M.fname '.dynamic'],z(iyr0),exo_simul, ...
|
||||||
M.params, dr.ys, it_);
|
M.params, dr.ys, it_);
|
||||||
end
|
end
|
||||||
elseif options.order >= 2
|
elseif options.order >= 2
|
||||||
if (options.bytecode)
|
if (options.bytecode)
|
||||||
[chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
|
[chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
|
||||||
M.params, dr.ys, 1);
|
M.params, dr.ys, 1);
|
||||||
jacobia_ = [loc_dr.g1 loc_dr.g1_x];
|
jacobia_ = [loc_dr.g1 loc_dr.g1_x];
|
||||||
else
|
else
|
||||||
[junk,jacobia_,hessian1] = feval([M.fname '.dynamic'],z(iyr0),...
|
[~,jacobia_,hessian1] = feval([M.fname '.dynamic'],z(iyr0),...
|
||||||
exo_simul, ...
|
exo_simul, ...
|
||||||
M.params, dr.ys, it_);
|
M.params, dr.ys, it_);
|
||||||
end
|
end
|
||||||
if options.use_dll
|
if options.use_dll
|
||||||
% In USE_DLL mode, the hessian is in the 3-column sparse representation
|
% In USE_DLL mode, the hessian is in the 3-column sparse representation
|
||||||
|
|
|
@ -6,19 +6,19 @@ coef_y = zeros(endo_nbr,3*endo_nbr);
|
||||||
coef_u = zeros(endo_nbr,M.exo_nbr);
|
coef_u = zeros(endo_nbr,M.exo_nbr);
|
||||||
|
|
||||||
if M.maximum_lag > 0
|
if M.maximum_lag > 0
|
||||||
[junk,c1,c2] = find(ll(1,:));
|
[~,c1,c2] = find(ll(1,:));
|
||||||
coef_y(:,c1) = jacobian(:,c2);
|
coef_y(:,c1) = jacobian(:,c2);
|
||||||
[junk,c1,c2] = find(ll(2,:));
|
[~,c1,c2] = find(ll(2,:));
|
||||||
coef_y(:,c1+endo_nbr) = jacobian(:,c2);
|
coef_y(:,c1+endo_nbr) = jacobian(:,c2);
|
||||||
if M.maximum_lead > 0
|
if M.maximum_lead > 0
|
||||||
[junk,c1,c2] = find(ll(3,:));
|
[~,c1,c2] = find(ll(3,:));
|
||||||
coef_y(:,c1+2*endo_nbr) = jacobian(:,c2);
|
coef_y(:,c1+2*endo_nbr) = jacobian(:,c2);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
[junk,c1,c2] = find(ll(1,:));
|
[~,c1,c2] = find(ll(1,:));
|
||||||
coef_y(:,c1+endo_nbr) = jacobian(:,c2);
|
coef_y(:,c1+endo_nbr) = jacobian(:,c2);
|
||||||
if M.maximum_lead > 0
|
if M.maximum_lead > 0
|
||||||
[junk,c1,c2] = find(ll(2,:));
|
[~,c1,c2] = find(ll(2,:));
|
||||||
coef_y(:,c1+2*endo_nbr) = jacobian(:,c2);
|
coef_y(:,c1+2*endo_nbr) = jacobian(:,c2);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -142,7 +142,7 @@ while ~done
|
||||||
elseif ischar(grad)
|
elseif ischar(grad)
|
||||||
[g1, badg1] = grad(x1,varargin{:});
|
[g1, badg1] = grad(x1,varargin{:});
|
||||||
else
|
else
|
||||||
[junk1,cost_flag,g1] = penalty_objective_function(x1,fcn,penalty,varargin{:});
|
[~,cost_flag,g1] = penalty_objective_function(x1,fcn,penalty,varargin{:});
|
||||||
badg1 = ~cost_flag;
|
badg1 = ~cost_flag;
|
||||||
end
|
end
|
||||||
wall1=badg1;
|
wall1=badg1;
|
||||||
|
@ -169,7 +169,7 @@ while ~done
|
||||||
elseif ischar(grad)
|
elseif ischar(grad)
|
||||||
[g2, badg2] = grad(x2,varargin{:});
|
[g2, badg2] = grad(x2,varargin{:});
|
||||||
else
|
else
|
||||||
[junk2,cost_flag,g2] = penalty_objective_function(x1,fcn,penalty,varargin{:});
|
[~,cost_flag,g2] = penalty_objective_function(x1,fcn,penalty,varargin{:});
|
||||||
badg2 = ~cost_flag;
|
badg2 = ~cost_flag;
|
||||||
end
|
end
|
||||||
wall2=badg2;
|
wall2=badg2;
|
||||||
|
@ -201,7 +201,7 @@ while ~done
|
||||||
elseif ischar(grad)
|
elseif ischar(grad)
|
||||||
[g3, badg3] = grad(x3,varargin{:});
|
[g3, badg3] = grad(x3,varargin{:});
|
||||||
else
|
else
|
||||||
[junk3,cost_flag,g3] = penalty_objective_function(x1,fcn,penalty,varargin{:});
|
[~,cost_flag,g3] = penalty_objective_function(x1,fcn,penalty,varargin{:});
|
||||||
badg3 = ~cost_flag;
|
badg3 = ~cost_flag;
|
||||||
end
|
end
|
||||||
wall3=badg3;
|
wall3=badg3;
|
||||||
|
@ -261,7 +261,7 @@ while ~done
|
||||||
elseif ischar(grad)
|
elseif ischar(grad)
|
||||||
[gh, badgh] = grad(xh,varargin{:});
|
[gh, badgh] = grad(xh,varargin{:});
|
||||||
else
|
else
|
||||||
[junkh,cost_flag,gh] = penalty_objective_function(x1,fcn,penalty,varargin{:});
|
[~,cost_flag,gh] = penalty_objective_function(x1,fcn,penalty,varargin{:});
|
||||||
badgh = ~cost_flag;
|
badgh = ~cost_flag;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,12 +46,12 @@ for i=1:n
|
||||||
xiold = x(i);
|
xiold = x(i);
|
||||||
h = step_length_correction(xiold,scale,i)*delta;
|
h = step_length_correction(xiold,scale,i)*delta;
|
||||||
x(i) = xiold + h;
|
x(i) = xiold + h;
|
||||||
[f1,junk1,cost_flag1] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
[f1,~,cost_flag1] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
||||||
if ~cost_flag1
|
if ~cost_flag1
|
||||||
fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the right!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h))
|
fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the right!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h))
|
||||||
end
|
end
|
||||||
x(i) = xiold - h;
|
x(i) = xiold - h;
|
||||||
[f2,junk2,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
[f2,~,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
||||||
if ~cost_flag2
|
if ~cost_flag2
|
||||||
fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the left!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h))
|
fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the left!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h))
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,13 +48,13 @@ for i=1:n
|
||||||
xiold = x(i);
|
xiold = x(i);
|
||||||
h = step_length_correction(xiold,scale,i)*delta;
|
h = step_length_correction(xiold,scale,i)*delta;
|
||||||
x(i) = xiold+h;
|
x(i) = xiold+h;
|
||||||
[f1,junk1,cost_flag1,] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
[f1,~,cost_flag1,] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
||||||
x(i) = xiold-h;
|
x(i) = xiold-h;
|
||||||
[f2,junk1,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
[f2,~,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
||||||
x(i) = xiold+2*h;
|
x(i) = xiold+2*h;
|
||||||
[f3,junk1,cost_flag3] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
[f3,~,cost_flag3] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
||||||
x(i) = xiold-2*h;
|
x(i) = xiold-2*h;
|
||||||
[f4,junk1,cost_flag4] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
[f4,~,cost_flag4] = penalty_objective_function(x, fcn, penalty, varargin{:});
|
||||||
if f0<f1 && f1<f3 && f0<f2 && f2<f4
|
if f0<f1 && f1<f3 && f0<f2 && f2<f4
|
||||||
g0 = 0;
|
g0 = 0;
|
||||||
else
|
else
|
||||||
|
|
|
@ -190,7 +190,7 @@ if verbose
|
||||||
disp('Simplex initialization...')
|
disp('Simplex initialization...')
|
||||||
end
|
end
|
||||||
initial_point = x;
|
initial_point = x;
|
||||||
[initial_score,junk1,nopenalty] = feval(objective_function,x,varargin{:});
|
[initial_score,~,nopenalty] = feval(objective_function,x,varargin{:});
|
||||||
if ~nopenalty
|
if ~nopenalty
|
||||||
disp('Cannot initialize the simplex with the provided initial guess.')
|
disp('Cannot initialize the simplex with the provided initial guess.')
|
||||||
skipline()
|
skipline()
|
||||||
|
@ -528,7 +528,7 @@ for j = 1:n
|
||||||
end
|
end
|
||||||
v(:,j+1) = y;
|
v(:,j+1) = y;
|
||||||
x = y;
|
x = y;
|
||||||
[fv(j+1),junk1,nopenalty_flag] = feval(objective_function,x,varargin{:});
|
[fv(j+1),~,nopenalty_flag] = feval(objective_function,x,varargin{:});
|
||||||
if check_delta
|
if check_delta
|
||||||
while ~nopenalty_flag
|
while ~nopenalty_flag
|
||||||
if y(j)~=0
|
if y(j)~=0
|
||||||
|
@ -544,7 +544,7 @@ for j = 1:n
|
||||||
end
|
end
|
||||||
v(:,j+1) = y;
|
v(:,j+1) = y;
|
||||||
x = y;
|
x = y;
|
||||||
[fv(j+1),junk1,nopenalty_flag] = feval(objective_function,x,varargin{:});
|
[fv(j+1),~,nopenalty_flag] = feval(objective_function,x,varargin{:});
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -91,7 +91,7 @@ if options_.ramsey_policy && options_.ACES_solver == 0
|
||||||
opt.jacobian_flag = 0;
|
opt.jacobian_flag = 0;
|
||||||
oo_.steady_state = dynare_solve('ramsey_static',oo_.steady_state,opt,M_,options_,oo_,it_);
|
oo_.steady_state = dynare_solve('ramsey_static',oo_.steady_state,opt,M_,options_,oo_,it_);
|
||||||
options_.solve_algo = old_solve_algo;
|
options_.solve_algo = old_solve_algo;
|
||||||
[junk,junk,multbar] = ramsey_static(oo_.steady_state,M_,options_,oo_,it_);
|
[~,~,multbar] = ramsey_static(oo_.steady_state,M_,options_,oo_,it_);
|
||||||
[jacobia_,M_] = ramsey_dynamic(oo_.steady_state,multbar,M_,options_,oo_,it_);
|
[jacobia_,M_] = ramsey_dynamic(oo_.steady_state,multbar,M_,options_,oo_,it_);
|
||||||
klen = M_.maximum_lag + M_.maximum_lead + 1;
|
klen = M_.maximum_lag + M_.maximum_lead + 1;
|
||||||
dr.ys = [oo_.steady_state;zeros(M_.exo_nbr,1);multbar];
|
dr.ys = [oo_.steady_state;zeros(M_.exo_nbr,1);multbar];
|
||||||
|
@ -123,14 +123,14 @@ else
|
||||||
lq_instruments.sim_ruleids=sim_ruleids;
|
lq_instruments.sim_ruleids=sim_ruleids;
|
||||||
lq_instruments.tct_ruleids=tct_ruleids;
|
lq_instruments.tct_ruleids=tct_ruleids;
|
||||||
%if isfield(lq_instruments,'xsopt_SS') %% changed by BY
|
%if isfield(lq_instruments,'xsopt_SS') %% changed by BY
|
||||||
[junk, lq_instruments.xsopt_SS,lq_instruments.lmopt_SS,s2,check] = opt_steady_get;%% changed by BY
|
[~, lq_instruments.xsopt_SS,lq_instruments.lmopt_SS,s2,check] = opt_steady_get;%% changed by BY
|
||||||
[qc, DYN_Q] = QPsolve(lq_instruments, s2, check); %% added by BY
|
[qc, DYN_Q] = QPsolve(lq_instruments, s2, check); %% added by BY
|
||||||
z = repmat(lq_instruments.xsopt_SS,1,klen);
|
z = repmat(lq_instruments.xsopt_SS,1,klen);
|
||||||
else
|
else
|
||||||
z = repmat(dr.ys,1,klen);
|
z = repmat(dr.ys,1,klen);
|
||||||
end
|
end
|
||||||
z = z(iyr0) ;
|
z = z(iyr0) ;
|
||||||
[junk,jacobia_] = feval([M_.fname '.dynamic'],z,[oo_.exo_simul ...
|
[~,jacobia_] = feval([M_.fname '.dynamic'],z,[oo_.exo_simul ...
|
||||||
oo_.exo_det_simul], M_.params, dr.ys, it_);
|
oo_.exo_det_simul], M_.params, dr.ys, it_);
|
||||||
|
|
||||||
if options_.ACES_solver==1 && (length(sim_ruleids)>0 || length(tct_ruleids)>0 )
|
if options_.ACES_solver==1 && (length(sim_ruleids)>0 || length(tct_ruleids)>0 )
|
||||||
|
|
|
@ -368,7 +368,7 @@ end
|
||||||
save_options_initval_file = options_.initval_file;
|
save_options_initval_file = options_.initval_file;
|
||||||
options_.initval_file = '__';
|
options_.initval_file = '__';
|
||||||
|
|
||||||
[pos_constrained_pf, junk] = find(constrained_perfect_foresight);
|
[pos_constrained_pf, ~] = find(constrained_perfect_foresight);
|
||||||
indx_endo_solve_pf = constrained_vars(pos_constrained_pf);
|
indx_endo_solve_pf = constrained_vars(pos_constrained_pf);
|
||||||
if isempty(indx_endo_solve_pf)
|
if isempty(indx_endo_solve_pf)
|
||||||
pf = 0;
|
pf = 0;
|
||||||
|
@ -572,7 +572,7 @@ else
|
||||||
for t = 1:constrained_periods
|
for t = 1:constrained_periods
|
||||||
|
|
||||||
if direct_mode && ~isempty(is_constraint)
|
if direct_mode && ~isempty(is_constraint)
|
||||||
[pos_constrained_pf, junk] = find(constrained_perfect_foresight .* is_constraint(t, :)');
|
[pos_constrained_pf, ~] = find(constrained_perfect_foresight .* is_constraint(t, :)');
|
||||||
indx_endo_solve_pf = constrained_vars(pos_constrained_pf);
|
indx_endo_solve_pf = constrained_vars(pos_constrained_pf);
|
||||||
if isempty(indx_endo_solve_pf)
|
if isempty(indx_endo_solve_pf)
|
||||||
pf = 0;
|
pf = 0;
|
||||||
|
@ -580,7 +580,7 @@ else
|
||||||
pf = length(indx_endo_solve_pf);
|
pf = length(indx_endo_solve_pf);
|
||||||
end
|
end
|
||||||
|
|
||||||
[pos_constrained_surprise, junk] = find((1-constrained_perfect_foresight) .* is_constraint(t, :)');
|
[pos_constrained_surprise, ~] = find((1-constrained_perfect_foresight) .* is_constraint(t, :)');
|
||||||
indx_endo_solve_surprise = constrained_vars(pos_constrained_surprise);
|
indx_endo_solve_surprise = constrained_vars(pos_constrained_surprise);
|
||||||
|
|
||||||
if isempty(indx_endo_solve_surprise)
|
if isempty(indx_endo_solve_surprise)
|
||||||
|
@ -591,7 +591,7 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
if direct_mode && ~isempty(is_shock)
|
if direct_mode && ~isempty(is_shock)
|
||||||
[pos_shock_pf, junk] = find(shock_perfect_foresight .* is_shock(t, :)');
|
[pos_shock_pf, ~] = find(shock_perfect_foresight .* is_shock(t, :)');
|
||||||
indx_endo_solve_pf = shock_vars(pos_shock_pf);
|
indx_endo_solve_pf = shock_vars(pos_shock_pf);
|
||||||
if isempty(indx_endo_solve_pf)
|
if isempty(indx_endo_solve_pf)
|
||||||
b_pf = 0;
|
b_pf = 0;
|
||||||
|
@ -599,7 +599,7 @@ else
|
||||||
b_pf = length(indx_endo_solve_pf);
|
b_pf = length(indx_endo_solve_pf);
|
||||||
end
|
end
|
||||||
|
|
||||||
[pos_shock_surprise, junk] = find((1-shock_perfect_foresight) .* is_shock(t, :)');
|
[pos_shock_surprise, ~] = find((1-shock_perfect_foresight) .* is_shock(t, :)');
|
||||||
indx_endo_solve_surprise = shock_vars(pos_shock_surprise);
|
indx_endo_solve_surprise = shock_vars(pos_shock_surprise);
|
||||||
|
|
||||||
if isempty(indx_endo_solve_surprise)
|
if isempty(indx_endo_solve_surprise)
|
||||||
|
|
|
@ -179,9 +179,9 @@ if ~isreal(oo_.endo_simul(:)) %can only happen without bytecode
|
||||||
yT = real(oo_.endo_simul(:,options_.periods+2));
|
yT = real(oo_.endo_simul(:,options_.periods+2));
|
||||||
yy = real(oo_.endo_simul(:,2:options_.periods+1));
|
yy = real(oo_.endo_simul(:,2:options_.periods+1));
|
||||||
illi = M_.lead_lag_incidence';
|
illi = M_.lead_lag_incidence';
|
||||||
[i_cols,junk,i_cols_j] = find(illi(:));
|
[i_cols,~,i_cols_j] = find(illi(:));
|
||||||
illi = illi(:,2:3);
|
illi = illi(:,2:3);
|
||||||
[i_cols_J1,junk,i_cols_1] = find(illi(:));
|
[i_cols_J1,~,i_cols_1] = find(illi(:));
|
||||||
i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
|
i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
|
||||||
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
|
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
|
||||||
oo_.exo_simul,M_.params,oo_.steady_state, ...
|
oo_.exo_simul,M_.params,oo_.steady_state, ...
|
||||||
|
|
|
@ -123,16 +123,16 @@ if nargout>1
|
||||||
yy = oo_.endo_simul(:,2:options_.periods+1);
|
yy = oo_.endo_simul(:,2:options_.periods+1);
|
||||||
if ~exist('illi')
|
if ~exist('illi')
|
||||||
illi = M_.lead_lag_incidence';
|
illi = M_.lead_lag_incidence';
|
||||||
[i_cols,junk,i_cols_j] = find(illi(:));
|
[i_cols,~,i_cols_j] = find(illi(:));
|
||||||
illi = illi(:,2:3);
|
illi = illi(:,2:3);
|
||||||
[i_cols_J1,junk,i_cols_1] = find(illi(:));
|
[i_cols_J1,~,i_cols_1] = find(illi(:));
|
||||||
i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
|
i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
|
||||||
end
|
end
|
||||||
if options_.block && ~options_.bytecode
|
if options_.block && ~options_.bytecode
|
||||||
maxerror = oo_.deterministic_simulation.error;
|
maxerror = oo_.deterministic_simulation.error;
|
||||||
else
|
else
|
||||||
if options_.bytecode
|
if options_.bytecode
|
||||||
[chck, residuals, junk]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1);
|
[chck, residuals, ~]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1);
|
||||||
else
|
else
|
||||||
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
|
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
|
||||||
oo_.exo_simul,M_.params,oo_.steady_state, ...
|
oo_.exo_simul,M_.params,oo_.steady_state, ...
|
||||||
|
|
|
@ -71,8 +71,8 @@ y0 = endogenousvariables(:,M.maximum_lag);
|
||||||
yT = endogenousvariables(:,M.maximum_lag+periods+1);
|
yT = endogenousvariables(:,M.maximum_lag+periods+1);
|
||||||
z = endogenousvariables(:,M.maximum_lag+(1:periods));
|
z = endogenousvariables(:,M.maximum_lag+(1:periods));
|
||||||
illi = M.lead_lag_incidence';
|
illi = M.lead_lag_incidence';
|
||||||
[i_cols, junk,i_cols_j] = find(illi(:));
|
[i_cols,~,i_cols_j] = find(illi(:));
|
||||||
illi = illi(:,2:3);
|
illi = illi(:,2:3);
|
||||||
[i_cols_J1, junk,i_cols_1] = find(illi(:));
|
[i_cols_J1,~,i_cols_1] = find(illi(:));
|
||||||
i_cols_T = nonzeros(M.lead_lag_incidence(1:2,:)');
|
i_cols_T = nonzeros(M.lead_lag_incidence(1:2,:)');
|
||||||
dynamicmodel = str2func([M.fname,'.dynamic']);
|
dynamicmodel = str2func([M.fname,'.dynamic']);
|
|
@ -99,16 +99,16 @@ if nargout>1
|
||||||
yy = oo_.endo_simul(:,2:options_.periods+1);
|
yy = oo_.endo_simul(:,2:options_.periods+1);
|
||||||
if ~exist('illi')
|
if ~exist('illi')
|
||||||
illi = M_.lead_lag_incidence';
|
illi = M_.lead_lag_incidence';
|
||||||
[i_cols,junk,i_cols_j] = find(illi(:));
|
[i_cols,~,i_cols_j] = find(illi(:));
|
||||||
illi = illi(:,2:3);
|
illi = illi(:,2:3);
|
||||||
[i_cols_J1,junk,i_cols_1] = find(illi(:));
|
[i_cols_J1,~,i_cols_1] = find(illi(:));
|
||||||
i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
|
i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
|
||||||
end
|
end
|
||||||
if options_.block && ~options_.bytecode
|
if options_.block && ~options_.bytecode
|
||||||
maxerror = oo_.deterministic_simulation.error;
|
maxerror = oo_.deterministic_simulation.error;
|
||||||
else
|
else
|
||||||
if options_.bytecode
|
if options_.bytecode
|
||||||
[chck, residuals, junk]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1);
|
[chck, residuals, ~]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1);
|
||||||
else
|
else
|
||||||
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
|
residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
|
||||||
oo_.exo_simul,M_.params,oo_.steady_state, ...
|
oo_.exo_simul,M_.params,oo_.steady_state, ...
|
||||||
|
|
|
@ -204,7 +204,7 @@ for b=fpar:B
|
||||||
|
|
||||||
if run_smoother
|
if run_smoother
|
||||||
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
[alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,junk1,junk2,P,junk4,junk5,trend_addition,state_uncertainty,M_,oo_,options_,bayestopt_] = ...
|
[alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,~,~,P,~,~,trend_addition,state_uncertainty,M_,oo_,options_,bayestopt_] = ...
|
||||||
DsgeSmoother(deep,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
|
DsgeSmoother(deep,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
|
||||||
|
|
||||||
stock_trend_coeff(options_.varobs_id,irun(9))=trend_coeff;
|
stock_trend_coeff(options_.varobs_id,irun(9))=trend_coeff;
|
||||||
|
|
|
@ -98,8 +98,7 @@ nobs = options_.nobs;
|
||||||
if forecast_ && any(forecast_params)
|
if forecast_ && any(forecast_params)
|
||||||
M1=M_;
|
M1=M_;
|
||||||
M1.params = forecast_params;
|
M1.params = forecast_params;
|
||||||
[junk1,junk2,junk3,junk4,junk5,junk6,oo1] = dynare_resolve(M1,options_,oo_);
|
[~,~,~,~,~,~,oo1] = dynare_resolve(M1,options_,oo_);
|
||||||
clear junk1 junk2 junk3 junk4 junk5 junk6
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if fast_realtime
|
if fast_realtime
|
||||||
|
@ -109,7 +108,7 @@ if fast_realtime
|
||||||
newString=sprintf(running_text);
|
newString=sprintf(running_text);
|
||||||
fprintf(['%s'],newString);
|
fprintf(['%s'],newString);
|
||||||
options_.nobs=fast_realtime;
|
options_.nobs=fast_realtime;
|
||||||
[oo0,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean0] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
|
[oo0,M_,~,~,Smoothed_Variables_deviation_from_mean0] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
|
||||||
gend0 = size(oo0.SmoothedShocks.(M_.exo_names{1}),1);
|
gend0 = size(oo0.SmoothedShocks.(M_.exo_names{1}),1);
|
||||||
prctdone=0.5;
|
prctdone=0.5;
|
||||||
if isoctave
|
if isoctave
|
||||||
|
@ -120,7 +119,7 @@ if fast_realtime
|
||||||
fprintf([s0,'%s'],newString);
|
fprintf([s0,'%s'],newString);
|
||||||
end
|
end
|
||||||
options_.nobs=nobs;
|
options_.nobs=nobs;
|
||||||
[oo2,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean2] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
|
[oo2,M_,~,~,Smoothed_Variables_deviation_from_mean2] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
|
||||||
gend2 = size(oo2.SmoothedShocks.(M_.exo_names{1}),1);
|
gend2 = size(oo2.SmoothedShocks.(M_.exo_names{1}),1);
|
||||||
prctdone=1;
|
prctdone=1;
|
||||||
if isoctave
|
if isoctave
|
||||||
|
@ -142,7 +141,7 @@ for j=presample+1:nobs
|
||||||
% evalin('base',['options_.nobs=' int2str(j) ';'])
|
% evalin('base',['options_.nobs=' int2str(j) ';'])
|
||||||
options_.nobs=j;
|
options_.nobs=j;
|
||||||
if ~fast_realtime
|
if ~fast_realtime
|
||||||
[oo,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
|
[oo,M_,~,~,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
|
||||||
gend = size(oo.SmoothedShocks.(M_.exo_names{1}),1);
|
gend = size(oo.SmoothedShocks.(M_.exo_names{1}),1);
|
||||||
else
|
else
|
||||||
gend = gend0+j-fast_realtime;
|
gend = gend0+j-fast_realtime;
|
||||||
|
|
|
@ -72,7 +72,7 @@ end
|
||||||
|
|
||||||
options_.selected_variables_only = 0; %make sure all variables are stored
|
options_.selected_variables_only = 0; %make sure all variables are stored
|
||||||
options_.plot_priors=0;
|
options_.plot_priors=0;
|
||||||
[oo_, M_, junk1, junk2, Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set, varlist, M_, oo_, options_, bayestopt_, estim_params_);
|
[oo_, M_, ~, ~, Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set, varlist, M_, oo_, options_, bayestopt_, estim_params_);
|
||||||
|
|
||||||
% reduced form
|
% reduced form
|
||||||
dr = oo_.dr;
|
dr = oo_.dr;
|
||||||
|
|
|
@ -97,7 +97,7 @@ if nargin>2
|
||||||
if ~isunix
|
if ~isunix
|
||||||
error('The parallel version of SMM estimation is not implemented for non unix platforms!')
|
error('The parallel version of SMM estimation is not implemented for non unix platforms!')
|
||||||
end
|
end
|
||||||
[junk,hostname] = unix('hostname --fqdn');
|
[~,hostname] = unix('hostname --fqdn');
|
||||||
hostname = deblank(hostname);
|
hostname = deblank(hostname);
|
||||||
master_is_running_a_job = 0;
|
master_is_running_a_job = 0;
|
||||||
for i=1:length(parallel)
|
for i=1:length(parallel)
|
||||||
|
|
|
@ -111,22 +111,22 @@ it_ = M_.maximum_lag + 1;
|
||||||
z = repmat(dr.ys,1,klen);
|
z = repmat(dr.ys,1,klen);
|
||||||
if local_order == 1
|
if local_order == 1
|
||||||
if (options_.bytecode)
|
if (options_.bytecode)
|
||||||
[chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
|
[chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
|
||||||
M_.params, dr.ys, 1);
|
M_.params, dr.ys, 1);
|
||||||
jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd];
|
jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd];
|
||||||
else
|
else
|
||||||
[junk,jacobia_] = feval([M_.fname '.dynamic'],z(iyr0),exo_simul, ...
|
[~,jacobia_] = feval([M_.fname '.dynamic'],z(iyr0),exo_simul, ...
|
||||||
M_.params, dr.ys, it_);
|
M_.params, dr.ys, it_);
|
||||||
end
|
end
|
||||||
elseif local_order == 2
|
elseif local_order == 2
|
||||||
if (options_.bytecode)
|
if (options_.bytecode)
|
||||||
[chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
|
[chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
|
||||||
M_.params, dr.ys, 1);
|
M_.params, dr.ys, 1);
|
||||||
jacobia_ = [loc_dr.g1 loc_dr.g1_x];
|
jacobia_ = [loc_dr.g1 loc_dr.g1_x];
|
||||||
else
|
else
|
||||||
[junk,jacobia_,hessian1] = feval([M_.fname '.dynamic'],z(iyr0),...
|
[~,jacobia_,hessian1] = feval([M_.fname '.dynamic'],z(iyr0),...
|
||||||
exo_simul, ...
|
exo_simul, ...
|
||||||
M_.params, dr.ys, it_);
|
M_.params, dr.ys, it_);
|
||||||
end
|
end
|
||||||
if options_.use_dll
|
if options_.use_dll
|
||||||
% In USE_DLL mode, the hessian is in the 3-column sparse representation
|
% In USE_DLL mode, the hessian is in the 3-column sparse representation
|
||||||
|
@ -217,15 +217,15 @@ nz = nnz(M_.lead_lag_incidence);
|
||||||
|
|
||||||
sdyn = M_.endo_nbr - nstatic;
|
sdyn = M_.endo_nbr - nstatic;
|
||||||
|
|
||||||
[junk,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ...
|
[~,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ...
|
||||||
order_var));
|
order_var));
|
||||||
b = zeros(M_.endo_nbr,M_.endo_nbr);
|
b = zeros(M_.endo_nbr,M_.endo_nbr);
|
||||||
b(:,cols_b) = jacobia_(:,cols_j);
|
b(:,cols_b) = jacobia_(:,cols_j);
|
||||||
|
|
||||||
if M_.maximum_endo_lead == 0
|
if M_.maximum_endo_lead == 0
|
||||||
% backward models: simplified code exist only at order == 1
|
% backward models: simplified code exist only at order == 1
|
||||||
if local_order == 1
|
if local_order == 1
|
||||||
[k1,junk,k2] = find(kstate(:,4));
|
[k1,~,k2] = find(kstate(:,4));
|
||||||
dr.ghx(:,k1) = -b\jacobia_(:,k2);
|
dr.ghx(:,k1) = -b\jacobia_(:,k2);
|
||||||
if M_.exo_nbr
|
if M_.exo_nbr
|
||||||
dr.ghu = -b\jacobia_(:,nz+1:end);
|
dr.ghu = -b\jacobia_(:,nz+1:end);
|
||||||
|
|
|
@ -204,7 +204,7 @@ if ~isempty(options_.nk) && options_.nk ~= 0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
positions_in_declaration_order=oo_.dr.order_var(bayestopt_.smoother_var_list(bayestopt_.smoother_saved_var_list));
|
positions_in_declaration_order=oo_.dr.order_var(bayestopt_.smoother_var_list(bayestopt_.smoother_saved_var_list));
|
||||||
[junk,sorted_index_declaration_order]=sort(positions_in_declaration_order);
|
[~,sorted_index_declaration_order]=sort(positions_in_declaration_order);
|
||||||
oo_.FilteredVariablesKStepAhead(:,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAhead;
|
oo_.FilteredVariablesKStepAhead(:,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAhead;
|
||||||
if ~isempty(PK) && options_.filter_covariance %get K-step ahead variances
|
if ~isempty(PK) && options_.filter_covariance %get K-step ahead variances
|
||||||
oo_.FilteredVariablesKStepAheadVariances(:,sorted_index_declaration_order,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAheadVariances;
|
oo_.FilteredVariablesKStepAheadVariances(:,sorted_index_declaration_order,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAheadVariances;
|
||||||
|
|
|
@ -31,7 +31,7 @@ function [hasLicense] = user_has_matlab_license(toolbox)
|
||||||
if matlab_ver_less_than('7.12')
|
if matlab_ver_less_than('7.12')
|
||||||
hasLicense = license('test', toolbox);
|
hasLicense = license('test', toolbox);
|
||||||
else
|
else
|
||||||
[hasLicense, junk] = license('checkout',toolbox);
|
[hasLicense, ~] = license('checkout',toolbox);
|
||||||
end
|
end
|
||||||
if ~hasLicense
|
if ~hasLicense
|
||||||
return
|
return
|
||||||
|
|
|
@ -21,7 +21,7 @@ a = dir('*.mod');
|
||||||
|
|
||||||
|
|
||||||
for i = 1:length(a)
|
for i = 1:length(a)
|
||||||
[junk,basename,extension] = fileparts(a(i).name);
|
[~,basename,extension] = fileparts(a(i).name);
|
||||||
if exist([basename '.m'])
|
if exist([basename '.m'])
|
||||||
delete([basename '.m']);
|
delete([basename '.m']);
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,7 +48,7 @@ if ~all(check)
|
||||||
end
|
end
|
||||||
|
|
||||||
nvar = length(i_var);
|
nvar = length(i_var);
|
||||||
[i_var_unique, index_uniques, junk] = unique(i_var, 'first');
|
[i_var_unique, index_uniques, ~] = unique(i_var, 'first');
|
||||||
index_uniques = sort(index_uniques);
|
index_uniques = sort(index_uniques);
|
||||||
i_var_unique = i_var(index_uniques);
|
i_var_unique = i_var(index_uniques);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue