Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Time Series Analysis with Python Cookbook

You're reading from   Time Series Analysis with Python Cookbook Practical recipes for exploratory data analysis, data preparation, forecasting, and model evaluation

Arrow left icon
Product type Paperback
Published in Jan 2026
Publisher
ISBN-13 9781805124283
Length 98 pages
Edition 2nd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Tarek A. Atwan Tarek A. Atwan
Author Profile Icon Tarek A. Atwan
Tarek A. Atwan
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

1. Time Series Analysis with Python Cookbook, Second Edition: Practical recipes for exploratory data analysis, data preparation, forecasting, and model evaluation
2. Chapter 1: Getting Started with Time Series Analysis FREE CHAPTER 3. Chapter 2: Reading Time Series Data from Files 4. Chapter 3: Reading Time Series Data from Databases 5. Chapter 4: Persisting Time Series Data to Files 6. Chapter 5: Persisting Time Series Data to Databases 7. Chapter 6: Working with Date and Time in Python 8. Chapter 7: Handling Missing Data 9. Chapter 8: Outlier Detection Using Statistical Methods 10. Chapter 9: Exploratory Data Analysis and Diagnosis 11. Chapter 10: Building Univariate Time Series Models Using Statistical Methods 12. Chapter 11: Additional Statistical Modeling Techniques for Time Series 13. Chapter 12: Forecasting Using Supervised Machine Learning

Testing for autocorrelation in time series data

Autocorrelation is like statistical correlation (think Pearson correlation from high school), which measures the strength of a linear relationship between two variables, except that we measure the linear relationship between time series values separated by a lag. In other words, we are comparing a variable with its lagged version of itself.

In this recipe, you will perform a Ljung-Box test to check for autocorrelations up to a specified lag and whether they are significantly far off from 0. The null hypothesis for the Ljung-Box test states that the previous lags are not correlated with the current period. In other words, you are testing for the absence of autocorrelation.

When running the test using acorr_ljungbox from statsmodels, you need to provide a lag value. The test will run for all lags up to the specified lag (maximum lag).

The autocorrelation test is another helpful test for model diagnostics. As discussed in the previous recipe...

lock icon The rest of the chapter is locked
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Time Series Analysis with Python Cookbook
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
Modal Close icon
Modal Close icon