I have a problem with the steady state. I am using the ‘‘normcdf’’ function in my ss file.
it used to work well in my previous model.
I modified the model and now this is the error I get . Any idea what should I check ???
thnx in advance

Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using
Levenberg-Marquardt algorithm instead.

In fsolve at 285
In AGKbgg_steadystate at 25
In evaluate_steady_state_file at 49
In evaluate_steady_state at 58
In steady_ at 54
In steady at 81
In AGKbgg at 630
In dynare at 180
Error using erfc
Input must be real and full.

Error in normcdf>localnormcdf (line 124)
p(todo) = 0.5 * erfc(-z ./ sqrt(2));
Error in normcdf (line 46)
[varargout{1:max(1,nargout)}] = localnormcdf(uflag,x,varargin{:});

I need to see the file, but my guess is that you are not correctly filtering out an exception that occurs earlier so that the input provided to the normcdf function is invalid.

Thanks for the comment.
please find attached the file
obviously the problem is from including the NORMCDF command in ‘‘fun’’ file

You need to tell your solver that psi cannot be negative as you are taking the log of it. Use an exp() tranformation for this.

Thanks a lot Mr. Pfeifer for taking your time.
Very much appreciated .

Hi both,

Sorry for turning this old topic back to life but I have the same problem. How exactly the transformation should be applied in a steady state system with x unknowns and only one variable needed to be always positive? If I apply an exp() transformation to the one variable, all the other variables will change too.

I am not sure I am following. All other variables are unaffected by this. Say you have an equation
and want b to be positive. Then you rewrite the equation as
where the new b is actually log(b). exp(b) cannot be negative and all other objects are unaffected.

Hi Johannes,

I don’t know if that’s trivial but lets say you have a system of two equations:

a +log(b) =2
a/ log(b) =1

You get a solution. If I change b to exp(b), a is supposed to change. Although I did it in Matlab and you are absolutely right I don’t get the intuition why a does not change to an exponential transformation of b.


The second equation implies that
Plugging that into the first equation
log(b) +log(b) =2*log(b)=2
so that


Now replace b by exp(\tilde b) so that \tilde b is now actually equal to \log(b):
a +log(exp(\tilde b)) =a+\tilde b=2
a/ log(exp(\tilde b)) =a/\tilde b=1
From this you will get that a=1 and \tilde b=1, which implies that b=exp(\tilde b)=e. This shows you why the variable substitution for b does not alter anything except for the definition of the variable you are substituting

Thanks a lot for your time Johannes.
I fully get it now. And I solved my problem too.
Best wishes,

I have a similar question: I’m running into the same problem that the original poster ran into. I’m trying to solve the BGG model but my model finds negative values for the default threshold \bar{\omega} such that you can no longer take a log of it. So I can’t calculate normcdf\left(\frac{\bar{\omega} + 0.5\sigma^2}{\sigma }\right), as I also get the Error in normcdf>localnormcdf (line 124). My question is: is it possible to find an exponential transformation of \bar{\omega} where I can keep the rest of the model in non-linear form, while getting rid of the negative log issue?

I am not sure I understand. Is a negative \bar \omega even economically feasible?