We will set inequality constraints (and interval constraints) via
transformations. For example, let's assume that we want parameter
a to be positive. This can be achieved by expressing
a as an exponential. We can, therefore, estimate
lna = ln(a) and then recover a = exp(lna)
after the estimation. The trick is to use a transformation whose
range is the interval over which we want to restrict the parameter.

Type

. help math functions

to see the mathematical functions available in Stata.

There are many ways to set interval constraints. The following examples show
some possibilities.

Example 1: Constraints of the form a > 0

As stated before, we will estimate ln(a) instead of
a.

. nl (mpg2 = exp({lna})*price + {b}*turn + {c}), nolog
(obs = 74)

Source

SS df MS

Number of obs = 74

Model

1427.2735 2 713.636766

R-squared = 0.5841

Residual

1016.1859 71 14.3124778

Adj R-squared = 0.5724

Root MSE = 3.783184

Total

2443.4595 73 33.4720474

Res. dev. = 403.8641

mpg2

Coef. Std. Err. t P>|t| [95% Conf. Interval]

/lna

-7.535992 .2959172 -25.47 0.000 -8.126034 -6.94595

/b

.8350376 .1058498 7.89 0.000 .6239791 1.046096

/c

-57.69477 4.027951 -14.32 0.000 -65.72627 -49.66326

Parameter c taken as constant term in model & ANOVA table

The output shows the parameter lna. To recover
a, we can use the nlcom command; we can
always call nl (or any estimation command) with the
coeflegend option to see how to refer to the parameters in
further expressions.

Example 4: Constraints of the form 0 < a < b

We can express a as an exponential, as in Example 1, to
ensure that it will be positive. In addition, we want to set the restriction
b>a; therefore, we can also express the difference
b−a as an exponential.