Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Data Analysis with STATA

You're reading from   Data Analysis with STATA Explore the big data field and learn how to perform data analytics and predictive modelling in STATA

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher Packt
ISBN-13 9781782173175
Length 176 pages
Edition 1st Edition
Arrow right icon
Toc

Table of Contents (11) Chapters Close

Preface 1. Introduction to Stata and Data Analytics FREE CHAPTER 2. Stata Programming and Data Management 3. Data Visualization 4. Important Statistical Tests in Stata 5. Linear Regression in Stata 6. Logistic Regression in Stata 7. Survey Analysis in Stata 8. Time Series Analysis in Stata 9. Survival Analysis in Stata 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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime