Yul Young Park
08/24/2018
Shiny App: https://yypark.shinyapps.io/shiny_proj/
Github repo: https://github.com/yypark/ShinyStock
Components of time series data
Composition types of the components
Methods of time series forecasting
As an example, we demonstrate ARIMA model, and exponential filtering model is shown in Shiny App.
Three components of ARIMA model
library(quantmod)
library(forecast)
load("stock_data_google_2010_2016.RData")
weekly_GOOG <- to.weekly(GOOG[ "2013-01-01::2013-12-31"])
weekly_GOOG_closing <- Cl(weekly_GOOG)
ts1 <- ts(weekly_GOOG_closing, frequency=5)
autoplot(ts1) # seasonal component adj. excluded due to aperiodicity
ts1 %>% diff() %>% ggtsdisplay(main="Differenced data")
fit <- Arima(ts1, order=c(6,3,7))
checkresiduals(fit)
Ljung-Box test
data: Residuals from ARIMA(6,3,7)
Q* = 5.6726, df = 3, p-value = 0.1287
Model df: 13. Total lags used: 16
autoplot(forecast(fit))
print(accuracy(fit))
ME RMSE MAE MPE MAPE MASE
Training set 0.7272524 11.19919 7.544993 0.131336 1.699653 0.3099237
ACF1
Training set -0.006435246
References:
– https://machinelearningmastery.com/time-series-forecasting/
– https://www.r-bloggers.com/forecasting-stock-returns-using-arima-model/