Constraints in Regression Models
Defining constraints
Constraints impose restrictions on regression coefficients and the like. Often, you will want to impose the constraint that the effect of two variables is the same, i.e. that the difference of the regression coefficients is equal to 0 (zero). Other constraints are possible, of course; e.g., you might wish to test that one coefficient has twice the magnitude of another.
Constraints are defined prior to model estimation. Each constraint has to be given a number. I give two examples, assuming that we have a series of dummy variables on which the constraints are to be imposed (of course constraints can be used for any type of variable you wish):
constraint 1 group1 = group2
const 2 group2 = .5 * group3
Here, I have defined the constraints mentioned in the first paragraph: The effect of group1 is supposed to be equal to that of group2; and the effect of group2 is half that of group3 (which makes the effect of group3 twice that of group2). Note that both constraints imply that the effect of group3 is also twice that of group1.
The second constraint might also have been written as:
constraint 2 group2 * 2 = group3
Managing constraints
If you have lost sight of which constraints you have defined, type
const list
I you wish to drop one or several constraints, you may type, e.g.,
const drop 2 5
The constraints are kept in memory and are not tied to a specific dataset. That is, if you have defined and used a constraint, and you switch to another data set that contains the very variables that are adressed by the constraint (or, to be precise: variables with the same names), you may use this constraint again if you wish.
Using constraints
Several regression models permit inclusion of constraints via the use of options. Typically, you will add an option like const(1 3 5)
or whichever constraints you wish to include. If appropriate, you may write const(1/5)
.
For linear regression with constraints, the option constraint
is not defined. Here, you will have to use a special command, cnsreg
.
Afterword
Actually, constraint
as command can be abbreviated to cons
. But as an option, the minimum required is const
. So you better get used to const
in the first place.
© W. Ludwig-Mayerhofer, Stata Guide | Last update: 27 Jun 2012