Residuals of static equations NaN

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
try4_steadystate.m (2.25 KB)
try4.mod (2.22 KB)

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]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-betdelta-1)fE/fX);
x(2)-((S/P)^(theta-1)
((theta
kfXI)/(k-theta+1)-fE*((1-bet)/bet)/((tauzd/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=((SPX/P)^(theta-1))/((tauzd/zx)^(theta-1)+(1/zx)^k*(k/(k-theta+1))^(k/(theta-1)));
PD=SzxPX/(tauzd);
W=S
PX*(theta-1)zx/(thetatau);
C=W*(L+NDfE(1-bet)/bet)/P;
NE=deltaND;
NX=ND
(zx)^(-k)(k/(k-theta+1))^(k/(theta-1));
dd=(PD/P)^(1-theta)CP/theta;
dx=(S
PX/P)^(1-theta)CP/theta-WfX;
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,: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]