Model.pdf (1.8 MB)
RBC_credit_det-3.mod (3.9 KB)

Hi @jpfeifer, I having problem computing for the steady states. This model includes cash in advance and human capital accumulation. It would be great if you could help me. Thanks

dynare RBC_credit_det.mod
Starting Dynare (version 6.0).
Calling Dynare with arguments: none
Starting preprocessing of the model file …
Found 18 equation(s).
Evaluating expressions…
Computing static model derivatives (order 1).
Normalizing the static model…
Normalization failed with cutoff, trying symbolic normalization…
Finding the optimal block decomposition of the static model…
8 block(s) found:
7 recursive block(s) and 1 simultaneous block(s).
the largest simultaneous block has 11 equation(s)
and 11 feedback variable(s).
Computing dynamic model derivatives (order 1).
Normalizing the dynamic model…
Finding the optimal block decomposition of the dynamic model…
6 block(s) found:
5 recursive block(s) and 1 simultaneous block(s).
the largest simultaneous block has 11 equation(s)
and 10 feedback variable(s).
Preprocessing completed.
Preprocessing time: 0h00m01s.

Residuals of the static equations:
Equation number 1: aggregate money : -0.500000
Equation number 2: money balance : -0.500000
Equation number 3: stationary price : -2.366890
Equation number 4: stationary money : 0.000000
Equation number 5: intratemporal optimality : 0.000000
Equation number 6: intertemporal optimality 1 (Euler) : 0.000000
Equation number 7: intertemporal optimality 2 (Euler) : 0.000000
Equation number 8: intertemporal optimality 3 (Euler) : 0.000000
Equation number 9: human capital accumulation : 0.000000
Equation number 10: physical capital accumulation : 0.000000
Equation number 11: cash in advance constraint : 0.635302
Equation number 12: time endowment : 0.000000
Equation number 13: market clearing : 1.251228
Equation number 14: production function : 0.000000
Equation number 15: labor demand : 0.000000
Equation number 16: capital demand : -5.584430
Equation number 17: total factor productivity : NaN
Equation number 18: growth rate of money : 0.202733

Error using print_info

Error in check (line 48)
print_info(info, 0, options_);

Error in RBC_credit_det.driver (line 576)
oo_.dr.eigval = check(M_,options_,oo_);

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

RBC_credit_det (1).mod (3.3 KB)

``````function [ys,params,check] = RBC_credit_det_steadystate(ys,exo,M_,options_)
% Inputs:
%   - ys        [vector] vector of initial values for the steady state of the endogenous variables
%   - exo       [vector] vector of values for the exogenous variables
%   - M_        [structure] Dynare model structure
%   - options   [structure] Dynare options structure
%
% Output:
%   - ys        [vector] vector of steady state values for the the endogenous variables
%   - params    [vector] vector of parameter values
%   - check     [scalar] 0 if steady state computation worked and to
%                        1 of not (allows to impose restrictions on parameters)

%% Step 0: initialize indicator and set options for numerical solver
check = 0;
options = optimset('Display','Final','TolX',1e-10,'TolFun',1e-10);

%% Step 1: read out parameters to access them with their name
for ii = 1:M_.param_nbr
eval([ M_.param_names{ii} ' = M_.params(' int2str(ii) ');']);
end

%% Step 2: Check parameter restrictions
%if etaC*etaL<1 % parameter violates restriction (here it is artifical)
%    check=1; %set failure indicator
%    return;  %return without updating steady states
%end

%% Step 3: Enter model equations here

% What does setting to 1 would mean?
%z = epsz/(1-RHOZ);
z = 1;

A = 1;

p = 1;

m = 1;

% use different values
g = 1;

x = 1;

if z <= 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% r = 0.035
r = 1/BETA + DELTAK -1;

if r <= 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% K_NH 740.35 re-check the -values
K_NH = (r/(ALPHA*exp(z)))^(1/ALPHA-1);

if K_NH <= 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% Y_NH = 70.69
Y_NH = exp(z)*K_NH^ALPHA;

if Y_NH <= 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% IV_NH = 1.767
IV_NH = DELTAK*K_NH;

if IV_NH <= 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% w = 45.95
w = (1-ALPHA)*exp(z)*K_NH^ALPHA;

if w <= 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% e = 0.0005 (when omega = 10, e = 0.069)
e = (w/(OMEGA*PHIE))^(1/(PHIE - 1));

if e <= 0.05
check = 1; % set failure indicator
return;    % return without updating steady states
end

% n = 0.026 use fsolve here n0 = 0.35
n = (1/w)*(1/BETA - (1-DELTAH) - OMEGA*e^(PHIE));

if n <= 0.1
check = 1; % set failure indicator
return;    % return without updating steady states
end

% might need to use fsolve asthe value is negative
h = x/(DELTAH - OMEGA*e^(PHIE));

%X_NH = 1/(n*(DELTAH - OMEGA*e^(PHIE)));

if h <= 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

X_NH = x/(n*h);

C_NH = Y_NH - X_NH - IV_NH;

if C_NH <= 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

l = 1 - n - e;

if l <= 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

c = ((BETA*w*h*l^(GAMMA))/g*A)^(1/SIGMA);

if c/n*h == C_NH
check = 1; % set failure indicator
return;    % return without updating steady states
end

p_hat = 1/c;

M = p/p_hat;

m_hat = m/M;

y  = Y_NH*n*h;
iv = IV_NH*n*h;
k  = K_NH*n*h;

% The labor level
%if etaC == 1 && etaL == 1
%    % Closed-form solution for labor
%    L = gam/pssi*C_L^(-1)*W/(1+gam/pssi*C_L^(-1)*W);
%else
%     No closed-form solution use a fixed-point algorithm
%    L0 = 1/3;
%    [L,~,exitflag] = fsolve(@(L) pssi*(1-L)^(-etaL)*L^etaC - gam*C_L^(-etaC)*W, L0,options);
%    if exitflag <= 0
%        check = 1; % set failure indicator
%        return     % return without updating steady states
%    end
%end

%% Step 4: Update parameters and variables
params=NaN(M_.param_nbr,1);
for iter = 1:M_.param_nbr %update parameters set in the file
eval([ 'params(' num2str(iter) ') = ' M_.param_names{iter} ';' ])
end

for ii = 1:M_.orig_endo_nbr %auxiliary variables are set automatically
eval(['ys(' int2str(ii) ') = ' M_.endo_names{ii} ';']);
end
``````

Error: Output argument “params” (and possibly others) not assigned a value in the execution with “RBC_credit_det_steadystate” function.

Error in RBC_credit_det.driver (line 579)

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

As proper syntax would be in:

However, in the file you get n\approx -4 and the file aborts.

``````function [ys,params,check] = RBC_credit_det_steadystate(ys,exo,M_,options_)
% Inputs:
%   - ys        [vector] vector of initial values for the steady state of the endogenous variables
%   - exo       [vector] vector of values for the exogenous variables
%   - M_        [structure] Dynare model structure
%   - options   [structure] Dynare options structure
%   - options   [structure] Dynare options structure
%
% Output:
%   - ys        [vector] vector of steady state values for the the endogenous variables
%   - params    [vector] vector of parameter values
%   - check     [scalar] 0 if steady state computation worked and to
%                        1 of not (allows to impose restrictions on parameters)

%% Step 0: initialize indicator and set options for numerical solver
check = 0;
options = optimset();

%% Step 1: read out parameters to access them with their name
for ii = 1:M_.param_nbr
eval([ M_.param_names{ii} ' = M_.params(' int2str(ii) ');']);
end

params = M_.params;
%% Step 2: Check parameter restrictions
%if etaC*etaL<1 % parameter violates restriction (here it is artifical)
%    check=1; %set failure indicator
%    return;  %return without updating steady states
%end

%% Step 3: Enter model equations here

% What does setting to 1 would mean?
%z = epsz/(1-RHOZ);
z = 1;

OMEGA =1;

A = 1;

p = 1;

m = 1;

% use different values
g = 1;

x = 1;

%if z <= 0
%    check = 1; % set failure indicator
%    return;    % return without updating steady states
%end

% r = 0.035
r = 1/BETA + DELTAK -1;

if r < 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% K_NH = 0.013 re-check the -values
K_NH = (r/(ALPHA*z))^(1/ALPHA-1);

if K_NH < 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% Y_NH = 0.22
Y_NH = z*K_NH^ALPHA;

if Y_NH < 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% IV_NH = 0.0003
IV_NH = DELTAK*K_NH;

if IV_NH < 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% w = 0.145
w = (1-ALPHA)*z*K_NH^ALPHA;

if w < 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% e = 0.2275(when omega = 10, e = 0.069)
e = (w/(OMEGA*PHIE))^(1/(PHIE - 1));

if e < 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% might need to use fsolve as the value is negative
h = x/(DELTAH - OMEGA*e^PHIE);
%h=0.5;
%X_NH = 1/(n*(DELTAH - OMEGA*e^(PHIE)));

%if h < 0
%    check = 1; % set failure indicator
%    return;    % return without updating steady states
%end

% n = -6.5 use fsolve here n0 = 0.35
n = (1/w)*(1/BETA - (1 - DELTAH) - OMEGA*e^PHIE);
%n=1/3;

%n0 = 1/3;

%[n,~,exitflag] = fsolve(@(n) (BETA*C_NH^(-SIGMA))/g - (A*(1-n-e)^(-GAMMA)/(w*h))*(h*n0)^(SIGMA), n0, options);
%    if exitflag <= 0
%        check = 1; % set failure indicator
%        return     % return without updating steady states
%   end

%if n <= 0
%    check = 1; % set failure indicator
%    return;    % return without updating steady states
%end

% X_NH = 0.147
X_NH = x/(n*h);

% C_NH = 0.07
C_NH = Y_NH - X_NH - IV_NH;

if C_NH < 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

% c = 0.51

% l = 7.18
l = 1 - n - e;

if l < 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

y  = Y_NH*n*h;
iv = IV_NH*n*h;
k  = K_NH*n*h;
c = C_NH*n*h;

if c < 0
check = 1; % set failure indicator
return;    % return without updating steady states
end

p_hat = 1/c;

M = p/p_hat;

m_hat = m/M;

%% Step 4: Update parameters and variables
params=NaN(M_.param_nbr,1);
for iter = 1:M_.param_nbr %update parameters set in the file
eval([ 'params(' num2str(iter) ') = ' M_.param_names{iter} ';' ])
end

``````
``````Residuals of the static equations:
Equation number  1: aggregate money                    :       0.000000
Equation number  2: money balance                      :       0.000000
Equation number  3: stationary price                   :       0.000000
Equation number  4: stationary money                   :       0.000000
Equation number  5: intratemporal optimality           :       0.000000
Equation number  6: intertemporal optimality 1 (Euler) :       0.000000
Equation number  7: intertemporal optimality 2 (Euler) :       1.458791
Equation number  8: intertemporal optimality 3 (Euler) :       0.000000
Equation number  9: human capital accumulation         :       0.000000
Equation number 10: physical capital accumulation      :       0.000000
Equation number 11: cash in advance constraint         :      -1.404771
Equation number 12: time endowment                     :       0.000000
Equation number 13: market clearing                    :       0.000000
Equation number 14: production function                :       0.000000
Equation number 15: labor demand                       :       0.000000
Equation number 16: capital demand                     :      -5.584430
Equation number 17: total factor productivity          :       0.000000
Equation number 18: growth rate of money               :       0.000000
``````

Hi @jpfeifer, I’m getting negative values for the n (labor supply) and h (human capital) in the steady state. The problem is coming from e^(PHIE). I tried to use fsolve as well but still not working. The mod file is same as posted before. I would be highly obliged if you could help me. Thanks again!

You need to approach this systematically. You are the only one knowing the model. I don’t even know that it means that