External Matlab Steady State solver

Hello everyone!

I’m a 4th year undergraduate student from Barcelona. I’m currenlty writing my thesis on simulating calibrated basic neoclassical and new keynesian models on Spain and UK by using Dynare. For now, I’ve adopted Jesus Fernandez-Villaverde’s RBC model (economics.sas.upenn.edu/~jesusfv/teaching.html) and computed the Steady State per hand. I want to write a Steady State solver Matlab file (.m) so to link it to my Dynare Script.

However, I’m very new to Dynare as well as to Matlab (I’m using both for the first time since I started with my Thesis this semester). Hence, I had some problems on writing a Matlab function for my Steady State. Even though I tried to understand some of the steady state .m files in the Dynare examples folder (i.e.NK_baseline) and tried to adapt it for my particular case, I don’t understand many of the commands that are displayed.

Therefore, I would really appreciate any kind of help as for instance giving me some advise on how to write successfully a Steady State function on Matlab, or having a look at my attached .mod files for my Neoclassical model and explain to me how may I create a .m file for my Steady State equations.

What is more, looking for some other postings I found a Steady State .m file for an RBC model for the Log_linearized case provided by the user “Sesser” (Steady State File). Given I did not understand much of the content neither I would also appreciate some help on this (maybe it is more appropiate to adapt my Steady State solver of my model on this .m file)

Thanks in advance for any useful help.
rbc_steadystate.m (1.66 KB)
SS_solver_Neoclassical_Model.mod (290 Bytes)
Neoclassical_Model_UK.mod (881 Bytes)

The steady state file should be:

[code]function [ys,check] = Neoclassical_Model_UK_steadystate(ys,exo)
% function [ys,check] = NK_baseline_steadystate(ys,exo)
% computes the steady state for the NK_baseline.mod and uses a numerical
% solver to do so
% Inputs:
% - ys [vector] vector of initial values for the steady state of
% the endogenous variables
% - exo [vector] vector of values for the exogenous variables
%
% Output:
% - ys [vector] vector of steady state values fpr the the endogenous variables
% - check [scalar] set to 0 if steady state computation worked and to
% 1 of not (allows to impos restriction on parameters)

global M_

% read out parameters to access them with their name
NumberOfParameters = M_.param_nbr;
for ii = 1:NumberOfParameters
paramname = deblank(M_.param_names(ii,:));
eval( paramname ’ = M_.params(’ int2str(ii) ‘);’]);
end
% initialize indicator
check = 0;

%% Enter model equations here

l = (1 - alppha)(1/betta - (1 - delta))/(psii(1/betta - (1 - delta) - alpphadelta) + (1 - alppha)(1/betta - (1 - delta)));
k = ((alppha/(1/betta - (1 - delta)))^(1/(1 - alppha)))l;
c = ((1/betta - (1 - delta) - alppha
delta)/alppha)k;
invest = delta
k;
y = c+invest;
y_l = y/l;
z = 0;
e = 0;

%% end own model equations

for iter = 1:length(M_.params) %update parameters set in the file
eval( ‘M_.params(’ num2str(iter) ') = ’ M_.param_names(iter,:slight_smile: ‘;’ ])
end

NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
varname = deblank(M_.endo_names(ii,:));
eval(‘ys(’ int2str(ii) ') = ’ varname ‘;’]);
end
[/code]
You need to use the header and footer provided in NK_baseline_steadystate.m and then add equations defining the steady state for every single variable in your model. Because Matlab has trouble with parameters that have the same name as internal functions, I needed to rename the parameter names and i. The mod-file would be

[code]// 1) Definition of variables

var y c k invest l y_l z;
varexo e;
parameters alppha betta delta psii rho sigma;

// 2) Calibration

alppha = 0.371;
betta = 0.973;
delta = 0.026;
psii = 3.11;
rho = 0.951;
sigma = 0.0043;

// 3) Model

model;
(1/c) = betta*(1/c(+1))(1+alppha(k^(alppha-1))(exp(z(+1))l(+1))^(1-alppha)-delta);
psii
c/(1-l) = (1-alppha)
(k(-1)^alppha)(exp(z)^(1-alppha))(l^(-alppha));
c+invest = y;
y = (k(-1)^alppha)*(exp(z)*l)^(1-alppha);
invest = k-(1-delta)k(-1);
y_l = y/l;
z = rho
z(-1)+e;
end;

// 4) Computation

shocks;
var e = sigma^2;
end;

steady;
check;

stoch_simul;[/code]
Note that the naming of the steadystate-file must be consistent with the name of the mod-file, i.e. mod_file_name_steadystate.m

1 Like

Dear Dr. Pfeifer,

Thanks a lot for your help! I really appreciated your advise and everything worked perfectly well!
Auf diesem Wege möchte ich mich nochmal ganz herzlich bei Ihnen “auf Deutsch” für Ihre Unterstützung bedanken.

Best wishes,

Erik