Basic rbc model with temporary and permanent shocks

Hello, I am trying to write dynare codes for basic rbc model with temporary and permanent shocks. I wrote this code below but I have still not figured out what I need to do for temporary and permanent shocks. How I can add them into the model? Can anyone explain that to me, please? Best.

var y c x l k w r A;
varexo z;

parameters alpha beta delta psi rho sigma;
alpha = 0.36;
beta = 0.99;
delta = 0.019;
psi = 1.75;
rho = 0.95;
sigma = 0.007;

model;
1/c = beta * (1/c(+1) * (1+r(+1)-delta));
psi * c = w * (1-l);
w = A * (1-alpha) * k^alpha * l^(-alpha);
r = A * alpha * k^(alpha-1) * l^(1-alpha);
c + k(+1) = A * k^alpha * l^(1-alpha) + (1-delta)k;
log(A) = rho
log(A(-1)) + z;
y = A * k ^ alpha * l ^ ( 1-alpha );
i = y - c;

steady_state_model;
r = 1 / beta - 1 + delta;
k_y = alpha / r;
x_y = delta * k_y;
c_y = 1 - i_y;
l = (1-alpha) / (psi * c_y + 1 - alpha);
k_l = k_y ^ (1/(1-alpha));
k = k_l * l;
A = 1;
y = A * k^alpha * l^(1-alpha);
w = (1-alpha) * y / l;
i = i_y * y;
c = c_y * y;
end;
shocks;
var z;
stderr sigma;
end;
stoch_simul (order = 2, irf = 40);

You need to set up the model in Dynare in detrended form and then recover the non-stationary movement of the underlying non-stationary variables following a permanent shock. For an example, see the AguiarGopinath2007.mod at my homepage at sites.google.com/site/pfeiferecon/dynare

Thank you very much for your help. I checked the mod file that you suggested me and I wrote my code based on it but now I am getting a mistake and i could not figure out it my self. I got this error message in below. Could you please tell me how can i fix that? I also posted my codes if you like to look at it.
best,

Reference to non-existent field ‘exo_nbr’.

Error in basicrbc (line 181)
if M_.exo_nbr > 0;

Error in dynare (line 180)
evalin(‘base’,fname) ;
basicrbc.mod (1.58 KB)

Never put a clear all in your mod-file

Hi,
now, I am trying to build basic rbc model with separable utility function and also using permanent and temporary shocks. I am getting that mistakes in below.Could you please tell me what is the meaning of that error and how can I sort out that problem? Thanks in advance.
Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : NaN
Equation number 3 : 0.0019418
Equation number 4 : -0.073565
Equation number 5 : 0
Equation number 6 : 1.0451
Equation number 7 : 0.71068
Equation number 8 : 0.0289
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : NaN
Equation number 12 : 0

Warning: Some of the parameters have no value (chi) when using steady. If these parameters are not initialized in
a steadystate file, Dynare may not be able to solve the model…

In test_for_deep_parameters_calibration at 46
In steady at 33
In basicrbcs at 200
In dynare at 180

STEADY: The Jacobian contains Inf or NaN. The problem arises from:

STEADY: Derivative of Equation 2 with respect to Variable h (initial value of h: 1)
STEADY: Derivative of Equation 11 with respect to Variable h (initial value of h: 1)

STEADY: The problem most often occurs, because a variable with
STEADY: exponent smaller than 1 has been initialized to 0. Taking the derivative
STEADY: and evaluating it at the steady state then results in a division by 0.
Error using dynare_solve (line 60)
An element of the Jacobian is not finite or NaN

Error in evaluate_steady_state (line 66)
[ys,check] = dynare_solve([M.fname ‘_static’],…

Error in steady_ (line 54)
[steady_state,params,info] =
evaluate_steady_state(oo_.steady_state,M_,options_,oo_,~options_.steadystate.nocheck);
Error in steady (line 81)
[steady_state,M_.params,info] = steady_(M_,options_,oo_);

Error in basicrbcs (line 200)
steady;

Error in dynare (line 180)
evalin(‘base’,fname) ;
basicrbcs.mod (1.76 KB)

An alternative is to have both a stationary and a unit root shock in an undetrended model:

var y, c, k, a, h, a_temp, a_perm;
varexo e, u;

parameters beta, rho, alpha, delta, theta, psi, tau;

alpha = 0.36;
rho   = 0.95;
tau   = 0.025;
beta  = 0.99;
delta = 0.025;
psi   = 0;
theta = 2.95;

phi   = 0.1;

model;
c*theta*h^(1+psi)=(1-alpha)*y;
k = beta*(c/c(+1))*(alpha*y(+1)+(1-delta)*k);
y = exp(a)*(k(-1)^alpha)*(h^(1-alpha));
k = (y-c)+(1-delta)*k(-1);
a = a_temp+a_perm;
a_temp=rho*a_temp(-1) + e;
a_perm=a_perm(-1) + u;
end;

initval;
y = 1.08068253095672;
c = 0.80359242014163;
h = 0.29175631001732;
k = 11.08360443260358;
a = 0;
a_temp = 0;
a_perm= 0;
e = 0;
u = 0;
end;

shocks;
var e; stderr 1;
var u; stderr 1;
end;
check;
stoch_simul(order=1,irf=200);
1 Like