# RBC: Steady State error

**URL:** <https://forum.dynare.org/t/rbc-steady-state-error/25335>\
**Category:** Steady state\
**Created:** [10 March 2024 17:49 UTC](https://forum.dynare.org/t/rbc-steady-state-error/25335 "2024-03-10T17:49:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ADITYA](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/df705f/32.png) [@ADITYA](https://forum.dynare.org/u/ADITYA)\
**Post date:** [10 March 2024 17:49 UTC](https://forum.dynare.org/t/rbc-steady-state-error/25335/1 "2024-03-10T17:49:17Z")

</div>

[Model.pdf](https://forum.dynare.org/uploads/short-url/uPGEDpyQGaJjY00jAaZdxq1BdmZ.pdf) (1.8 MB)  
[RBC\_credit\_det-3.mod](https://forum.dynare.org/uploads/short-url/xyNMi8Gw9zFLHbtkaNBT8KnXMz3.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  
The steadystate file did not compute the steady state

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’]);

---

<div class="post-metadata">

**Author:** ![ADITYA](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/df705f/32.png) [@ADITYA](https://forum.dynare.org/u/ADITYA)\
**Post date:** [10 March 2024 22:50 UTC](https://forum.dynare.org/t/rbc-steady-state-error/25335/2 "2024-03-10T22:50:39Z")

</div>

[RBC\_credit\_det (1).mod](https://forum.dynare.org/uploads/short-url/gObBbuomcgZ7c4CXisDRwausVV7.mod) (3.3 KB)

Steady State file:

```auto
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 evaluate\_steady\_state\_file (line 47)  
> [ys,params1,check] = h\_steadystate(ys\_init, exo\_ss,M\_,options\_);
> 
> Error in evaluate\_steady\_state (line 275)  
> [ys,params,info] = evaluate\_steady\_state\_file(ys\_init,exo\_ss,M\_, options\_,steadystate\_check\_flag);
> 
> Error in steady (line 112)  
> [oo\_.steady\_state,M\_.params,info] = evaluate\_steady\_state(oo\_.steady\_state,[oo\_.exo\_steady\_state; oo\_.exo\_det\_steady\_state],M\_,options\_,~options\_.steadystate.nocheck);
> 
> Error in RBC\_credit\_det.driver (line 579)  
> steady;
> 
> Error in dynare (line 310)  
> evalin(‘base’,[fname ‘.driver’]);

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [11 March 2024 08:22 UTC](https://forum.dynare.org/t/rbc-steady-state-error/25335/3 "2024-03-11T08:22:25Z")

</div>

As proper syntax would be in:  
[RBC\_credit\_det\_steadystate.m](https://forum.dynare.org/uploads/short-url/maZIG9rjVEbeq19UsMXoD9xZ3Sm.m) (4.3 KB)

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

---

<div class="post-metadata">

**Author:** ![ADITYA](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/df705f/32.png) [@ADITYA](https://forum.dynare.org/u/ADITYA)\
**Post date:** [14 March 2024 19:59 UTC](https://forum.dynare.org/t/rbc-steady-state-error/25335/4 "2024-03-14T19:59:32Z")

</div>

```auto
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

```

```auto
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

```

---

<div class="post-metadata">

**Author:** ![ADITYA](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/df705f/32.png) [@ADITYA](https://forum.dynare.org/u/ADITYA)\
**Post date:** [14 March 2024 20:04 UTC](https://forum.dynare.org/t/rbc-steady-state-error/25335/5 "2024-03-14T20:04:10Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [15 March 2024 11:53 UTC](https://forum.dynare.org/t/rbc-steady-state-error/25335/6 "2024-03-15T11:53:38Z")

</div>

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

> [@ADITYA](#):
>
> problem is coming from e^(PHIE).
