How to restrict an equation to only positive values

Hi all,

My humble apologies if this type of question has been dealt with before but I have been unable to find an answer. I have the following equation:

Me = W*n - W(-1)*n(-1);

In other words it is a first-difference equation of the form y= x - x(-1). I would like to limit the equation to yield only positive values (ie: if the result is negative then the equation should take a value of zero). I guess the solution should be in the form of a max function like:

y= max[0; x - x(-1)]

Is it possible to do such a thing in Dynare? And if so would you please direct me to a resource that can help with the syntax.

The closest discussion that I have been able to find appears in the FAQs as:
“If you want to restrict a parameter to positive numbers, use a prior such as “gamma_pdf” or “inv_gamma_pdf”. Note that “estimated_params_bounds” is only used as a help for computing the posterior mode, it isn’t used during MH iterations. It is only for avoiding that the optimizer gets itself lost in regions where the mode can’t reasonably be. It isn’t a device to do constrained estimation.”

Unfortunately I am a Dynare n00b and I have no idea what this means :frowning:
Any assistance would be greatly appreciated.

We are talking about an occasionally binding constraint here. In the context of perfect foresight simulations, you can easily use the max operator. But if you are thinking of perturbation techniques to solve a deterministic model, this is a problem. Unless you go for a penalty function approach you must use something like Iacoviello/Guerrieri’s Occbin. Estimating such a model is currently not possible.

Thank you Prof.

I will do some more digging, I will try messing around with a max operator otherwise investigate this Iacoviello/Guerrieri’s Occbin.

I greatly appreciate your taking the time.

Well if anyone is interested, I added the following line, and Dynare did it’s thing, so on the plus side my syntax did not break Dynare:

Me(+1) = max(0 , W(+1)n(+1) - Wn);

On the minus side there was no change to my results, so maybe it only worked because the result was never negative.

But whatever the reason, thank you for the help Prof you are most kind.