How to get the Dynare code for this paper

I am writing my thesis on the topic of intangible assets and found a very good paper to base off my own study. The original study, “The importance of intangible capital for the transmission of financial shocks” by Jose Ignacio Lopez and Virginia Olivella, uses Dynare for solving their model. I tried figuring out a couple of things using ChatGPT but I’m stuck after a point. I tried emailing the authors, requesting them for the code. What more can I do right now. I have written below the error at which I’m stuck right now. Hoping to get some help. Thanks!

“Normalization failed with cutoff, trying symbolic normalization…
Could not normalize the dynamic model. Variable KI is not in the maximum cardinality matching.”

“There are 3 eigenvalue(s) larger than 1 in modulus for 9 forward-looking variable(s)
The rank condition ISN’T verified!”

Without the code it is impossible to tell. That being said, the error suggests that you are doing many timing errors.

% model1.mod
% Dynare file implementing a model with two types of capital, financial frictions,
% and search frictions in the labor market.
%
% Calibration:
%   beta      = 0.997
%   gamma     = 0.980
%   chi_bar   = 0.72
%   delta_T   = 0.007
%   delta_I   = 0.017
%   alphaKT   = 0.25
%   alphaKI   = 0.15
%   phi       = 0.50
%   x         = 0.034
%   omega_bar = 0.92
%   phi_d     = 0.921
%   q         = 0.355
%   rho_z     = 0.9516, sigma_z   = 0.0033
%   rho_chi   = 0.9950, sigma_chi = 0.0044

var c KT KI Y n v theta B mu W r MPL rT rI z chi;
varexo eps_z eps_chi;
parameters beta gamma chi_bar delta_T delta_I alphaKT alphaKI phi x omega_bar phi_d q rho_z sigma_z rho_chi sigma_chi;

% Calibration values
beta      = 0.997;
gamma     = 0.980;
chi_bar   = 0.72;
delta_T   = 0.007;
delta_I   = 0.017;
alphaKT   = 0.25;
alphaKI   = 0.15;
phi       = 0.50;
x         = 0.034;
omega_bar = 0.92;
phi_d     = 0.921;
q         = 0.355;
rho_z     = 0.9516;
sigma_z   = 0.0033;
rho_chi   = 0.9950;
sigma_chi = 0.0044;

model;
  % Production function: Y = exp(z) * KT^(alphaKT) * KI^(alphaKI) * n^(1 - alphaKT - alphaKI)
  Y = exp(z) * (KT^alphaKT) * (KI^alphaKI) * (n^(1 - alphaKT - alphaKI));
  
  % Entrepreneur's budget constraint:
  c + (1 + r) * B + (KT(+1) - (1 - delta_T) * KT) + (KI(+1) - (1 - delta_I) * KI) + W * n + q * v = Y + B(+1);
  
  % Borrowing constraint (always binding):
  B(+1) * (1 + r(+1)) = chi * KT(+1);
  
  % Law of motion for employment:
  n(+1) = (1 - x) * n + omega_bar * theta^(-phi) * v;
  
  % Definition of market tightness:
  theta = v/(1 - n);
  
  % Euler equation for tangible capital:
  1 - mu * chi = gamma * (c/(c(+1))) * ((alphaKT * Y(+1)/KT(+1)) + (1 - delta_T));
  
  % Euler equation for intangible capital:
  1 = gamma * (c/(c(+1))) * ((alphaKI * Y(+1)/KI(+1)) + (1 - delta_I));
  
  % Euler equation for debt:
  mu = 1/(1 + r(+1)) - gamma * (c/(c(+1)));
  
  % Recruiting (vacancy) Euler equation:
  q/(omega_bar*theta^(-phi)) = gamma * (c/(c(+1))) * (((1 - alphaKT - alphaKI) * Y(+1)/n(+1)) + q * (1 - x)/(omega_bar * theta(+1)^(-phi)) - W(+1));
  
  % Wage determination (Nash bargaining):
  W = phi * ((1 - alphaKT - alphaKI) * Y/n) + (q * theta * beta/(1 - x)) + (gamma/(omega_bar * theta^(-phi) * q)) * (1 - beta/gamma) + (1 - phi) * phi_d * c;
  
  % Household Euler equation:
  1 = beta * (c/(c(+1))) * (1 + r(+1));
  
  % AR(1) processes for shocks:
  z = rho_z * z(-1) + eps_z;
  chi = rho_chi * chi(-1) + eps_chi;
  
  % Definitions of auxiliary variables:
  rT = alphaKT * Y/KT;
  rI = alphaKI * Y/KI;
  MPL = (1 - alphaKT - alphaKI)*Y/n;
end;

initval;
  c       = 1;
  KT      = 10;
  KI      = 10;
  n       = 0.95;
  z       = 0;
  chi     = chi_bar;
  Y       = exp(0) * (KT^alphaKT) * (KI^alphaKI) * (n^(1 - alphaKT - alphaKI));
  theta   = 7;
  v       = theta*(1 - n);
  r       = 0.003;
  B       = (chi_bar*KT)/(1 + r);
  mu      = 0.01;
  W       = 1;
  MPL     = (1 - alphaKT - alphaKI)*Y/n;
  rT      = alphaKT*Y/KT;
  rI      = alphaKI*Y/KI;
  eps_z   = 0;
  eps_chi = 0;
end;

steady;
check;

shocks;
  var eps_z = sigma_z^2;
  var eps_chi = sigma_chi^2;
end;

stoch_simul(order=1, noprint, drop=12);

This is the code that I’m using

Looking at it, pretty much all your state variables have the wrong timing. It must be something like

predetermined_variables KT KI B n;

There may be more.

Ok, I understand.

Luckily, I was able to get the code but I’m encountering this error as of this moment:

Error in Matlab_Code_Lopez_Olivella_2018_Intangible (line 670)
Sim_FF_Search_etaz_irf=[y_etaz,k_etaz,n_etaz,U_etaz,v_etaz, theta_etaz,mpl_etaz, kikt_etaz,b_etaz];
^^^^^^

Code:

Matlab_Code_Lopez_Olivella_2018_Intangible.m (39.8 KB)

You did neither provide the full error message nor all files required to run the code.

I’m sorry, I’ll try attaching all of the files.

This is the link that i used for downloading all the files to my mac. I can’t seem to upload the files in a proper format in the forum.

I cannot reproduce the error. I followed the instruction to download Dynare 4.4.3 and everything runs as expected.

Can you please help me understand how one is supposed to run the code properly. I keep encountering an error but since this is the original code, I assume that shouldn’t happen.

Unrecognized function or variable ‘y_etaz’.

Error in Matlab_Code_Lopez_Olivella_2018_Intangible (line 670)
Sim_FF_Search_etaz_irf=[y_etaz,k_etaz,n_etaz,U_etaz,v_etaz, theta_etaz,mpl_etaz, kikt_etaz,b_etaz];

This is the error that I keep encountering.

Which Dynare version are you using?

I’m using the dynare version 6.2 for MacOS currently.

That explains it. The files were written for Dynare 4.4.3. If you want to port them, you may have to add the send_irfs_to_workspace command before the line in question

Mate would it be possible for you to help me understand how I need to integrate this into my overall code. Is it just a one line command that I need to write or is it something more than that?

Try putting

in line 669 of Matlab_Code_Lopez_Olivella_2018_Intangible.m.

Thanks!

Error using dynare
DYNARE: preprocessing failed

Error in Matlab_Code_Lopez_Olivella_2018_Intangible (line 314)
dynare Benchmark_2018.mod noclearall

174 error(‘DYNARE: preprocessing failed’)

I executed as you said, but still the following error appears. is there anything else that I might need to change?

That is not the full error message. Use
Matlab_Code_Lopez_Olivella_2018_Intangible.m (40.0 KB)
Unfortunately, you still need to modify the calls to dyntable or comment them out.

Alternatively, use Dynare 4.4.3.

I have just executed the file that you provided me. This is what’s coming up at the moment. Would you have any suggestions as to how I can tackle this?

(I changed the name of the code file you gave me to - jpfeifer)

Dot indexing is not supported for variables of this type.

Error in dyntable (line 35)
if options_.noprint

Error in Benchmark_2018_chi.driver (line 1030)
dyntable(‘Relative standard deviations in %’,strvcat(‘VARIABLE’,‘REL. S.D.’),M_.endo_names(1:size(oo_.var,1),:),statistic1(1,1),10,8,4);

Error in dynare (line 308)
evalin(‘base’,[fname ‘.driver’]);

Error in jpfeifer (line 696)
dynare Benchmark_2018_chi.mod

Thanks a lot again!!

Try the attached:
Lopez_Olivella_2018_Dynare_6.zip (148.5 KB)