Book Image

Data Analysis with STATA

Book Image

Data Analysis with STATA

Overview of this book

Table of Contents (16 chapters)
Data Analysis with Stata
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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:

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 the dependent variable:

xcorr fridge_sales volume, lags(10) xlabel(-10(1)10,grid)

At lag 0, you can see that there is a nicely pointed out negative correlation between fridge_sales and the volume of the given model. This implies that the drop in volume causes a continuous and immediate increase in fridge_sales, as shown in the following table:

Now...