How to restrict an equation to only positive values

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

How to restrict an equation to only positive values

Postby snickles » Thu Sep 10, 2015 11:11 am

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 :(
Any assistance would be greatly appreciated.
snickles
 
Posts: 6
Joined: Wed Sep 09, 2015 12:40 pm

Re: How to restrict an equation to only positive values

Postby jpfeifer » Sun Sep 13, 2015 6:02 pm

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: How to restrict an equation to only positive values

Postby snickles » Tue Sep 22, 2015 4:51 am

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.
snickles
 
Posts: 6
Joined: Wed Sep 09, 2015 12:40 pm

Re: How to restrict an equation to only positive values

Postby snickles » Tue Sep 22, 2015 10:28 am

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) - W*n);

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.
snickles
 
Posts: 6
Joined: Wed Sep 09, 2015 12:40 pm


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 9 guests