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

Fix various issues with stack_solve_algo=7 and lags on exogenous > 1

Complete the fix started in 8913791f.

Change the test case to prevent regressions.

(cherry picked from commit 79484607)
parent 2cad7ca7
No related branches found
No related tags found
No related merge requests found
......@@ -55,9 +55,9 @@ for it = maximum_lag+(1:T)
z(jexog) = transpose(exo_simul(it,:));
residuals(i_rows) = dynamicjacobian*z;
if nargout == 2
if it == 2
if it == maximum_lag+1
JJacobian(i_rows,i_cols_J1) = dynamicjacobian(:,i_cols_1);
elseif it == T + 1
elseif it == maximum_lag+T
JJacobian(i_rows,i_cols_J(i_cols_T)) = dynamicjacobian(:,i_cols_T);
else
JJacobian(i_rows,i_cols_J) = dynamicjacobian(:,i_cols_j);
......
......@@ -74,7 +74,7 @@ i_rows = 1:ny;
offset = 0;
i_cols_J = i_cols;
for it = 2:(T+1)
for it = maximum_lag+(1:T)
if nargout == 1
res = dynamic_function(YY(i_cols),exo_simul, params, ...
steady_state,it);
......@@ -83,15 +83,15 @@ for it = 2:(T+1)
[res,jacobian] = dynamic_function(YY(i_cols),exo_simul, params, ...
steady_state,it);
residuals(i_rows) = res(eq_index);
if it == 2
if it == maximum_lag+1
[rows,cols,vals] = find(jacobian(eq_index,i_cols_1));
iJacobian{1} = [offset+rows, i_cols_J1(cols), vals];
elseif it == T + 1
elseif it == maximum_lag+T
[rows,cols,vals] = find(jacobian(eq_index,i_cols_T));
iJacobian{T} = [offset+rows, i_cols_J(i_cols_T(cols)), vals];
else
[rows,cols,vals] = find(jacobian(eq_index,i_cols_j));
iJacobian{it-1} = [offset+rows, i_cols_J(cols), vals];
iJacobian{it-maximum_lag} = [offset+rows, i_cols_J(cols), vals];
i_cols_J = i_cols_J + ny;
end
offset = offset + ny;
......
......@@ -71,22 +71,22 @@ i_rows = 1:ny;
i_cols_J = i_cols;
offset = 0;
for it = (maximum_lag+1):(T+1)
for it = maximum_lag+(1:T)
if nargout == 1
residuals(i_rows) = dynamic_function(YY(i_cols),exo_simul, params, ...
steady_state,it);
elseif nargout == 2
[residuals(i_rows),jacobian] = dynamic_function(YY(i_cols),exo_simul, params, ...
steady_state,it);
if it == 2
if it == maximum_lag+1
[rows,cols,vals] = find(jacobian(:,i_cols_1));
iJacobian{1} = [offset+rows, i_cols_J1(cols), vals];
elseif it == T + 1
elseif it == maximum_lag+T
[rows,cols,vals] = find(jacobian(:,i_cols_T));
iJacobian{T} = [offset+rows, i_cols_J(i_cols_T(cols)), vals];
else
[rows,cols,vals] = find(jacobian(:,i_cols_j));
iJacobian{it-1} = [offset+rows, i_cols_J(cols), vals];
iJacobian{it-maximum_lag} = [offset+rows, i_cols_J(cols), vals];
i_cols_J = i_cols_J + ny;
end
offset = offset + ny;
......
......@@ -67,9 +67,9 @@ elseif (options.solve_algo == 11)
end
end
y0 = endogenousvariables(:,1);
yT = endogenousvariables(:,periods+2);
z = endogenousvariables(:,2:periods+1);
y0 = endogenousvariables(:,M.maximum_lag);
yT = endogenousvariables(:,M.maximum_lag+periods+1);
z = endogenousvariables(:,M.maximum_lag+(1:periods));
illi = M.lead_lag_incidence';
[i_cols, junk,i_cols_j] = find(illi(:));
illi = illi(:,2:3);
......
......@@ -69,7 +69,7 @@ else
check = 1;
end
endogenousvariables = [y0 reshape(y, M.endo_nbr, options.periods) yT];
endogenousvariables(:, M.maximum_lag+(1:options.periods)) = reshape(y, M.endo_nbr, options.periods);
if check
info.status = false;
......
......@@ -17,7 +17,7 @@ sigma2 = 0;
model;
// Eq. n°1:
efficiency = rho*efficiency(-1) + EfficiencyInnovation;
efficiency = rho*efficiency(-1) + EfficiencyInnovation(-2); // Use a lag of two to test the maximum_lag logic
// Eq. n°2:
Efficiency = effstar*exp(efficiency);
......
......@@ -17,7 +17,7 @@ sigma2 = 0;
model;
// Eq. n°1:
efficiency = rho*efficiency(-1) + EfficiencyInnovation;
efficiency = rho*efficiency(-1) + EfficiencyInnovation(-2); // Use a lag of two to test the maximum_lag logic
// Eq. n°2:
Efficiency = effstar*exp(efficiency);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment