Commit 7e13fe5e authored by MichelJuillard's avatar MichelJuillard
Browse files

fix loglinear option with leaded or lagged exogenous variables

parent e07d97a1
......@@ -88,7 +88,7 @@ switch task
if isfield(oo.Smoother,'Constant') && isfield(oo.Smoother.Constant,v_name)
y0(i,:)=y0(i,:)-oo.Smoother.Constant.(v_name)(end-maximum_lag+1:end); %subtract mean or steady state
if options.loglinear
y0(i,:)=y0(i,:)+log(oo.dr.ys(strmatch(v_name,deblank(M.endo_names),'exact')));
y0(i,:)=y0(i,:)+log_variable(i,oo.dr.ys,M);
else
y0(i,:)=y0(i,:)+oo.dr.ys(strmatch(v_name,deblank(M.endo_names),'exact'));
end
......
......@@ -108,8 +108,9 @@ if info(1)
end
if options.loglinear
% Find variables with non positive steady state.
idx = find(dr.ys<1e-9);
% Find variables with non positive steady state. Skip auxiliary
% variables for lagges/leaded exogenous variables
idx = find(dr.ys(get_all_variables_but_lagged_leaded_exogenous(M)) < 1e-9);
if length(idx)
if options.debug
variables_with_non_positive_steady_state = M.endo_names(idx,:);
......
......@@ -84,8 +84,8 @@ else
end
if options_.loglinear && isfield(oo_.dr,'ys') && options_.logged_steady_state==0 %log steady state for correct display of decision rule
oo_.dr.ys=log(oo_.dr.ys);
oo_.steady_state=log(oo_.steady_state);
oo_.dr.ys=log_variable(1:M_.endo_nbr,oo_.dr.ys,M_);
oo_.steady_state=log_variable(1:M_.endo_nbr,oo_.steady_state,M_);
options_old.logged_steady_state = 1; %make sure option is preserved outside of stoch_simul
options_.logged_steady_state=1; %set option for use in stoch_simul
end
......
......@@ -334,12 +334,16 @@ end
if options_.loglinear
% this needs to be extended for order=2,3
k = find(dr.kstate(:,2) <= M_.maximum_endo_lag+1);
klag = dr.kstate(k,[1 2]);
k1 = dr.order_var;
dr.ghx = repmat(1./dr.ys(k1),1,size(dr.ghx,2)).*dr.ghx.* ...
repmat(dr.ys(k1(klag(:,1)))',size(dr.ghx,1),1);
dr.ghu = repmat(1./dr.ys(k1),1,size(dr.ghu,2)).*dr.ghu;
k = get_all_variables_but_lagged_leaded_exogenous(M_);
[ik,k1] = rm_lagged_leaded_exogenous_variables(dr.order_var,M_);
[iklag,klag1] = rm_lagged_leaded_exogenous_variables(dr.order_var(M_.nstatic+(1:M_.nspred)),M_);
if ~isempty(ik)
if M_.maximum_endo_lag > 0
dr.ghx(ik,iklag) = repmat(1./dr.ys(k1),1,length(klag1)).*dr.ghx(ik,iklag).* ...
repmat(dr.ys(klag1)',length(ik),1);
end
dr.ghu(ik,:) = repmat(1./dr.ys(k1),1,M_.exo_nbr).*dr.ghu(ik,:);
end
if options_.order>1
error('Loglinear options currently only works at order 1')
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment