var lc, lk, lr, lz;
varexo e;

parameters beta_P, theta_p, rho_p, niu_p, phi_p;

%calibrated parameters
beta_P  =   0.99;
rho_p   = 0.36;
theta_p = 0.025;
niu_p = 1;
phi_p = 0.95;

model;
    exp(lc) = exp(lz) * (exp(lk(-1))^rho_p) + (1 - theta_p)*exp(lk(-1)) - exp(lk);

    exp(lr) = rho_p * exp(lz) * (exp(lk(-1))^(rho_p-1)) + 1-theta_p;

    1 = beta_P * ((exp(lc)/exp(lc(+1)))^niu_p) * exp(lr(+1));

    lz = phi_p*lz(-1) + e;
end; // end model

initval; // initialization for the steady state

    lr  = log(1/beta_P);
    lk  = log( (rho_p/(1/beta_P - 1 + theta_p))^(1/(1-rho_p)));
    lc  = lk^rho_p - theta_p*lk;
    lz   = 0;

end;

steady;
check; // check for the Blanchard-Kahn condition. Nr. of eigenvalues should not be greater than the nr. of lead variables.

shocks;
    var e = 0.007;
end;



stoch_simul(order=1, irf = 320);
//stoch_simul(irf=32, periods = 2100);
//pause;
//plot(lr);