Perfect Foresight error

I’m trying to solve this code:

var c, k;
varexo G;
parameters beta, alpha, delta, TFP;

beta=0.99;
alpha=0.36;
delta=0.025;
TFP=1;

model;
c=beta*c(-1)*(TFP*alpha*(1/k(-1))^(1-alpha)+1-delta);
k=(1-delta)*k(-1)-c(-1)+(1-alpha)*TFP*k(-1)^alpha+TFP*alpha*k(-1)^alpha-G;
end;

initval;
c=1;
k=10;
end;
steady;

shocks;
var G;
periods 0:47, 48:95, 96:156;
values 0.3, 1.2, 0.3;
end;

endval;
G = 0.3;
end;

steady;

perfect_foresight_setup(periods=156);
perfect_foresight_solver;

subplot(2,2,1); plot(c); title('consumption');
subplot(2,2,2); plot(k); title('capital');

Everything works except for the perfect foresight section. I get this error when I run the code:

Error using perfect_foresight_problem
M_.lead_lag_incidence should be a double
precision matrix with 2+M_.maximum_endo_lag rows
and M_.endo_nbr columns

Error in perfect_foresight_solver (line 210)
residuals = perfect_foresight_problem(yy(:), y0, yT, oo_.exo_simul, M_.params, oo_.steady_state, periods, M_, options_);

Error in PS_2.driver (line 170)
perfect_foresight_solver;

Error in dynare (line 281)
evalin(‘base’,[fname ‘.driver’]);

I’m running this on macOS Monterey and have added file to path. Not sure what I’m doing wrong but would appreciate any help

The message is due to a bug. See Fix perfect_foresight_problem.cc for case without leaded variables (#1850) · Issues · Dynare / dynare · GitLab
But the problem in your mod-file is that there are no forward-looking variables. In your Euler equation, it needs to be c(+1) on the right.

1 Like

Thank you very much! It works perfectly now