diff --git a/matlab/perfect-foresight-models/perfect_foresight_problem.m b/matlab/perfect-foresight-models/perfect_foresight_problem.m
index a4df03f80bf621942d27693f0efa22402d0b8d27..d27ec6eaf0115a39d8e160df60437d5a16363424 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_problem.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_problem.m
@@ -71,7 +71,7 @@ i_rows = 1:ny;
 i_cols_J = i_cols;
 offset = 0;
 
-for it = 2:(T+1)
+for it = (maximum_lag+1):(T+1)
     if nargout == 1
         residuals(i_rows) = dynamic_function(YY(i_cols),exo_simul, params, ...
                                              steady_state,it);