Non-negative variable

Dear all,
I am quite new to Dynare. I would like to code up the following:

v_t = s_t-sbar-Omega if s_t > sbar+Omega. Otherwise (i.e. if s_t <= sbar+Omega) v_t should be zero.

What I tried in the Dynare model block is

  1. v = max(0, (s-sbar-Omega));
  2. v= (s>(sbar+Omega))*(s-sbar-Omega);

However both do not seem to do what I need. While the first suggestion yields also negative values for v_t, the second suggestion is always zero.

Could anybody help me on this issue? Many thanks in advance.

Are you doing stochastic simulations or perfect foresight?

Currently I am trying stochastic simulation.

That’s the problem with linearizations:

So, did I get it correctly that what I would like to do does not work, at least no when doing stochastic simulation (what is with perfect foresight?)?

Would it then be possible to have something like
if x> some threshold, y=f(x) and otherwise if x< some threshold, y=g(x), with f(x) and g(x) being different?

It depends on the context. You could use a piecewise linear solution (OccBin) or perfect foresight simulation with mcp-tags.

Thank you so much for your help