# Hack for imposing inequality constraints during estimation

**URL:** <https://forum.dynare.org/t/hack-for-imposing-inequality-constraints-during-estimation/2039>\
**Category:** Dynare contributions and examples\
**Created:** [25 June 2011 00:17 UTC](https://forum.dynare.org/t/hack-for-imposing-inequality-constraints-during-estimation/2039 "2011-06-25T00:17:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cfp](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/ed655f/32.png) [@cfp](https://forum.dynare.org/u/cfp)\
**Post date:** [25 June 2011 00:17 UTC](https://forum.dynare.org/t/hack-for-imposing-inequality-constraints-during-estimation/2039/1 "2011-06-25T00:17:24Z")

</div>

So I wanted to impose some non-linear inequality constraints during estimation. The following code seemed to work and may be of use to others. The trick is to introduce a new dummy variable with an equation that violates the Blanchard-Kahn conditions if the inequalities aren’t satisfied.

```auto
var dummy;
...
model;
...
	#ineqtest = 1.5 - 
		( p * gamma * lambda < 1 ) *
		( eta * gamma * lambda >= 1.0 ) *
		( STEADY_STATE( jP ) > 0 ) *
		( STEADY_STATE( log_1PmuP ) > STEADY_STATE( log_1Pmu ) ) *
		( STEADY_STATE( LR ) > 0 ) *
		( STEADY_STATE( o_log_rd_share ) > -3.5915 ) *
		( STEADY_STATE( o_log_rd_share ) < -3.5905 );
	dummy = ineqtest * ( 1 + dummy(+1) ) - 0.5;
```

The first equation specifies all of the inequalities I want to hold (and is the bit you would need to change). Note that the things in the inequalities can be functions of the steady state, and of model local variables (eta is in this particular example). The second ensures that the BK conditions are violated if the inequalities don’t hold. When the inequalities hold, ineqtest = 0.5, and so the dummy equation is explosive, meaning dummy = 0 is the only solution and the BK conditions hold. If one of the inequalities doesn’t hold, then ineqtest = 1.5, and so the dummy equation is indeterminate (and so violates the BK conditions), with a mean of -2 (to make clear what’s going on).

If any of the Dynare dev’s are reading this it would be great if there was a non-hacky way of doing this. (Perhaps there already is and I’ve just missed it.)

Tom

---

<div class="post-metadata">

**Author:** ![azuo1001](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@azuo1001](https://forum.dynare.org/u/azuo1001)\
**Post date:** [15 February 2012 02:18 UTC](https://forum.dynare.org/t/hack-for-imposing-inequality-constraints-during-estimation/2039/2 "2012-02-15T02:18:08Z")

</div>

Hi Tom, I tested it, but it seemed that it didn’t work, the result was just liking not imposing the restritions.

---

<div class="post-metadata">

**Author:** ![cfp](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/ed655f/32.png) [@cfp](https://forum.dynare.org/u/cfp)\
**Post date:** [15 February 2012 11:04 UTC](https://forum.dynare.org/t/hack-for-imposing-inequality-constraints-during-estimation/2039/3 "2012-02-15T11:04:59Z")

</div>

Your PM suggested that you’re trying to use this method to impose bounds on simulated variables rather than on the steady state. See Michael’s post here for details on doing that: [[The Zero Lower Bound Constraint on Nominal Int. Rate](https://forum.dynare.org/t/the-zero-lower-bound-constraint-on-nominal-int-rate/1940/1))
