O'Reilly logo

Data Analysis with Stata by Swizec Teller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Code for time series analysis in Stata

Let's understand the Stata code to run the autocorrelation test first. To find autocorrelation, we draw correlograms. The command to draw correlograms is corrgram, for example, take a look at the following:

corrgram fridge_sales, lags(12)

You will get the following output when you run this command:

Code for time series analysis in Stata

To explore the different relationships between two given time series, you can leverage the xcorr command.

The following graph depicts the existing correlation between the fridge_sales quarterly growth rate and volume. When you use the xcorr command, you need to type all the independent variables first, followed by ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required