residuals of static equations NaN

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

residuals of static equations NaN

Postby miti » Wed May 18, 2016 10:46 am

Hi there,

I am trying to run this model in dynare. I have a separate steady state file to compute the steady state, but every time I try to run it it gives the following error message. I have attched the dynare and the steady state file. please let me know if you can say what the problem might be.
Residuals of the static equations:

Equation number 1 : NaN
Equation number 2 : NaN
Equation number 3 : NaN
Equation number 4 : NaN
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : NaN
Equation number 12 : NaN
Equation number 13 : NaN
Equation number 14 : NaN
Equation number 15 : 0
Equation number 16 : 0
Equation number 17 : 0
Equation number 18 : 0
Equation number 19 : NaN
Equation number 20 : NaN
Equation number 21 : NaN
Equation number 22 : NaN
Equation number 23 : NaN
Equation number 24 : NaN
Equation number 25 : NaN
Equation number 26 : NaN
Equation number 27 : NaN
Equation number 28 : -1


Error using print_info (line 72)
The steadystate file did not compute the steady state
Attachments
try4_steadystate.m
(2.25 KiB) Downloaded 102 times
try4.mod
(2.22 KiB) Downloaded 94 times
miti
 
Posts: 1
Joined: Wed May 18, 2016 10:38 am

Re: residuals of static equations NaN

Postby jpfeifer » Wed May 18, 2016 6:24 pm

Your steady state file is not correct. You cannot simply paste a second function into the middle of a different function.
Please use an anonymous function of the form
Code: Select all
function [ys,check] = try4_steadystate(ys,exo)
% function [ys,check] = try4_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

options=optimset(); % set options for numerical solver

% the steady state computation follows FV (2006), section 4.1
S=S_bar;
P_f=P/S;
I=1/bet;
I_f=I;

x0=[1;1]
[x,fval] = fsolve(@(x)[x(1)^(1-theta)*tau^(theta-1)*(k/(k-theta+1))^2+(x(1)^(-k)*(k/(k-theta+1))^(k/(theta-1))*((theta-1)/(k-theta+1))+(bet-bet*delta-1)*fE/fX);
     x(2)-((S/P)^(theta-1)*((theta*k*fX*I)/(k-theta+1)-fE*((1-bet)/bet)/((tau*zd/x(1))^(theta-1)+(1/x(1))^k*(k/(k-theta+1))^(k/(theta-1))))^(1/(1-theta)))],x0,options);
 zx=x(1);
 PX=x(2);

ND=((S*PX/P)^(theta-1))/((tau*zd/zx)^(theta-1)+(1/zx)^k*(k/(k-theta+1))^(k/(theta-1)));
PD=S*zx*PX/(tau*zd);
W=S*PX*(theta-1)*zx/(theta*tau);
C=W*(L+ND*fE*(1-bet)/bet)/P;
NE=delta*ND;
NX=ND*(zx)^(-k)*(k/(k-theta+1))^(k/(theta-1));
dd=(PD/P)^(1-theta)*C*P/theta;
dx=(S*PX/P)^(1-theta)*C*P/theta-W*fX;
v=W*fE;
d=dd+(NX/ND)*dx;
zx_f=zx;
PX_f=PX;
ND_f=ND;
PD_f=PD;
W_f=W;
C_f=C;
NE_f=NE;
NX_f=NX;
dd_f=dd;
dx_f=dx;
v_f=v;
d_f=d;





%% 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,:) ';' ])
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
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 14 guests