How much Stata code does it take to draw one impulse response? In my first video for Timberlake Consultants, I explore AI-assisted coding through a question from oil markets. When the geopolitical acts index rises by one point, how does the real price of Brent crude respond over the next four years?
I start with Stata’s lpirf command. I then estimate one regression for each monthly horizon, so you can see which coefficient becomes each point on the curve. Finally, I write the estimator in Mata, where the matrix calculations for the coefficients and their robust standard errors are explicit.
To follow along, download the monthly data and the three Stata do-files. A simple way to check your own implementation is to pick one horizon, such as month 12, and compare its coefficient and standard error across the three scripts. My companion article for Timberlake explains the economic assumptions behind the exercise.
Many thanks to Charlotte and Francesca at Timberlake for sharing the video.