Let’s take DATE and Adjusted Price variables

mydata <- read.csv("ocbc.csv")
str(mydata)
## 'data.frame':    751 obs. of  7 variables:
##  $ Date     : Factor w/ 751 levels "1/10/2017","1/10/2018",..: 580 587 590 593 595 596 602 605 608 612 ...
##  $ Open     : num  10.2 10.4 10.4 10.4 10.3 ...
##  $ High     : num  10.3 10.4 10.4 10.4 10.4 ...
##  $ Low      : num  10.2 10.3 10.4 10.3 10.3 ...
##  $ Close    : num  10.3 10.4 10.4 10.3 10.4 ...
##  $ Adj.Close: num  9.29 9.35 9.31 9.3 9.37 ...
##  $ Volume   : int  5817500 5037600 3915700 2517100 6111900 2759600 6103800 8404500 4301500 4724400 ...

Some samples of actual price

tail(mydata)
# convert to proper date format
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
ds <- as.Date(parse_date_time(mydata$Date, "mdy"))
y <- log(mydata$Adj.Close)
df <- data.frame(ds,y)

# display graph
library(ggplot2)
qplot(ds,y, data=df)

released by facebook

library(prophet)
## Loading required package: Rcpp
m <- prophet(df)
## Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
## Initial log joint probability = -3.32159
## Optimization terminated normally: 
##   Convergence detected: relative gradient magnitude is below tolerance
#prediction
# future <- make_future_dataframe(m, periods = 365) #365 days. 

future <- make_future_dataframe(m, periods = 7) #gambler won't wait 365 days, want to see next 7 days
forecast <-predict(m, future)
tail(forecast[c('ds', 'yhat', 'yhat_lower', 'yhat_upper')])

What is the forecasted stock price ? I extracted below

#             ds     yhat yhat_lower yhat_upper
# 753 2018-07-15 2.438590   2.414380   2.463657
# 754 2018-07-16 2.451848   2.426568   2.476955
# 755 2018-07-17 2.451204   2.425156   2.477577
# 756 2018-07-18 2.449886   2.426266   2.475271
# 757 2018-07-19 2.450195   2.424433   2.474771
# 758 2018-07-20 2.448888   2.421411   2.472443

Convert the log price back to original stock price. Yhat is the predicted price. What is the forecasted stock price on 2018 July 20th ?

exp(2.448888) # took the last date.
## [1] 11.57547

Predicted 30 days price

future <- make_future_dataframe(m, periods = 30) 
forecast <-predict(m, future)
tail(forecast[c('ds', 'yhat', 'yhat_lower', 'yhat_upper')],30)

Plot Forecast

plot(m, forecast)

prophet_plot_components(m, forecast)