Max() function


I am trying to simulate a model w/ a Taylor rule for monetary policy and want to impose the zero lower bound. Looking through these forums, I see in the “pound lines again” thread that there is a max() function defined in Dynare 4 that takes 2 arguments. My code compiles without error but I still get values as small as about 0.985 for the gross nominal interest rate. I have a few questions.

  1. Is the command documented anywhere?

  2. Dynare needs to calculate derivatives of functions up to order 2. A max(1 , x) function has a kink at 1, so Dynare must approximate the function with a function that is differentiable at the kink. What is the functional form used? I know that there is a literature on nondifferentiable optimization, for example Israel Zang (1980), “A Smoothing-Out Technique for Min-Max Optimization” Mathematical Programming 19, 61-77. The technique suggested there is to define a smooth curve in the region of the kink only and splice it to the max() function at either endpoint, ensuring that the function never takes a value lower than the 1 in the example above, but Dynare can’t be using this technique.

  3. Does the newest version of Dynare 4 allow for user-defined Matlab functions? I could easily write a Matlab script to reproduce the technique in the cited article, and run it to get the function into memory before invoking Dynare.

Thanks in advance.



  1. Unfortunately the command is not yet documented

  2. Our way of computing the derivative of the max() function is not as clever as the one you suggest; basically, the derivative of “max(f(x), g(x)” is “(f(x)>g(x))*f’(x) + (f(x)<=g(x))*g’(x)”, where a comparison must be understood as evaluating to 1 or 0. So at the kink, by convention we give the derivative of the second argument, but this is clearly not satisfactory and is only meant as a convention.

Actually our max() function is principally meant for deterministic models where we don’t make local approximations; if you use a first or second order approximation (such as with stoch_simul), you are basically replacing max(a,b) by whatever of the expressions is greater at the steady-state.

  1. We should provide such a feature in the next major Dynare relase (probably numbered Dynare 4.1).