Book Image

R Data Visualization Cookbook

Book Image

R Data Visualization Cookbook

Overview of this book

Table of Contents (17 chapters)
R Data Visualization Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Generating a decomposed time series


A time series is dominated by seasonality as well as trend. The main objective of this section is to introduce the concept of decomposition. We can extract different elements from a time series such as trend or seasonality. The residual series is the series that is free from both, trend and seasonality.

R provides us with the tools to conduct time series analysis very efficiently. It is not possible to cover the topic of time series analysis in detail and I would highly recommend readers to refer to Introductory Time Series with R given in the See also section.

In this recipe, we will explore a simple additive decomposition model. The model is represented as follows:

Xt = Mt+St+Zt

In this notation, the variables at time t are as follows:

  • Xt: This is an observed series

  • Mt: This is the trend

  • St: This is the seasonal effect

  • Zt: This is the error term

It is also possible to use a multiplicative model and it is necessary that readers interested in decomposing the time...