Book Image

R Data Science Essentials

Book Image

R Data Science Essentials

Overview of this book

With organizations increasingly embedding data science across their enterprise and with management becoming more data-driven it is an urgent requirement for analysts and managers to understand the key concept of data science. The data science concepts discussed in this book will help you make key decisions and solve the complex problems you will inevitably face in this new world. R Data Science Essentials will introduce you to various important concepts in the field of data science using R. We start by reading data from multiple sources, then move on to processing the data, extracting hidden patterns, building predictive and forecasting models, building a recommendation engine, and communicating to the user through stunning visualizations and dashboards. By the end of this book, you will have an understanding of some very important techniques in data science, be able to implement them using R, understand and interpret the outcomes, and know how they helps businesses make a decision.
Table of Contents (15 chapters)
R Data Science Essentials
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Forecasting using ARIMA


We can build the ARIMA forecasting model using the arima function in R. The following code is used to build the ARIMA forecasting model, which can be used to make the forecast:

a_model=arima(as.matrix(ts), order=c(2,0,0))

There are a few important concepts that we should know in the implementation of the ARIMA technique. The preceding function takes the time series data as an input, and the other mandatory parameter that has to be passed is the order parameter, which requires three values (p, d, q), defined as follows:

  • p: The number of autoregressive terms

  • d: The number of nonseasonal differences needed for stationarity

  • r: The number of lagged forecast errors

We will understand how to choose the preceding values to build the forecasting model. We will go through a few of the combinations in detail, as shown here:

  • (1,0,0): This series is generally used when the data is highly auto-correlated. Here, we predict the current value using its immediate preceding value. Usually...