# How to simulate deterministic growth model

Hi, I am trying to simulate a Ramsey-Kass-Koopmans model that has deterministic growth and plot process of convergence to steady state. I can compute the de-trended steady state easily, however plotting the actual convergence I haven’t yet figured out. My code currently reads:

``````%%file Dynare_model\NGM\NGM_approx.mod
@#define periods=100

parameters beta delta gamma alpha g;

periods = @{periods};
varexo Z;
%trend_var(growth_factor=1+g) Z;
% Equation is: k'=A^(1-alpha) k^alpha -c +(1-delta-g)k
% if we normalize, divide by A:
%var(deflator=Z) k;
%var(deflator=Z) c;
var k;
var c;

beta = 0.98;
delta = 0.01;
alpha = 0.3;
gamma = 2.0;
g=0.05;

model;
(c)^(1-gamma)/c = beta*((c(+1))^(1-gamma)/c(+1))*(1+alpha*Z(-1)^(1-alpha)*k(-1)^(alpha)/k(-1)-delta-g);
k = Z(-1)^(1-alpha)*k(-1)^alpha - c + (1-delta-g)*k(-1);
end;

initval;
k = 0.7;
c = 1.0;
end;

shock_vals_Z = cumprod((1+g)*ones(@{periods},1));
shocks;
var Z;
periods 1:@{periods};
values (shock_vals_Z);
end;

endval;
Z = 1*(1+g)^(@{periods}+1);
k =Z*(1+g)*(delta+g)^(1/alpha-1);
end;

stoch_simul(periods=@{periods});
%perfect_foresight_setup(periods=@{periods});

%perfect_foresight_solver;
rplot k c;
``````

any suggestions?

You cannot call `steady` to compute a steady state in a trending model.

Thanks so much for the reply.

Then how do I compute the detrended model and plot convergence to the detrended steady state? If you look at the commented-out section I tried to do exactly this with a trend_var and the perfect_foresight_solver. This does not actually let me track convergence though. Do I need to manually detrend? I’ve tried this too, with no luck.