// A growthless growth model with efficiency (CES production function)
// stephane [DOT] adjemian [AT] ens [DOT] fr [11-02-2008]


// Declare the endogenous variables:
var c k eff;


// Declare the deep parameters:
parameters teta A alfa epsil betta delta PSI rho effstar;


// Calibration of the deep paramaters:
teta = 3.000;
alfa = 0.300;
epsil = 0.100;
betta = 0.980;
delta = 0.020;
A = (1/betta+delta-1)/alfa ;  // A is such that the steady state level of physical capital is one.
PSI = (epsil-1)/epsil ;
rho = .95;
effstar = 1;


// Declaration of the model.

model; 
    (c(1)/c)^teta - betta*(alfa*A*eff(1)*( alfa*k^PSI + 1-alfa )^(1/PSI-1)*k^(PSI-1)+1-delta);//*(1/c(1))^teta ;
    c + k - A*eff*( alfa*k(-1)^PSI + 1-alfa)^(1/PSI) - (1-delta)*k(-1);
    eff = (eff(-1)^rho)*(effstar^(1-rho));
end;


// Here we set the initial value for efficiency and physical capital stock. Note that
// we do not need to specify an initial value for consumption because this is a jumping
// variable. In this example we do not start the simulation from the steady state.

initval;
    eff = 0.8;
    k = 1.2;
end;


// Here we impose that the terminal level is the steady state. 
// First we provide some terminal values for the endogenous variables in the endval block.

endval;
    eff = 0.95;
    k = 1.05;
    c = 2;
end;

// Second, using the values defined in the previous block as an initial guess we compute the steady state :

steady;

// => The steady state will be the terminal level of the path simulation.
// Note that in this example we do provide in the same directory a file called dog_steadystate.m. Dynare will first
// check that the steady state defined in this file is correct. If this is not the case, Dynare will use a Newton
// like algorithm to compute the steady state, starting with the initial guess defined in the endval block. 

// Trigger the deterministic simulation:

simul(periods = 200);


// Plot the solution paths:

figure('Name','Consumption path')
plot(c(2:131));
axis tight;

figure('Name','Physical capital path')
plot(k(1:130));
axis tight;

figure('Name','Efficiency path')
plot(eff(1:130));
axis tight;