Clarifying the use of lincom, nlcom, and margins in Stata

In this post, I will show how to use some postestimation tools in Stata to test linear combination of coefficients with interactions terms between two continuous variables. I thank my coauthor, Hugo Oriola, for showing me how lincom functions.

The data that I will use in this blog is based on a joint project with Joshua Aizenman, Donghyun Park, Gazi Salah Uddin, and Hiro Ito on the determinants of recoveries. This relies on this document on interactions written by Rose Medeiros from Stata Corp LLC. Besides, we are going to use the data coming from this database on trade restrictions.

We are going to estimate the effect on the recoveries 8 quarters after the start of the recession of the second component of the 12 variables in the ICRG political risk dimension and the Measure of Aggregate Trade Restrictions (MATR).

// Equivalence between lincom and margins
areg recovery2 c.MATR##c.pc2 if RGDP_p!=0 & period>2002, ///
 absorb(imfcode period) rob coeflegend

Now, I will summarize the variables. MATR is not continuous, but let us assume it is for the blog:

We can add a histogram for MATR:

hist MATR, frequency discrete addlabel ///
 graphregion(margin(r+3)) ///
 title("Distribution of MATR")

Look at the interaction for the value of 5 for MATR (a higher value indicates more restrictions). Margins, lincom and nlcom rely on the Delta method:

lincom pc2 + c.MATR#c.pc2*5
margins, dydx(pc2) at(MATR=(5)) vsquish
nlcom _b[pc2] +  _b[c.MATR#c.pc2]*5

The results are similar and the approximation is a bit different for nlcom.

Now, we try the value of 15 for MATR:

lincom pc2 + c.MATR#c.pc2*15
margins, dydx(pc2) at(MATR=(15)) vsquish
nlcom _b[pc2] +  _b[c.MATR#c.pc2]*15

Better institutions (less political risks according to the ICRG ratings) matter for the strength of the recovery after 8 quarters after the start of a recession, especially for countries with high trade restrictions.

References

Estefania-Flores, J., Furceri, D., Hannan, S. A., Ostry, J. D., & Rose, A. K. (2024). A measurement of aggregate trade restrictions and their economic effects. The World Bank Economic Review, lhae033, https://doi.org/10.1093/wber/lhae033.

Estefania-Flores, J., Furceri, D., Hannan, S. A., Ostry, J. D., & Rose, A. K. Measure of Aggregate Trade Restrictions – MATR, https://sites.google.com/view/m-atr/, consulted on February 23, 2025.

Rose Medeiros, Linear Regression Models with Interaction/Moderation, https://www.stata.com/why-use-stata/easy-to-grow-with/linear.pdf, consulted on February 23, 2025.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.