RBC Model with Search Frictions

Hello!

I m trying to incorporate search frictions in the labour side of an RBC model. The original RBC code is the following

close all;
warning off ;

%----------------------------------------------------------------
% 1. Defining variables
%----------------------------------------------------------------

// Endogenous variables (13)
var y c h ii la k a g r; //

// Exogenous variables (3)
varexo u_a u_g;

// Parameters (17)
parameters BETA DELTA OMEGA ALPHA GAMMA;
parameters RHO_a SIGMA_a RHO_g SIGMA_g;
parameters g_ss a_ss g_to_y_ss r_ss h_ss;

%----------------------------------------------------------------
% 2. Calibration
%----------------------------------------------------------------

// Calibarted parameteres (BETA, OMEGA, g_ss are determined in teh calibration)
DELTA=0.023;
ALPHA=0.33;
GAMMA=1;
RHO_a=0.95;
SIGMA_a=0.01;
RHO_g=0.90;
SIGMA_g=0.01;

// Targeted steady state values
a_ss=1;
g_to_y_ss=0.1;
r_ss=0.04/4;
h_ss=0.3;

%----------------------------------------------------------------
% 3. Model (13 equations)
%----------------------------------------------------------------

model;

exp(la)=exp©^(-GAMMA)(1-exp(h))^(OMEGA(1-GAMMA));
OMEGAexp©/(1-exp(h))=(1-ALPHA)exp(y)/exp(h);
exp(la)=BETA
exp(la(+1))
(ALPHAexp(y(+1))/exp(k)+1-DELTA);
exp(la)=BETA
exp(la(+1))(1+exp®);
exp(y) = exp© + exp(ii) + exp(g) ;
exp(k)=(1-DELTA)exp(k(-1))+exp(ii);
exp(y)=exp(a)
(exp(k(-1)))^ALPHA
(exp(h))^(1-ALPHA);
log(exp(a)/a_ss) = RHO_alog(exp(a(-1))/a_ss) + u_a;
log(exp(g)/g_ss) = RHO_g
log(exp(g(-1))/g_ss) + u_g;

end;

%----------------------------------------------------------------
% 4. Steady State
%----------------------------------------------------------------

steady_state_model;

// Computing the steady state and calibrated parameters
BETA=1/(1+r_ss);
y_to_k_ss=(r_ss+DELTA)/(ALPHA);
k_to_h_ss=y_to_k_ss^(1/(ALPHA-1));
k_ss=k_to_h_ssh_ss;
y_ss=y_to_k_ss
k_ss;
g_ss=g_to_y_ssy_ss;
ii_ss=DELTA
k_ss;
c_ss=y_ss-ii_ss-g_ss;
OMEGA=(1-ALPHA)y_ss/c_ss(1/h_ss-1);
la_ss=c_ss^(-GAMMA)(1-h_ss)^(OMEGA(1-GAMMA));

// Initial values for solver
a=log(a_ss);
g=log(g_ss);
y=log(y_ss);
h=log(h_ss);
k=log(k_ss);
c=log(c_ss);
ii=log(ii_ss);
r=log(r_ss);
la=log(la_ss);

end;

%----------------------------------------------------------------
% 4. Computation
%----------------------------------------------------------------

steady;
check;

shocks;
var u_a = SIGMA_a^2;
var u_g = SIGMA_g^2;
end;

stoch_simul(periods=0, irf = 50, order = 1);
save rbc_loglinear.mat;

and it runs smoothly

But when I incoporate the search frictions i have real problems. I have tried to solve the steady state but i cant seem to solve the system. The code so far is this:

close all;
warning off ;

%----------------------------------------------------------------
% 1. Defining variables
%----------------------------------------------------------------

// Endogenous variables (15)

var C N K I Y LAM S V M A G R Q P THETA;

varexo u_A u_G;

parameters beta alpha gamma sigma co a eta phi psi delta; //(10)

parameters rho_A sigma_A rho_G sigma_G;

parameters G_ss A_ss G_to_Y_ss R_ss N_ss Q_ss;

%----------------------------------------------------------------
% 2. Calibration
%----------------------------------------------------------------

alpha=0.33;
delta=0.023;
RHO_a=0.95;
SIGMA_a=0.01;
RHO_g=0.90;
SIGMA_g=0.01;
eta=1;
gamma=0.6;
co=0.005;
a=0.05;
psi=0.07;
phi=2;

// Targeted steady state values
A_ss=1;
G_to_Y_ss=0.1;
R_ss=0.04/4;
N_ss=0.95;
//Q_ss=0.75; //no tengo que targetear Q porque al targetear N ya targueteo M, debido a la funcion Cobb Douglas de M puedo despejar y que me quede V

%----------------------------------------------------------------
% 3. Model (14 equations)
%----------------------------------------------------------------

model;

exp(Y)=exp©+exp(I)+exp(G)+aexp(V)+coexp(S)^(eta)*(1-exp(N(-1))); //condicion de agregación ecuacion 1

exp(Y)=exp(A)*exp(K(-1))^(alpha)*exp(N(-1))^(1-alpha); //función de producción ecuacion 2

exp(K)=(1-delta)*exp(K(-1))+exp(I); //ley de movimiento del capital ecuacion 3

exp(N)=(1-psi)*exp(N(-1))+exp(M); //ley de movimiento del empleo ecuacion 4

exp(M)=exp(V)^(gamma)(exp(S)(1-exp(N(-1))))^(gamma); //funcion de matching ecuacion 5

exp©^(-sigma)=exp(LAM); //CPO con respecto al consumo ecuacion 6

exp(LAM)=betaexp(LAM(+1))(alpha*exp(Y(+1))/exp(K)+1-delta); //condicion respecto a la acumulación de capital ecuación 7

exp(LAM)=betaexp(LAM(+1))(1+exp®); //es lo mismo que la anterior solo que con R

exp(LAM)((-1)coetaexp(S)^(eta-1)(1-exp(N(-1))))+beta((-1)(exp(N)^(phi))gammaexp(M)/exp(S)+exp(LAM(+1))((1-alpha)(exp(Y(+1))/exp(N))gammaexp(M)/exp(S)+coexp(S(+1))^(eta)gamma(exp(M)/exp(S))))=0; //CPO con respecto a search ecuacion 8

exp(LAM)((-1)a)+beta(-(exp(N)^(phi))(1-gamma)exp(M)/exp(V)+exp(LAM(+1))((1-alpha)(exp(Y(+1))/exp(N))(1-gamma)exp(M)/exp(V)+coexp(S(+1))*(1-gamma)*exp(M)/exp(V)))=0; //cpo con respecto a las vacantes ecuacion 9

exp(Q)=exp(M)/exp(V); //probabilidad q ecuacion 12

exp§=exp(M)/(exp(S)*(1-exp(N(-1)))); //probabilidad p ecuacion 13

exp(THETA)=exp(V)/(1-exp(N(-1))); //tightness of labour market ecuacion 14

log(exp(A)/A_ss) = rho_A*log(exp(A(-1))/A_ss) + u_A; //proceso ar1 para la tecnologia ecuacion 10

log(exp(G)/G_ss) = rho_G*log(exp(G(-1))/G_ss) + u_G; //proceso ar1 para el gasto del gobierno ecuacion 11

end;

%----------------------------------------------------------------
% 4. Steady State
%----------------------------------------------------------------

steady_state_model;

beta=1/(1+R_ss);

Y_to_K_ss=(R_ss+delta)/(alpha);

K_to_N_ss=Y_to_K_ss^(1/(alpha-1));

K_ss=K_to_N_ss*N_ss;

Y_ss=Y_to_K_ss*K_ss;

G_ss=G_to_Y_ss*Y_ss;

I_ss=delta*K_ss;

C_ss=Y_ss-I_ss-G_ss;

LAM_ss=C_ss^(-sigma);

M_ss=N_ss*psi;

//M_ss=V_ss^(1-gamma)S_ss^(gamma)(1-N_ss)^(gamma);

//P_ss=M_ss/(S_ss*(1-N_ss));

//Q_ss=M_ss/V_ss;

//V_ss=M_ss/Q_ss;

S_ss=betaM_ssgamma*(co^(-1))((LAM_ss)^(-1))(N_ss^(phi)-LAM_ss*(Y_ss/N_ss)(1-alpha))(betaM_ss-eta(1-N_ss))^(-1);

V_ss=(N_sspsi((S_ss*(1-N_ss))^(-gamma)))^(1/(1-gamma));

Q_ss=M_ss/V_ss;

P_ss=M_ss/(S_ss*(1-N_ss));

THETA_ss=V_ss/(1-N_ss);

// Initial values for solver
A=log(A_ss);
G=log(G_ss);
Y=log(Y_ss);
N=log(N_ss);
K=log(K_ss);
C=log(C_ss);
I=log(I_ss);
R=log(R_ss);
LAM=log(LAM_ss);
V=log(V_ss);
S=log(S_ss);
Q=log(Q_ss);
P=log(P_ss);

end;

%----------------------------------------------------------------
% 4. Computation
%----------------------------------------------------------------

steady;
check;

shocks;
var u_A = SIGMA_A^2;
var u_G = SIGMA_G^2;
end;

stoch_simul(periods=0, irf = 50, order = 1);
save searchRBC.mat;

When I run it Dynare cant solve the steady state. Any suggestions will be appreciated. Does anyone know of an example of search frictions? I did not find one in the paper section of Dynare.
Thanks

the search and matching functions come from Merz (1995) journal of monetary economics!

There is a whole bunch of issues you need to fix. Most importantly, many parameters are not initialized, partly because their name does not match the one in the definition:

[quote]Warning: Some of the parameters have no value (beta, sigma, rho_A, sigma_A, rho_G, sigma_G, G_ss, Q_ss) when using steady. If these parameters are not
initialized in a steadystate file or a steady_state_model-block, Dynare may not be able to solve the model… [/quote]

Moreover, some variables do not have their steady state set

[quote]WARNING: in the ‘steady_state_model’ block, variable ‘M’ is not assigned a value
WARNING: in the ‘steady_state_model’ block, variable ‘THETA’ is not assigned a value[/quote]

Thank you!
I ll work on it and keep you updated

I ve solved many of the issues thanks to your help. I ve got to this. It still has some issues but I think I am closer to the solution

% Search RBC Model - log-linearized
%
% By El loco Camara

%----------------------------------------------------------------
% 0. Housekeeping (close all graphic windows)
%----------------------------------------------------------------

close all;
warning off ;

%----------------------------------------------------------------
% 1. Defining variables
%----------------------------------------------------------------

// Endogenous variables (15)

var C N K I Y LAM S V M A G R Q P THETA;

varexo u_A u_G;

parameters beta alpha gamma sigma co a eta phi psi delta; //(10)

parameters rho_A sigma_A rho_G sigma_G;

parameters G_ss A_ss G_to_Y_ss R_ss N_ss Y_to_K_ss K_to_N_ss S_ss;

%----------------------------------------------------------------
% 2. Calibration
%----------------------------------------------------------------

alpha=0.33;
delta=0.023;
rho_A=0.95;
sigma_A=0.01;
rho_G=0.90;
sigma_G=0.01;
eta=1;
gamma=0.6;
co=0.005;
a=0.05;
psi=0.07;
phi=3;
sigma=1;

// Targeted steady state values
A_ss=1;
G_to_Y_ss=0.1;
R_ss=0.04/4;
N_ss=0.95;
//S_ss=1.15;

%----------------------------------------------------------------
% 3. Model (14 equations)
%----------------------------------------------------------------

model;

exp(Y)=exp©+exp(I)+exp(G)+aexp(V)+coexp(S)^(eta)*(1-exp(N(-1))); //condicion de agregación ecuacion 1

exp(Y)=exp(A)*exp(K(-1))^(alpha)*exp(N(-1))^(1-alpha); //función de producción ecuacion 2

exp(K)=(1-delta)*exp(K(-1))+exp(I); //ley de movimiento del capital ecuacion 3

exp(N)=(1-psi)*exp(N(-1))+exp(M); //ley de movimiento del empleo ecuacion 4

exp(M)=exp(V)^(1-gamma)(exp(S)(1-exp(N(-1))))^(gamma); //funcion de matching ecuacion 5

exp©^(-sigma)=exp(LAM); //CPO con respecto al consumo ecuacion 6

exp(LAM)=betaexp(LAM(+1))(alpha*exp(Y(+1))/exp(K)+1-delta); //condicion respecto a la acumulación de capital ecuación 7

exp(LAM)=betaexp(LAM(+1))(1+exp®); //es lo mismo que la anterior solo que con R

exp(LAM)a=beta((-1)exp(N)^(phi)(1-gamma)exp(M)/(exp(V))+exp(LAM(+1))((1-gamma)(exp(M)/exp(V))((1-alpha)(exp(Y(+1))/(exp(N)))+coexp(S(+1))^(eta))));

exp(LAM)coetaexp(S)^(eta-1)(1-exp(N(-1)))=beta*((-1)exp(N)^(phi)gammaexp(M)/(exp(S))+exp(LAM(+1))(gammaexp(M)/(exp(S))((1-alpha)(exp(Y(+1))/(exp(N)))+coexp(S(+1))^(eta))));

exp(Q)=exp(M)/exp(V); //probabilidad q ecuacion 12

exp§=exp(M)/(exp(S)*(1-exp(N(-1)))); //probabilidad p ecuacion 13

exp(THETA)=exp(V)/(1-exp(N(-1))); //tightness of labour market ecuacion 14

log(exp(A)/A_ss) = rho_A*log(exp(A(-1))/A_ss) + u_A; //proceso ar1 para la tecnologia ecuacion 10

log(exp(G)/G_ss) = rho_G*log(exp(G(-1))/G_ss) + u_G; //proceso ar1 para el gasto del gobierno ecuacion 11

end;

%----------------------------------------------------------------
% 4. Steady State
%----------------------------------------------------------------

steady_state_model;

beta=1/(1+R_ss);
Y_to_K_ss=(R_ss+delta)/(alpha);
K_to_N_ss=Y_to_K_ss^(1/(alpha-1));
K_ss=K_to_N_ssN_ss;
Y_ss=Y_to_K_ss
K_ss;
G_ss=G_to_Y_ssY_ss;
I_ss=delta
K_ss;
C_ss=Y_ss-I_ss-G_ss;
LAM_ss=C_ss^(-sigma);
M_ss=N_ss*psi;

S_ss=(betaM_ssgamma*(co^(-1))((LAM_ss)^(-1))(-N_ss^(phi)+LAM_ss*(Y_ss/N_ss)(1-alpha))(eta*(1-N_ss)-betagammaM_ss)^(-1))^(1/eta);

V_ss=(M_ss/((S_ss*(1-N_ss))^(gamma)))^(1/(1-gamma));
Q_ss=M_ss/V_ss;
P_ss=M_ss/(S_ss*(1-N_ss));
THETA_ss=V_ss/(1-N_ss);

// Initial values for solver
A=log(A_ss);
G=log(G_ss);
Y=log(Y_ss);
N=log(N_ss);
K=log(K_ss);
C=log(C_ss);
I=log(I_ss);
R=log(R_ss);
LAM=log(LAM_ss);
M=log(M_ss);
THETA=log(THETA_ss);
V=log(V_ss);
S=log(S_ss);
Q=log(Q_ss);
P=log(P_ss);

end;

%----------------------------------------------------------------
% 4. Computation
%----------------------------------------------------------------

steady;
check;

shocks;
var u_A = sigma_A^2;
var u_G = sigma_G^2;
end;

stoch_simul(periods=0, irf = 50, order = 1);
save searchRBC.mat;

There are two equations with big residuals. You need to check them. Given the size of the residual of equation 9, there is most probably something wrong with the exp/log substitution.

I think I am giving up!
The residuals from equation 9 are really sensitive to changes in the value of parameters. I think the problem is that the value of some parameter must be determined in the steady state block and I am fixing it.

I don’t understand your point. There must be as many equations as degrees of freedom. If you fix a variable ex ante (say labor in steady state is 0.2), then you must have a parameter that is endogenously determined in steady state (the labor disutility parameter in my example).
In this case, there is one and only one steady state that you must provide.

Thats the problem I am finding
I have fixed the hours of labour in steady state, but I also simultaneously fixed the disutility parameter. If I choose the correct calibration for that parameter the model runs fine. I have to choose one to be determined endogenously
Thanks A LOT!
I ll keep you updated