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:
- First, install and load the
quantmod
package:> install.packages("quantmod") > library(quantmod)
- Download the historical prices of Facebook Inc from Yahoo with
quantmod
:> getSymbols("FB",src="yahoo", from="2015-01-01")
- Next, plot the historical stock prices as...