v4.1: add provision for <modfile>_steady_state.m and auxiliary variables for leads on more than 1 period

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3022 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
michel 2009-10-06 14:37:23 +00:00
parent ed5bad62c3
commit ce5c510d06
7 changed files with 57 additions and 13 deletions

View File

@ -1,9 +1,27 @@
function ys1 = add_auxiliary_variables_to_steadystate(ys,aux_vars)
function ys1 = add_auxiliary_variables_to_steadystate(ys,aux_vars,fname, ...
exo_steady_state, exo_det_steady_state,params)
n = length(aux_vars);
ys1 = [ys;zeros(n,1)];
k = size(ys,1)+1;
aux_lead_nbr = 0;
for i=1:n
ys1(k) = ys(aux_vars(i).orig_endo_index);
if aux_vars(i).type == 1
ys1(k) = ys(aux_vars(i).orig_endo_index);
elseif aux_vars(i).type == 0
aux_lead_nbr = aux_lead_nbr + 1;
end
k = k+1;
end
for i=1:aux_lead_nbr + 1;
res = feval([fname '_static'],ys1,...
[exo_steady_state; ...
exo_det_steady_state],params);
for j=1:n
if aux_vars(j).type == 0
el = aux_vars(j).endo_index;
ys1(el) == res(el);
end
end
end

View File

@ -281,10 +281,16 @@ if ~isempty(estim_params_)
set_parameters(xparam1);
end
if options_.steadystate_flag% if the *_steadystate.m file is provided.
[ys,tchek] = feval([M_.fname '_steadystate'],[],[]);
[ys,tchek] = feval([M_.fname '_steadystate'],...
[zeros(M_.exo_nbr,1);...
oo_.exo_det_steady_state]);
if size(ys,1) < M_.endo_nbr
if isfield(M_,'aux_vars')
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars);
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
M_.fname,...
zeros(M_.exo_nbr,1),...
oo_.exo_det_steady_state,...
M_.params);
else
error([M_.fname '_steadystate.m doesn''t match the model']);
end
@ -521,14 +527,15 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
else
[xparam1,fval,exitflag] = fminsearch(fh,xparam1,optim_options,gend);
end
case 101
case 101
myoptions=soptions;
myoptions(2)=1e-6; %accuracy of argument
myoptions(3)=1e-6; %accuracy of function (see Solvopt p.29)
myoptions(5)= 1.0;
[xparam1,fval]=solvopt(xparam1,fh,[],myoptions,gend,data);
case 102
case 102
%simulating annealing
% LB=zeros(size(xparam1))-20;
% UB=zeros(size(xparam1))+20;
@ -572,7 +579,8 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation
,neps,maxevl,LB,UB,c,idisp ,t,vm,gend);
end
otherwise
error(['ESTIMATION: mode_compute=' int2str(options_.mode_compute) ' option is unknown!'])
error(['ESTIMATION: mode_compute=' int2str(options_.mode_compute) ...
' option is unknown!'])
end
if options_.mode_compute ~= 5
if options_.mode_compute ~= 6

View File

@ -70,7 +70,11 @@ function initial_estimation_checks(xparam1,gend,data,data_index,number_of_observ
oo_.exo_det_steady_state]);
if size(ys,1) < M_.endo_nbr
if isfield(M_,'aux_vars')
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars);
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
M_.fname,...
oo_.exo_steady_state,...
oo_.exo_det_steady_state,...
M_.params);
else
error([M_.fname '_steadystate.m doesn''t match the model']);
end

View File

@ -80,7 +80,10 @@ function model_diagnostics(M_,options_,oo_)
[oo_.exo_steady_state; oo_.exo_det_steady_state]);
if size(ys,1) < M_.endo_nbr
if isfield(M_,'aux_vars')
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars);
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
M_.fname,...
oo_.exo_steady_state,...
oo_.exo_det_steady_state);
else
error([M_.fname '_steadystate.m doesn''t match the model']);
end

View File

@ -48,7 +48,10 @@ function osr1(i_params,i_var,weights)
[oo_.exo_steady_state; oo_.exo_det_steady_state]);
if size(ys,1) < M_.endo_nbr
if isfield(M_,'aux_vars')
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars);
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
M_.fname,...
oo_.exo_steady_state,...
oo_.exo_det_steady_state);
else
error([M_.fname '_steadystate.m doesn''t match the model']);
end

View File

@ -73,7 +73,11 @@ if options_.steadystate_flag
oo_.exo_det_steady_state]);
if size(dr.ys,1) < M_.endo_nbr
if isfield(M_,'aux_vars')
dr.ys = add_auxiliary_variables_to_steadystate(dr.ys,M_.aux_vars);
dr.ys = add_auxiliary_variables_to_steadystate(dr.ys,M_.aux_vars,...
M_.fname,...
oo_.exo_steady_state,...
oo_.exo_det_steady_state,...
M_.params);
else
error([M_.fname '_steadystate.m doesn''t match the model']);
end

View File

@ -43,7 +43,11 @@ function steady_()
oo_.exo_det_steady_state]);
if size(ys,1) < M_.endo_nbr
if isfield(M_,'aux_vars')
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars);
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
M_.fname,...
oo_.exo_steady_state,...
oo_.exo_det_steady_state,...
M_.params);
else
error([M_.fname '_steadystate.m doesn''t match the model']);
end