Variable interaction in Stata

April 24, 2019

In this post we’ll continue looking at factor variables, and in particular how they can interact with continuous variables. Interactions can be achieved using the # operator. Let’s load up the nlsw88 dataset and have a try:

sysuse nlsw88, clear summarize c.wage#i.south

The interaction of the variables wage and south indicate that the average wage of non-southerners is approx $2 higher than that of southern residents.

Interaction of wage and south

It’s also possible to perform interactions between two indicator variables:

summarize i.collgrad#i.union

Interaction of collgrad and union

The result tells us that in this sample approx 16,67% of non-college grads are union workers whereas 7,88% of college grads belong to a union.


Profile picture

Written by Johan Osterberg who lives and works in Gothenburg, Sweden as a developer specialized in e-commerce. Connect with me on Linkedin

2024 © Johan Osterberg