Book Image

Hands-On Time Series Analysis with R

By : Rami Krispin
Book Image

Hands-On Time Series Analysis with R

By: Rami Krispin

Overview of this book

Time-series analysis is the art of extracting meaningful insights from, and revealing patterns in, time-series data using statistical and data visualization approaches. These insights and patterns can then be utilized to explore past events and forecast future values in the series. This book explores the basics of time-series analysis with R and lays the foundation you need to build forecasting models. You will learn how to preprocess raw time-series data and clean and manipulate data with packages such as stats, lubridate, xts, and zoo. You will analyze data using both descriptive statistics and rich data visualization tools in R including the TSstudio, plotly, and ggplot2 packages. The book then delves into traditional forecasting models such as time-series linear regression, exponential smoothing (Holt, Holt-Winter, and more) and Auto-Regressive Integrated Moving Average (ARIMA) models with the stats and forecast packages. You'll also work on advanced time-series regression models with machine learning algorithms such as random forest and Gradient Boosting Machine using the h2o package. By the end of this book, you will have developed the skills necessary for exploring your data, identifying patterns, and building a forecasting model using various traditional and machine learning methods.
Table of Contents (14 chapters)

What this book covers

Chapter 1, Introduction to Time Series Analysis and R, provides a brief introduction to the time series analysis process and defines the attributes and characteristics of time series data. In addition, the chapter provides a brief introduction to R for readers with no prior knowledge of R. This includes the mathematical and logical operators, loading data from multiple sources (such as flat files and APIs), installing packages, and so on.

Chapter 2, Working with Date and Time Objects, focuses on the main date and time classes in R—the Date and POSIXct/lt classes—and their attributes. This includes ways to reformat date and time objects with the base and lubridate packages.

Chapter 3, The Time Series Object, focuses on the ts class, an R core class for time series data. This chapter dives deep into the attributes of the ts class, methods for creating and manipulating ts objects using tools from the stats package, and data visualization applications with the TSstudio and dygraphs packages.

Chapter 4, Working with zoo and xts Objects, covers the applications of the zoo and xts classes, an advanced format for time series data. This chapter focuses on the attributes of the zoo and xts classes and the preprocessing and data visualization tools from the zoo and xts packages

Chapter 5, Decomposition of Time Series Data, focuses on decomposing time series data down to its structural patterns—the trend, seasonal, cycle, and random components. Starting with the moving average function, the chapter explains how to use the function for smoothing, and then focuses on decomposing a time series to down its components with the moving average.

Chapter 6, Seasonality Analysis, explains approaches and methods for exploring and revealing seasonal patterns in time series data. This includes the use of summary statistics, along with data visualization tools from the forecast, TSstudio, and ggplot2 packages.

Chapter 7, Correlation Analysis, focuses on methods and techniques for analyzing the relationship between time series data and its lags or other series. This chapter provides a general background for correlation analysis, and introduces statistical methods and data visualization tools for measuring the correlation between time series and its lags or between multiple time series.

Chapter 8, Forecasting Strategies, introduces approaches, strategies, and tools for building time series forecasting models. This chapter covers different training strategies, different error metrics, benchmarking, and evaluation methods for forecasting models.

Chapter 9, Forecasting with Linear Regression, dives into the forecasting applications of the linear regression model. This chapter explains how to model the different components of a series with linear regression by creating new features from the series. In addition, this chapter covers the advanced modeling of structural breaks, outliers, holidays, and time series with multiple seasonality.

Chapter 10, Forecasting with Exponential Smoothing Models, focuses on forecasting time series data with exponential smoothing functions. This chapter explains the usage of smoothing parameters to forecast time series data. This includes simplistic models such as simple exponential smoothing, which is for time series with neither trend nor seasonal components, to advanced smoothing models such as Holt-Winters forecasting, which is for forecasting time series with both trend and seasonal components.

Chapter 11, Forecasting with ARIMA Models, covers the ARIMA family of forecasting models. This chapter introduces the different types of ARIMA models—the autoregressive (AR), moving average (MA), ARMA, ARIMA, and seasonal ARIMA (SARIMA) models. In addition, the chapter focuses on methods and approaches to identify, tune, and optimize ARIMA models with both autocorrelation and partial correlation functions using applications from the stats and forecast packages.

Chapter 12, Forecasting with Machine Learning Models, focuses on methods and approaches for forecasting time series data with machine learning models with the h2o package. This chapter explains the different steps of modeling time series data with machine learning models. This includes feature engineering, training and tuning approaches, evaluation, and benchmarking a forecasting model's performance.