Skip to content
Snippets Groups Projects
Commit 24d18c78 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Merge branch 'exogenouslag-4.6' into '4.6'

Exogenouslag 4.6

See merge request Dynare/dynare!1760
parents 95084543 e8e02cf7
No related branches found
No related tags found
2 merge requests!1815WIP Cherry-picks for 4.6,!1760Exogenouslag 4.6
Pipeline #4140 passed
...@@ -120,9 +120,13 @@ if max(abs(d1))>options.solve_tolf ...@@ -120,9 +120,13 @@ if max(abs(d1))>options.solve_tolf
error('Jacobian is not evaluated at the steady state!') error('Jacobian is not evaluated at the steady state!')
end end
% current variables
[r0,c0,v0] = find(jacobian(:,jc)); [r0,c0,v0] = find(jacobian(:,jc));
% current and predetermined
[rT,cT,vT] = find(jacobian(:,jpc)); [rT,cT,vT] = find(jacobian(:,jpc));
% current and jump variables
[r1,c1,v1] = find(jacobian(:,jcn)); [r1,c1,v1] = find(jacobian(:,jcn));
% all endogenous variables
[rr,cc,vv] = find(jacobian(:,jendo)); [rr,cc,vv] = find(jacobian(:,jendo));
iv0 = 1:length(v0); iv0 = 1:length(v0);
...@@ -155,9 +159,16 @@ for it = (maximum_lag+1):(maximum_lag+periods) ...@@ -155,9 +159,16 @@ for it = (maximum_lag+1):(maximum_lag+periods)
nv = length(vv); nv = length(vv);
iA(iv+m,:) = [i_rows(rr),i_cols_A(cc),vv]; iA(iv+m,:) = [i_rows(rr),i_cols_A(cc),vv];
end end
if M.maximum_exo_lag > 0
% needed as jacobian for lagged exogenous variables is wrong
% in current version of Dynare
zz = Y(i_cols);
res(i_rows) = dynamicmodel(zz, exogenousvariables, params, steadystate_y, it);
else
z(jendo) = Y(i_cols); z(jendo) = Y(i_cols);
z(jexog) = transpose(exogenousvariables(it,:)); z(jexog) = transpose(exogenousvariables(it,:));
res(i_rows) = jacobian*z; res(i_rows) = jacobian*z;
end
m = m + nv; m = m + nv;
i_rows = i_rows + ny; i_rows = i_rows + ny;
i_cols = i_cols + ny; i_cols = i_cols + ny;
......
...@@ -38,13 +38,13 @@ dynamicmodel = str2func([M.fname,'.dynamic']); ...@@ -38,13 +38,13 @@ dynamicmodel = str2func([M.fname,'.dynamic']);
info.status = 1; info.status = 1;
for it = 2:options.periods+1 for it = M.maximum_lag + (1:options.periods)
yb = endogenousvariables(:,it-1); % Values at previous period, also used as guess value for current period yb = endogenousvariables(:,it-1); % Values at previous period, also used as guess value for current period
yb1 = yb(iyb); yb1 = yb(iyb);
[tmp, check] = solve1(dynamicmodel, [yb1; yb], 1:M.endo_nbr, nyb+1:nyb+M.endo_nbr, ... [tmp, check] = solve1(dynamicmodel, [yb1; yb], 1:M.endo_nbr, nyb+1:nyb+M.endo_nbr, ...
1, options.gstep, options.dynatol.f, options.dynatol.x, ... 1, options.gstep, options.dynatol.f, options.dynatol.x, ...
options.simul.maxit, options.debug, exogenousvariables, ... options.simul.maxit, options.debug, exogenousvariables, ...
M.params, steadystate, it+M.maximum_lag-1); M.params, steadystate, it);
if check if check
info.status = 0; info.status = 0;
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment