Gary King Homepage Previous: How can I set Up: Frequently Asked Questions Next: How can I use

How can I set the X's when I have interaction terms?

setx will work with interacted variables. Suppose the independent variables in your dataset are X1 and X2 and you have created an interaction term $ X1X2=X1\times X2$. First you would run estsimp with the interacted variable, e.g.:

estsimp regress y x1x2

If you wish to set X1X2 to its mean, then you can use setx in the normal way:

setx x1x2 mean

However, if you want to set X1X2 to the product of the means of X1 and X2 (rather than the mean of the product), then you have two choices. First, you could set the values by hand, e.g.,

setx x1x2 10*12

where 10 is the mean of x1 and 12 is the mean of x2.

However, an even better method is the following sequence of commands:

summarize x1, meanonly        /* Compute the mean of x1 */
local mx1=`r(mean)'           /* Save the mean in a local macro */
summarize x2, meanonly        /* Compute the mean of x2 */
local mx2=`r(mean)'           /* Save the mean in a local macro */
setx x1x2 `mx1'*`mx2'         /* Setx to mean(x1)*mean(x2) */



Gary King 2006-01-04