1. Read data

d <- read.csv("d:/UPWORK-CANADA/StageAnalysis-1.csv")
d01 <- d[1:4,-5]
head(d01)
##      Month Stage Starting Ending
## 1 1-Jan-21     A    1,304    576
## 2 1-Jan-21     B    2,260    706
## 3 1-Feb-21     A    1,947    308
## 4 1-Feb-21     B    2,958    644

2. Clean data

str(d01)
## 'data.frame':    4 obs. of  4 variables:
##  $ Month   : chr  "1-Jan-21" "1-Jan-21" "1-Feb-21" "1-Feb-21"
##  $ Stage   : chr  "A" "B" "A" "B"
##  $ Starting: chr  "1,304" "2,260" "1,947" "2,958"
##  $ Ending  : int  576 706 308 644
##         ds   y
## 1 1-Jan-21 576
## 2 1-Jan-21 706
## 3 1-Feb-21 308
## 4 1-Feb-21 644
str(df)
## 'data.frame':    4 obs. of  2 variables:
##  $ ds: chr  "1-Jan-21" "1-Jan-21" "1-Feb-21" "1-Feb-21"
##  $ y : num  576 706 308 644
##           ds   y
## 1 2021-01-01 576
## 2 2021-01-01 706
## 3 2021-02-01 308
## 4 2021-02-01 644

3.Model forecasting

prophetpred <- prophet(df)
## Disabling yearly seasonality. Run prophet with yearly.seasonality=TRUE to override this.
## Disabling weekly seasonality. Run prophet with weekly.seasonality=TRUE to override this.
## Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
## n.changepoints greater than number of observations. Using 2
future <- make_future_dataframe(prophetpred, periods = 3)#30

4.Prediction 3 days

forecastprophet <- predict(prophetpred, future)
forecastprophet
##           ds    trend zeros zeros_lower zeros_upper additive_terms
## 1 2021-01-01 640.6529     0           0           0              0
## 2 2021-01-01 640.6529     0           0           0              0
## 3 2021-02-01 476.1708     0           0           0              0
## 4 2021-02-01 476.1708     0           0           0              0
## 5 2021-02-02 470.8649     0           0           0              0
## 6 2021-02-03 465.5591     0           0           0              0
## 7 2021-02-04 460.2532     0           0           0              0
##   additive_terms_lower additive_terms_upper multiplicative_terms
## 1                    0                    0                    0
## 2                    0                    0                    0
## 3                    0                    0                    0
## 4                    0                    0                    0
## 5                    0                    0                    0
## 6                    0                    0                    0
## 7                    0                    0                    0
##   multiplicative_terms_lower multiplicative_terms_upper yhat_lower yhat_upper
## 1                          0                          0   488.8104   797.7580
## 2                          0                          0   477.1606   807.7001
## 3                          0                          0   316.9773   639.0347
## 4                          0                          0   315.5713   638.7964
## 5                          0                          0   314.4886   630.6821
## 6                          0                          0   301.8013   623.1310
## 7                          0                          0   297.7089   618.5060
##   trend_lower trend_upper     yhat
## 1    640.6529    640.6529 640.6529
## 2    640.6529    640.6529 640.6529
## 3    476.1708    476.1708 476.1708
## 4    476.1708    476.1708 476.1708
## 5    470.8649    470.8649 470.8649
## 6    465.5591    465.5591 465.5591
## 7    460.2532    460.2532 460.2532

5. Conclusion

forecast_next3days <- forecastprophet[,1:2]
forecast_next3days
##           ds    trend
## 1 2021-01-01 640.6529
## 2 2021-01-01 640.6529
## 3 2021-02-01 476.1708
## 4 2021-02-01 476.1708
## 5 2021-02-02 470.8649
## 6 2021-02-03 465.5591
## 7 2021-02-04 460.2532
# We can concluded, next 3days forecasting the trend will decrease, shown in date=2021-02-04, trend= 460.2532