Stata 15 help for constraint

[R] constraint -- Define and list constraints


Define constraints

constraint [define] # [exp = exp | coeflist]

List constraints

constraint dir [numlist|_all]

constraint list [numlist|_all]

Drop constraints

constraint drop {numlist|_all}

Programmer's commands

constraint get #

constraint free

where coeflist is as defined in [R] test and # is restricted to the range 1 to 1,999, inclusive.


Statistics > Other > Manage constraints


constraint defines, lists, and drops linear constraints. Constraints are for use by models that allow constrained estimation.

Constraints are defined by the constraint command. The currently defined constraints can be listed by either constraint list or constraint dir; both do the same thing. Existing constraints can be eliminated by constraint drop.

constraint get and constraint free are programmer's commands. constraint get returns the contents of the specified constraint in macro r(contents) and returns in scalar r(defined) 0 or 1 -- 1 being returned if the constraint was defined. constraint free returns the number of a free (unused) constraint in macro r(free).


For use with cnsreg (where there is one equation):

. sysuse auto . constraint 1 price = weight . cnsreg mpg price weight, constraints(1)

For use with mlogit (where there are multiple equations):

. webuse sysdsn1 . constraint 2 [Uninsure] = 0 . mlogit insure age male, constraints(2)

. constraint 10 [Indemnity]: . constraint 11 [Indemnity=Prepaid]: . mlogit insure age male, constraints(10/11) baseoutcome(3)

In all cases:

. constraint drop 1, 10-11 . constraint drop _all

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index