Predicting stock prices with an ARIMA model

As the historical prices of a stock are also a time series, we can thus build an ARIMA model to forecast future prices of a given stock. In this recipe, we introduce how to load historical prices with the quantmod package, and make predictions on stock prices with ARIMA.

Getting ready

In this recipe, we use the example of stock price prediction to review all the concepts we have covered in previous topics. You will require knowledge of how to create an ARIMA model and make predictions based on a built model to follow this recipe.

How to do it…

Please perform the following steps to predict Facebook's stock price with the ARIMA model:

  1. First, install and load the quantmod package:
    > install.packages("quantmod") ...

Get R for Data Science Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.