Forecasting the price of a stock is a necessary work for every stock investors. choosing the right model might be challenging and confusing especially if the historical data has no trend and seasonality. This report describes different timeseries forecasting models applied to a real stock close price dataset. For this project we will start with a general idea of the stock price, incluiding dataset analysis. Followed by a general description and analysis of the dataset, our objective is to apply different forecasting predictive models for “Unilever Indonesia” stock daily close price. The models will be evaluated, analysed and compared to find the best model that has as little error as possible.
The dataset is consist of stock price and several basic stock indicators of Unilever Indonesia, an issuer with code UNVR from Indonesia Stock Exchange. the dataset is acquire from IDX Stock API
library(tidyverse) #data manipulation
library(lubridate) # date manipulation
library(forecast) # time series library
library(TTR) # for Simple moving average function
library(MLmetrics) # calculate error
library(tseries) # adf.test
library(fpp)
library(ggplot2)
library(gridExtra)unvr <- read_csv("data_unvr_2015-2019.csv")
glimpse(unvr)## Rows: 1,213
## Columns: 25
## $ date <dttm> 2015-01-02, 2015-01-05, 2015-01-06, 2015-01-07,~
## $ previous <dbl> 32300, 32525, 32475, 32475, 33125, 33375, 33225,~
## $ open_price <dbl> 32300, 32475, 32300, 32500, 33100, 33100, 32875,~
## $ first_trade <dbl> 32400, 32400, 32200, 32525, 33125, 33125, 32875,~
## $ high <dbl> 32625, 32525, 32500, 33700, 33450, 33450, 32900,~
## $ low <dbl> 32275, 32275, 32150, 32500, 33100, 32975, 32100,~
## $ close <dbl> 32525, 32475, 32475, 33125, 33375, 33225, 32100,~
## $ change <dbl> 225, -50, 0, 650, 250, -150, -1125, 900, -350, 7~
## $ volume <dbl> 766900, 1761400, 1400700, 2901400, 2654900, 2078~
## $ value <dbl> 24931422500, 57201080000, 45438150000, 960229150~
## $ frequency <dbl> 987, 1229, 2123, 2549, 1574, 1663, 1518, 1693, 1~
## $ index_individual <dbl> 166538.7, 166282.6, 166282.6, 169610.9, 170890.9~
## $ offer <dbl> 32550, 32500, 32500, 33200, 33375, 33275, 32275,~
## $ offer_volume <dbl> 255200, 125500, 235800, 15200, 39600, 200, 2000,~
## $ bid <dbl> 32525, 32475, 32475, 33125, 33350, 33200, 32100,~
## $ bid_volume <dbl> 46300, 96700, 103000, 252300, 80000, 200, 133200~
## $ listed_shares <dbl> 7.63e+09, 7.63e+09, 7.63e+09, 7.63e+09, 7.63e+09~
## $ tradeble_shares <dbl> 7.63e+09, 7.63e+09, 7.63e+09, 7.63e+09, 7.63e+09~
## $ weight_for_index <dbl> 7.63e+09, 7.63e+09, 7.63e+09, 7.63e+09, 7.63e+09~
## $ foreign_sell <dbl> 352000, 1055200, 823400, 1091000, 931700, 107070~
## $ foreign_buy <dbl> 288100, 265700, 356800, 1754900, 1107300, 970800~
## $ delisting_date <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, ~
## $ non_regular_volume <dbl> 683000, 0, 378, 86600, 157407, 5000, 157400, 154~
## $ non_regular_value <dbl> 22171705000, 0, 12271891, 2851565300, 5254861400~
## $ non_regular_frequency <dbl> 15, 0, 4, 5, 7, 1, 8, 1, 0, 1, 1, 6, 2, 1, 18, 5~
Because we only want to forcast the stock price we will only use 2 variables which is date and close (closing price).
data <- unvr %>% select(date,close)
dataAs we can see from the data that there are some missing date due to there are no market transaction on weekends. to impute the missing date values we will perform padding using pad function from padr package. for the missing values we will use the price of the date before.
library(padr)
library(imputeTS)
data <- data %>%
pad() %>%
mutate(close = na_locf(close))
# add first jan 2015 as the first row data
data <- rbind(data.frame(date = ymd("2015-01-01"), close = data[1,]$close), data)
dataAfter the data is free from missing date. we will create time series object with ts function from stats package.
freq <- 365
data_ts <- ts(data = data$close,
start = c(2015,01,02),
frequency = freq)data_ts %>% autoplot()Now, we will try to explore whether our timeseries object has trend and seasonal properties (one-seasonal/multiseasonal).
data_dec <- decompose(data_ts)
data_dec %>% autoplot()note that the data is an additive time series and it has both trend and seasonality. This is a valuable information for the model building later.
When forecasting or predicting the future, most time series models assume that each point is independent of one another. The best indication of this is when the dataset of past instances is stationary. For data to be stationary, the statistical properties of a system do not change over time.
Now we test whether the data is stationary or not with Augmented Dickey-Fuller Test. we will see the alpha and determine whether to reject or accept the null hypothesis. the null hypothesis is data is not stationary H0 : data is not stationary H1 : data is stationary
adf.test(data_ts)##
## Augmented Dickey-Fuller Test
##
## data: data_ts
## Dickey-Fuller = -2.4592, Lag order = 12, p-value = 0.3839
## alternative hypothesis: stationary
Based on Augmented Dickey-Fuller Test (adf.test) result, the p-value is < alpha and therefore the data is already stationary. Therefore, for a model building using SARIMA, we do not need to perform differencing on the data first.
For time series the cross-validation scheme should not be sampled randomly, but split sequentially. We will split the data 80:20. Because the data is consist of five years transactions. we will use the first four years for train dataset and the rest for test dataset.
# the first 4 years data
train <- data_ts %>% head(length(data_ts) - freq)
# the last year data
test <- data_ts %>% tail(freq)For model building, I will compare between two of the widely used time series modeling in business and industry: ETS Holt-Winters and Seasonal Arima. I use ETS Holt-Winters because my data contain both seasonal and trend. I also want to compare it between seasonal Arima (SARIMA) to check whether the seasonal ARIMA can give better forecasting performance.
SARIMA is an acronyms for Seasonal Auto Regresive Integreted Moving Averange. SARIMA is great for predicting a stationary time series data that has seasonality. Stationary time series data has values which move around its mean (no trend nor seasonality). It predicts future values by combining Auto Regresive and Moving Averange method, whereas integrated stands for how many times differencing applied to the data (a way to transform non-stationary into stationary time series data). There is also a special approach for stationary data with seasonality that is using Seasonal ARIMA (SARIMA).
ETS Holt-Winters is a method that predict future values by smoothing on error, trend, and seasonal, where it gives different weights on each data point used for prediction.
# ETS Holt-Winters
data_ets <- stlm(train, method = "ets", lambda = 0) # no log transformation for addivite data
# SARIMA TODO
data_arima <- stlm(train, method = "arima", lambda = 0)# forecast
ets_forcast <- forecast(data_ets, h = freq)
arima_forcast <- forecast(data_arima, h = freq)The table below is the forecasted value plus confidence interval from ETS model.
ets_forcast ## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2019.0000 43009.39 42379.92 43648.22 42050.43 43990.22
## 2019.0027 43005.30 42151.13 43876.77 41705.86 44345.22
## 2019.0055 42995.78 41966.11 44050.72 41431.05 44619.60
## 2019.0082 42295.24 41135.77 43487.39 40534.90 44132.02
## 2019.0110 42458.60 41164.74 43793.12 40495.86 44516.48
## 2019.0137 43208.63 41772.35 44694.30 41031.45 45501.33
## 2019.0164 42959.64 41422.34 44553.98 40630.94 45421.79
## 2019.0192 43069.07 41425.96 44777.35 40581.68 45708.92
## 2019.0219 43117.93 41377.25 44931.85 40484.41 45922.77
## 2019.0247 42778.95 40962.23 44676.24 40031.97 45714.43
## 2019.0274 42660.99 40764.30 44645.93 39794.63 45733.81
## 2019.0301 42614.24 40638.63 44685.90 39630.15 45823.04
## 2019.0329 42797.96 40735.90 44964.40 39684.84 46155.30
## 2019.0356 42491.76 40370.11 44724.91 39290.20 45954.19
## 2019.0384 42588.20 40389.94 44906.11 39272.57 46183.77
## 2019.0411 42850.28 40568.72 45260.16 39410.53 46590.25
## 2019.0438 42941.94 40587.83 45432.60 39394.33 46809.03
## 2019.0466 42689.20 40283.70 45238.34 39065.67 46648.83
## 2019.0493 43259.01 40757.19 45914.40 39491.91 47385.44
## 2019.0521 43086.34 40532.29 45801.33 39242.13 47307.14
## 2019.0548 43580.31 40935.69 46395.79 39601.31 47959.11
## 2019.0575 43479.51 40781.38 46356.17 39421.52 47955.23
## 2019.0603 43554.44 40793.33 46502.43 39403.26 48142.94
## 2019.0630 44004.73 41157.49 47048.93 39725.60 48744.78
## 2019.0658 44265.60 41344.82 47392.71 39877.50 49136.57
## 2019.0685 44047.72 41086.12 47222.79 39599.82 48995.20
## 2019.0712 44313.22 41279.36 47570.05 39758.34 49389.92
## 2019.0740 44257.74 41174.40 47571.97 39630.12 49425.73
## 2019.0767 44057.91 40936.46 47417.37 39374.61 49298.26
## 2019.0795 44350.80 41157.17 47792.24 39560.74 49720.85
## 2019.0822 44115.93 40888.96 47597.57 39277.38 49550.53
## 2019.0849 43995.94 40728.49 47525.52 39098.21 49507.19
## 2019.0877 44295.99 40957.49 47906.63 39293.28 49935.64
## 2019.0904 44902.21 41469.37 48619.21 39759.69 50709.86
## 2019.0932 45421.22 41900.27 49238.04 40148.26 51386.71
## 2019.0959 45325.21 41764.11 49189.95 39993.68 51367.49
## 2019.0986 45442.68 41825.34 49372.87 40028.50 51589.16
## 2019.1014 45293.76 41642.10 49265.63 39829.76 51507.33
## 2019.1041 45478.58 41766.31 49520.80 39925.44 51804.10
## 2019.1068 45348.14 41601.57 49432.13 39745.23 51740.91
## 2019.1096 45461.19 41660.82 49608.25 39779.37 51954.58
## 2019.1123 45925.52 42042.01 50167.76 40120.95 52569.88
## 2019.1151 45793.32 41877.35 50075.47 39941.80 52502.09
## 2019.1178 45849.38 41885.49 50188.41 39927.80 52649.19
## 2019.1205 45772.82 41773.01 50155.62 39799.12 52643.14
## 2019.1233 45798.44 41754.34 50234.22 39760.14 52753.75
## 2019.1260 45348.90 41303.35 49790.70 39309.97 52315.54
## 2019.1288 45685.43 41568.88 50209.63 39542.06 52783.24
## 2019.1315 45672.27 41516.41 50244.13 39471.77 52846.78
## 2019.1342 45959.29 41737.01 50608.71 39661.24 53257.45
## 2019.1370 45969.06 41706.02 50667.87 39611.74 53346.68
## 2019.1397 45729.32 41449.26 50451.34 39348.16 53145.32
## 2019.1425 46097.77 41744.08 50905.52 39608.38 53650.36
## 2019.1452 45935.91 41558.90 50773.90 39413.30 53537.96
## 2019.1479 45720.63 41326.10 50582.47 39173.44 53362.08
## 2019.1507 45989.27 41531.04 50926.08 39348.70 53750.51
## 2019.1534 46333.65 41804.25 51353.81 39588.61 54227.90
## 2019.1562 46092.63 41549.56 51132.45 39328.77 54019.76
## 2019.1589 46088.76 41509.18 51173.58 39272.09 54088.63
## 2019.1616 46208.15 41580.08 51351.34 39320.83 54301.83
## 2019.1644 46546.24 41847.75 51772.26 39555.66 54772.24
## 2019.1671 47028.03 42244.30 52353.47 39912.19 55412.53
## 2019.1699 46647.55 41866.54 51974.55 39537.29 55036.50
## 2019.1726 46367.14 41579.40 51706.17 39248.42 54777.02
## 2019.1753 46749.43 41886.77 52176.59 39520.85 55300.15
## 2019.1781 46510.49 41637.73 51953.51 39268.42 55088.18
## 2019.1808 45918.06 41073.12 51334.49 38718.87 54455.82
## 2019.1836 45671.94 40819.21 51101.58 38462.67 54232.48
## 2019.1863 45572.37 40696.80 51032.05 38330.67 54182.23
## 2019.1890 45545.18 40639.38 51043.18 38260.08 54217.43
## 2019.1918 45844.29 40873.19 51419.99 38463.72 54641.07
## 2019.1945 45825.61 40823.72 51440.35 38400.83 54685.96
## 2019.1973 45851.72 40814.40 51510.74 38375.85 54783.94
## 2019.2000 46008.76 40921.75 51728.15 38460.64 55038.24
## 2019.2027 45905.49 40797.76 51652.68 38328.14 54980.85
## 2019.2055 46088.79 40928.65 51899.50 38435.19 55266.45
## 2019.2082 45815.21 40654.10 51631.52 38161.68 55003.69
## 2019.2110 46145.07 40915.21 52043.41 38391.09 55465.14
## 2019.2137 46193.32 40926.60 52137.80 38386.18 55588.30
## 2019.2164 46193.48 40895.57 52177.73 38341.60 55653.32
## 2019.2192 46399.42 41046.79 52450.06 38467.96 55966.22
## 2019.2219 45891.49 40566.90 51914.95 38003.08 55417.32
## 2019.2247 45761.66 40421.88 51806.82 37852.23 55323.80
## 2019.2274 45806.16 40431.12 51895.78 37845.97 55440.62
## 2019.2301 45729.55 40333.67 51847.30 37739.98 55410.51
## 2019.2329 45700.10 40278.09 51852.00 37673.32 55437.10
## 2019.2356 45665.04 40217.78 51850.09 37602.37 55456.50
## 2019.2384 45363.99 39923.63 51545.70 37312.99 55152.15
## 2019.2411 45863.55 40334.14 52150.99 37682.24 55821.13
## 2019.2438 45874.15 40314.48 52200.53 37649.56 55895.40
## 2019.2466 45610.04 40053.76 51937.08 37391.93 55634.34
## 2019.2493 45678.27 40085.19 52051.75 37407.20 55778.15
## 2019.2521 45848.84 40206.46 52283.05 37506.33 56046.97
## 2019.2548 45979.99 40293.14 52469.47 37573.21 56267.74
## 2019.2575 46035.71 40313.78 52569.80 37578.54 56396.20
## 2019.2603 46373.22 40581.10 52992.05 37813.81 56870.12
## 2019.2630 46722.63 40858.59 53428.28 38058.44 57359.28
## 2019.2658 46406.31 40554.05 53103.09 37761.00 57030.94
## 2019.2685 46507.62 40614.76 53255.48 37803.83 57215.34
## 2019.2712 46802.82 40844.72 53630.05 38004.16 57638.54
## 2019.2740 46881.74 40885.87 53756.91 38028.79 57795.62
## 2019.2767 46592.68 40606.37 53461.52 37755.35 57498.56
## 2019.2795 47189.97 41099.32 54183.22 38200.11 58295.48
## 2019.2822 46360.47 40349.91 53266.36 37490.30 57329.31
## 2019.2849 46231.61 40211.02 53153.65 37348.10 57228.13
## 2019.2877 46320.51 40261.69 53291.10 37382.07 57396.23
## 2019.2904 46661.32 40531.22 53718.57 37619.20 57876.80
## 2019.2932 46628.79 40476.42 53716.32 37555.30 57894.46
## 2019.2959 46814.43 40611.05 53965.38 37667.21 58182.99
## 2019.2986 47289.45 40996.49 54548.38 38011.64 58831.78
## 2019.3014 47349.97 41022.42 54653.52 38022.66 58965.35
## 2019.3041 47800.30 41385.93 55208.84 38346.52 59584.78
## 2019.3068 48232.23 41733.14 55743.42 38655.12 60182.15
## 2019.3096 48408.02 41858.53 55982.29 38758.16 60460.46
## 2019.3123 47634.49 41163.50 55122.73 38101.80 59552.16
## 2019.3151 46425.67 40093.53 53757.88 37098.99 58097.08
## 2019.3178 45855.99 39576.62 53131.67 36608.48 57439.48
## 2019.3205 46720.58 40297.54 54167.40 37262.96 58578.63
## 2019.3233 45726.74 39415.70 53048.26 36435.49 57387.31
## 2019.3260 45551.50 39240.24 52877.83 36261.35 57221.78
## 2019.3288 45600.94 39258.51 52968.01 36266.35 57338.16
## 2019.3315 45594.84 39229.07 52993.60 36227.32 57384.59
## 2019.3342 45884.72 39454.23 53363.28 36423.41 57803.69
## 2019.3370 45829.89 39382.99 53332.13 36345.87 57788.66
## 2019.3397 46553.70 39980.62 54207.44 36885.51 58756.05
## 2019.3425 46759.08 40132.64 54479.64 37013.88 59070.06
## 2019.3452 46400.63 39800.93 54094.69 36696.20 58671.44
## 2019.3479 47237.59 40494.45 55103.58 37323.72 59784.75
## 2019.3507 47143.94 40389.95 55027.33 37215.59 59720.98
## 2019.3534 47686.41 40830.31 55693.77 37609.44 60463.38
## 2019.3562 47495.42 40642.58 55503.73 37424.73 60276.04
## 2019.3589 47229.67 40391.23 55225.90 37181.61 59993.15
## 2019.3616 47308.15 40434.45 55350.34 37209.77 60147.13
## 2019.3644 47328.64 40428.18 55406.91 37192.40 60227.36
## 2019.3671 47661.53 40688.67 55829.33 37420.44 60705.36
## 2019.3699 47470.37 40501.82 55637.89 37237.08 60515.91
## 2019.3726 46560.95 39702.80 54603.77 36491.22 59409.42
## 2019.3753 46546.52 39667.48 54618.50 36447.58 59443.68
## 2019.3781 46652.00 39734.42 54773.91 36497.92 59631.05
## 2019.3808 46820.26 39854.78 55003.11 36597.33 59898.83
## 2019.3836 46642.78 39680.94 54826.04 36426.63 59724.13
## 2019.3863 46832.05 39819.20 55079.99 36542.49 60018.92
## 2019.3890 46475.40 39493.46 54691.67 36232.63 59613.75
## 2019.3918 46967.07 39888.62 55301.63 36584.17 60296.71
## 2019.3945 47181.25 40047.86 55585.24 36719.23 60624.10
## 2019.3973 47403.62 40213.94 55878.71 36860.51 60962.35
## 2019.4000 47141.27 39968.93 55600.67 36625.03 60677.06
## 2019.4027 47312.72 40091.84 55834.14 36726.78 60949.89
## 2019.4055 47059.56 39855.08 55566.38 36499.12 60675.52
## 2019.4082 46951.48 39741.45 55469.59 36384.34 60587.66
## 2019.4110 46350.44 39210.97 54789.86 35888.14 59862.77
## 2019.4137 45938.85 38841.31 54333.33 35539.42 59381.33
## 2019.4164 46054.17 38917.39 54499.71 35598.65 59580.54
## 2019.4192 46249.08 39060.66 54760.41 35719.32 59882.93
## 2019.4219 46025.46 38850.53 54525.45 35516.89 59643.25
## 2019.4247 45861.41 38690.96 54360.73 35360.80 59480.24
## 2019.4274 46325.84 39061.54 54941.08 35689.21 60132.54
## 2019.4301 46070.83 38825.48 54668.26 35463.37 59851.10
## 2019.4329 46163.59 38882.65 54807.91 35505.43 60021.15
## 2019.4356 45671.84 38447.76 54253.29 35098.31 59430.71
## 2019.4384 45873.29 38596.62 54521.83 35224.20 59741.85
## 2019.4411 45654.19 38391.73 54290.47 35027.29 59505.18
## 2019.4438 45770.54 38469.05 54457.86 35087.92 59705.50
## 2019.4466 45671.82 38365.68 54369.31 34983.79 59625.20
## 2019.4493 45854.16 38498.44 54615.32 35095.00 59911.80
## 2019.4521 45944.95 38554.28 54752.38 35136.07 60078.96
## 2019.4548 46046.63 38619.25 54902.47 35185.47 60260.46
## 2019.4575 45902.05 38477.78 54758.85 35046.82 60119.53
## 2019.4603 46017.28 38554.16 54925.06 35106.66 60318.74
## 2019.4630 46000.98 38520.39 54934.29 35066.21 60345.56
## 2019.4658 45941.60 38450.64 54891.95 34993.07 60315.67
## 2019.4685 45791.00 38304.70 54740.42 34850.68 60165.70
## 2019.4712 46033.78 38487.87 55059.15 35007.73 60532.61
## 2019.4740 45648.59 38146.12 54626.63 34687.40 60073.50
## 2019.4767 45832.56 38280.15 54875.02 34799.80 60363.11
## 2019.4795 45721.83 38168.07 54770.55 34688.49 60264.55
## 2019.4822 45781.56 38198.37 54870.16 34706.62 60390.52
## 2019.4849 45646.31 38066.10 54736.00 34577.10 60259.13
## 2019.4877 45491.90 37918.03 54578.60 34433.32 60102.04
## 2019.4904 45580.02 37972.20 54712.08 34473.25 60265.22
## 2019.4932 46355.27 38598.52 55670.82 35032.47 61337.70
## 2019.4959 46479.05 38682.06 55847.66 35098.92 61548.98
## 2019.4986 46209.40 38438.29 55551.60 34868.43 61239.01
## 2019.5014 46214.19 38422.99 55585.26 34845.29 61292.40
## 2019.5041 46183.00 38377.83 55575.55 34795.12 61297.93
## 2019.5068 46509.35 38629.74 55996.22 35014.26 61778.24
## 2019.5096 46187.41 38343.25 55636.30 34745.42 61397.34
## 2019.5123 46092.15 38245.17 55549.13 34647.44 61317.25
## 2019.5151 45972.45 38126.97 55432.32 34531.30 61204.36
## 2019.5178 45838.46 37997.07 55298.06 34404.66 61072.09
## 2019.5205 46037.36 38143.15 55565.38 34527.93 61383.32
## 2019.5233 45862.48 37979.60 55381.51 34370.93 61196.12
## 2019.5260 46492.23 38482.24 56169.48 34816.78 62082.92
## 2019.5288 46385.00 38374.72 56067.34 34710.52 61986.06
## 2019.5315 46520.01 38467.66 56257.95 34785.61 62212.85
## 2019.5342 46419.92 38366.23 56164.21 34684.96 62125.18
## 2019.5370 46466.97 38386.50 56248.42 34694.37 62234.30
## 2019.5397 46137.52 38095.90 55876.64 34422.90 61838.79
## 2019.5425 45959.73 37930.79 55688.19 34264.96 61645.99
## 2019.5452 45724.72 37718.67 55430.11 34064.66 61375.93
## 2019.5479 45453.53 37476.96 55127.82 33837.76 61056.74
## 2019.5507 45578.14 37561.71 55305.44 33905.68 61268.99
## 2019.5534 45365.80 37368.85 55074.09 33723.07 61028.13
## 2019.5562 45290.30 37288.88 55008.65 33642.41 60970.99
## 2019.5589 45333.85 37307.00 55087.73 33650.28 61074.02
## 2019.5616 45492.58 37419.87 55306.84 33743.61 61332.33
## 2019.5644 45452.33 37369.08 55284.05 33689.37 61322.43
## 2019.5671 45346.84 37264.76 55181.80 33586.93 61224.30
## 2019.5699 45939.22 37733.78 55928.98 34001.19 62068.76
## 2019.5726 46316.47 38025.78 56414.76 34255.78 62623.45
## 2019.5753 45362.04 37224.75 55278.14 33525.85 61376.96
## 2019.5781 45619.54 37418.56 55617.93 33692.06 61769.52
## 2019.5808 45514.94 37315.35 55516.29 33590.84 61671.88
## 2019.5836 45831.17 37557.13 55928.03 33800.15 62144.57
## 2019.5863 45721.40 37449.79 55819.99 33695.27 62039.77
## 2019.5890 45464.42 37222.05 55531.96 33482.16 61734.78
## 2019.5918 45659.98 37364.89 55796.60 33602.42 62044.16
## 2019.5945 45426.93 37157.04 55537.42 33407.34 61771.03
## 2019.5973 45413.96 37129.35 55547.11 33374.32 61796.85
## 2019.6000 44938.16 36723.49 54990.38 33001.49 61192.35
## 2019.6027 44716.26 36525.42 54743.89 32815.53 60932.83
## 2019.6055 44982.72 36726.29 55095.28 32988.02 61338.78
## 2019.6082 44844.82 36597.01 54951.42 32863.97 61193.38
## 2019.6110 44449.87 36258.21 54492.24 32551.89 60696.66
## 2019.6137 44616.13 36377.32 54720.90 32650.98 60965.99
## 2019.6164 44267.62 36076.82 54318.04 32373.51 60531.67
## 2019.6192 43979.57 35825.88 53988.98 32140.63 60179.35
## 2019.6219 43774.46 35642.72 53761.42 31968.69 59940.00
## 2019.6247 44698.97 36379.12 54921.55 32621.41 61248.05
## 2019.6274 44654.53 36326.64 54891.58 32566.61 61229.17
## 2019.6301 44574.69 36245.46 54817.99 32486.13 61161.58
## 2019.6329 44463.57 36138.95 54705.78 32383.01 61050.83
## 2019.6356 44368.88 36045.91 54613.62 32292.01 60962.37
## 2019.6384 44151.07 35853.00 54369.70 32111.62 60704.40
## 2019.6411 44400.90 36039.87 54701.65 32271.41 61089.38
## 2019.6438 44436.61 36052.87 54769.90 32275.48 61179.95
## 2019.6466 44862.78 36382.54 55319.62 32562.99 61808.48
## 2019.6493 44975.93 36458.22 55483.63 32623.10 62006.20
## 2019.6521 45667.99 37002.92 56362.19 33102.78 63002.72
## 2019.6548 45705.28 37016.86 56433.00 33107.56 63096.55
## 2019.6575 45804.38 37080.87 56580.16 33157.10 63275.78
## 2019.6603 45821.70 37078.65 56626.32 33147.44 63342.07
## 2019.6630 46071.55 37264.56 56959.96 33305.94 63730.01
## 2019.6658 45913.49 37120.53 56789.28 33169.56 63553.70
## 2019.6685 45715.06 36944.04 56568.45 33004.25 63321.14
## 2019.6712 45808.75 37003.68 56708.98 33049.94 63493.03
## 2019.6740 45861.22 37030.03 56798.54 33065.89 63607.89
## 2019.6767 46054.74 37170.21 57062.86 33183.48 63918.53
## 2019.6795 45199.64 36464.34 56027.54 32545.88 62773.15
## 2019.6822 45122.96 36386.81 55956.57 32469.28 62707.93
## 2019.6849 45880.07 36981.45 56919.91 32992.39 63802.00
## 2019.6877 45960.66 37030.53 57044.35 33028.68 63956.00
## 2019.6904 45640.75 36757.05 56671.54 32777.33 63552.42
## 2019.6932 46167.38 37165.29 57349.93 33133.88 64327.72
## 2019.6959 46096.06 37092.06 57285.75 33061.13 64270.23
## 2019.6986 46283.76 37227.26 57543.49 33174.17 64573.94
## 2019.7014 46895.56 37703.33 58328.88 33590.85 65470.00
## 2019.7041 46586.18 37438.73 57968.64 33347.63 65080.25
## 2019.7068 46482.48 37339.59 57864.07 33251.88 64977.39
## 2019.7096 46600.89 37418.91 58035.97 33315.07 65184.99
## 2019.7123 46304.22 37165.04 57690.81 33081.67 64811.76
## 2019.7151 46172.18 37043.48 57550.48 32966.12 64668.52
## 2019.7178 46375.64 37191.10 57828.35 33090.14 64995.19
## 2019.7205 46510.90 37283.95 58021.32 33165.40 65226.53
## 2019.7233 46542.95 37294.05 58085.59 33167.04 65313.24
## 2019.7260 45985.26 36831.80 57413.53 32748.71 64571.83
## 2019.7288 46176.18 36969.32 57675.93 32863.73 64881.24
## 2019.7315 46008.21 36819.53 57490.02 32723.37 64686.35
## 2019.7342 45631.79 36503.13 57043.34 32435.05 64197.85
## 2019.7370 45384.45 36290.23 56757.64 32238.81 63890.33
## 2019.7397 45956.37 36732.36 57496.65 32624.44 64736.38
## 2019.7425 46166.26 36884.90 57783.09 32752.76 65073.10
## 2019.7452 46169.61 36872.39 57811.10 32734.51 65118.84
## 2019.7479 46053.70 36764.70 57689.68 32631.80 64996.21
## 2019.7507 45625.53 36407.94 57176.79 32308.13 64432.37
## 2019.7534 45778.21 36514.81 57391.63 32395.94 64688.50
## 2019.7562 45850.31 36557.37 57505.53 32426.67 64830.91
## 2019.7589 45563.90 36314.18 57169.64 32204.00 64466.17
## 2019.7616 45298.96 36088.32 56860.40 31996.80 64131.28
## 2019.7644 45256.56 36039.88 56830.28 31946.97 64111.12
## 2019.7671 45192.48 35974.24 56772.86 31881.93 64060.11
## 2019.7699 45541.65 36237.50 57234.70 32108.36 64595.09
## 2019.7726 45553.66 36232.39 57272.96 32096.95 64652.11
## 2019.7753 45600.30 36254.83 57354.75 32109.97 64758.29
## 2019.7781 45494.56 36156.19 57244.84 32015.78 64647.99
## 2019.7808 45343.99 36022.03 57078.35 31890.18 64473.70
## 2019.7836 45279.16 35956.07 57019.64 31825.02 64421.08
## 2019.7863 45271.02 35935.20 57032.26 31799.79 64449.02
## 2019.7890 44971.21 35682.92 56677.25 31569.86 64061.42
## 2019.7918 45528.75 36110.87 57402.84 31941.72 64895.28
## 2019.7945 45491.14 36066.65 57378.32 31895.87 64881.26
## 2019.7973 45474.39 36039.02 57380.05 31864.71 64896.89
## 2019.8000 45518.89 36059.94 57459.04 31876.50 64999.91
## 2019.8027 45473.50 36009.68 57424.53 31825.38 64974.52
## 2019.8055 45332.98 35884.19 57269.77 31707.82 64813.01
## 2019.8082 45267.17 35817.92 57209.26 31642.64 64758.09
## 2019.8110 45174.80 35730.72 57115.07 31559.00 64664.99
## 2019.8137 44806.36 35425.33 56671.58 31282.74 64176.27
## 2019.8164 45331.82 35826.67 57358.76 31630.56 64967.98
## 2019.8192 45323.65 35806.15 57370.97 31605.86 64995.33
## 2019.8219 45111.33 35624.43 57124.61 31438.93 64729.67
## 2019.8247 44913.72 35454.49 56896.66 31282.47 64484.74
## 2019.8274 44805.83 35355.50 56782.18 31188.67 64368.32
## 2019.8301 44965.42 35467.58 57006.68 31281.08 64636.16
## 2019.8329 44701.36 35245.56 56694.00 31078.85 64294.90
## 2019.8356 44373.43 34973.39 56299.99 30832.51 63861.22
## 2019.8384 44370.08 34957.17 56317.61 30811.87 63894.35
## 2019.8411 44560.18 35093.33 56580.84 30925.53 64206.17
## 2019.8438 44454.74 34996.73 56468.81 30834.09 64092.17
## 2019.8466 44610.67 35105.91 56688.79 30923.96 64355.02
## 2019.8493 44416.27 34939.45 56463.54 30771.03 64112.41
## 2019.8521 44234.09 34782.73 56253.62 30626.77 63887.08
## 2019.8548 44317.30 34834.76 56381.13 30666.33 64044.92
## 2019.8575 43393.16 34095.26 55226.63 30009.22 62746.26
## 2019.8603 43145.98 33888.04 54933.10 29820.79 62425.43
## 2019.8630 42329.52 33234.05 53914.24 29239.36 61280.02
## 2019.8658 42430.78 33300.82 54063.87 29292.17 61462.53
## 2019.8685 42618.75 33435.58 54324.11 29404.77 61770.86
## 2019.8712 42575.75 33389.12 54289.98 29357.99 61744.51
## 2019.8740 42898.14 33629.15 54721.88 29563.08 62248.25
## 2019.8767 43127.14 33795.83 55034.90 29703.64 62616.91
## 2019.8795 43099.49 33761.35 55020.48 29667.38 62613.08
## 2019.8822 43072.72 33727.61 55007.13 29631.79 62610.44
## 2019.8849 43143.88 33770.56 55118.85 29663.58 62750.15
## 2019.8877 43090.94 33716.39 55072.00 29610.09 62709.35
## 2019.8904 42901.07 33555.18 54850.00 29462.62 62469.03
## 2019.8932 42991.86 33613.54 54986.78 29507.99 62637.29
## 2019.8959 43307.55 33847.64 55411.37 29707.59 63133.50
## 2019.8986 43515.53 33997.43 55698.37 29833.13 63473.11
## 2019.9014 43379.89 33878.77 55545.56 29723.10 63311.53
## 2019.9041 43689.58 34107.87 55963.03 29918.18 63800.00
## 2019.9068 43873.34 34238.53 56219.40 30026.85 64104.94
## 2019.9096 43470.54 33911.54 55724.04 29734.22 63552.64
## 2019.9123 43522.22 33939.22 55811.07 29752.62 63664.45
## 2019.9151 43459.62 33877.80 55751.51 29692.93 63609.03
## 2019.9178 43694.87 34048.54 56074.12 29836.71 63989.68
## 2019.9205 43814.78 34129.32 56248.85 29901.64 64201.68
## 2019.9233 44131.80 34363.54 56676.82 30100.94 64702.83
## 2019.9260 44190.01 34396.15 56772.55 30123.61 64824.80
## 2019.9288 44161.47 34361.25 56756.82 30087.16 64819.51
## 2019.9315 44078.55 34284.10 56671.14 30013.75 64734.29
## 2019.9342 43903.06 34135.03 56466.28 29877.43 64512.85
## 2019.9370 44082.03 34261.59 56717.31 29982.37 64812.25
## 2019.9397 44147.60 34299.97 56822.53 30010.13 64945.10
## 2019.9425 43967.86 34147.81 56611.92 29871.21 64716.94
## 2019.9452 43914.70 34094.04 56564.16 29818.40 64674.87
## 2019.9479 44031.08 34171.91 56734.79 29880.72 64882.51
## 2019.9507 44044.56 34169.90 56772.86 29873.20 64938.59
## 2019.9534 43875.28 34026.18 56575.27 29741.81 64725.05
## 2019.9562 44223.66 34283.88 57045.24 29961.29 65275.30
## 2019.9589 44557.72 34530.31 57497.04 30170.85 65804.93
## 2019.9616 44016.58 34098.58 56819.36 29787.90 65041.81
## 2019.9644 44343.86 34339.67 57262.57 29992.77 65561.73
## 2019.9671 44866.49 34731.83 57958.42 30329.48 66371.15
## 2019.9699 44560.11 34482.20 57583.43 30105.73 65954.34
## 2019.9726 45049.08 34848.01 58236.31 30419.30 66714.86
## 2019.9753 44952.78 34760.99 58132.75 30337.56 66608.93
## 2019.9781 44923.57 34725.91 58115.87 30301.17 66602.27
## 2019.9808 44924.17 34713.91 58137.53 30284.94 66639.75
## 2019.9836 44928.27 34704.63 58163.70 30271.09 66682.41
## 2019.9863 44637.86 34467.95 57808.44 30058.96 66287.69
## 2019.9890 45119.80 34827.63 58453.48 30366.88 67040.04
## 2019.9918 45229.81 34900.08 58616.93 30424.29 67240.21
## 2019.9945 45721.87 35267.18 59275.77 30738.50 68008.81
## 2019.9973 45376.96 34988.67 58849.57 30490.01 67532.55
ets_plot <- autoplot(ets_forcast, series = "ETS", fcol = "red") +
autolayer(data_ts, series = "Actual", color = "black") +
labs(subtitle = "Unilever Stock Price, from Jan 2015 - Dec 2018",
y = "Closing Price") +
theme_minimal()
ets_plotarima_forcast## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2019.0000 43031.78 42404.20 43668.64 42075.69 44009.59
## 2019.0027 43102.49 42251.30 43970.83 41807.53 44437.56
## 2019.0055 43124.80 42090.01 44185.02 41552.32 44756.78
## 2019.0082 42446.45 41293.06 43632.06 40695.23 44273.04
## 2019.0110 42629.32 41361.76 43935.73 40706.08 44643.43
## 2019.0137 43397.30 42012.99 44827.23 41298.15 45603.16
## 2019.0164 43158.74 41700.47 44668.00 40948.57 45488.20
## 2019.0192 43277.63 41742.14 44869.60 40951.48 45735.91
## 2019.0219 43333.68 41729.33 44999.72 40904.22 45907.44
## 2019.0247 42998.35 41344.96 44717.85 40495.61 45655.76
## 2019.0274 42883.91 41177.53 44661.01 40301.89 45631.37
## 2019.0301 42840.12 41081.27 44674.29 40179.61 45676.81
## 2019.0329 43027.31 41208.90 44925.96 40277.61 45964.73
## 2019.0356 42721.38 40866.57 44660.39 39917.51 45722.21
## 2019.0384 42819.84 40913.15 44815.40 39938.41 45909.16
## 2019.0411 43084.51 41119.74 45143.16 40116.18 46272.47
## 2019.0438 43177.57 41163.58 45290.10 40135.75 46449.93
## 2019.0466 42924.14 40878.51 45072.13 39835.39 46252.38
## 2019.0493 43497.63 41381.78 45721.67 40303.70 46944.67
## 2019.0521 43324.44 41175.31 45585.73 40081.14 46830.18
## 2019.0548 43821.47 41606.48 46154.38 40479.62 47439.21
## 2019.0575 43720.37 41470.24 46092.58 40326.36 47400.02
## 2019.0603 43795.90 41502.40 46216.15 40337.32 47551.04
## 2019.0630 44248.84 41892.49 46737.74 40696.34 48111.46
## 2019.0658 44511.29 42102.32 47058.09 40880.32 48464.75
## 2019.0685 44292.29 41857.41 46868.81 40623.12 48292.86
## 2019.0712 44559.34 42072.43 47193.24 40812.63 48650.00
## 2019.0740 44503.61 41983.13 47175.40 40707.18 48654.09
## 2019.0767 44302.71 41757.68 47002.86 40470.14 48498.23
## 2019.0795 44597.26 41999.69 47355.49 40686.43 48884.01
## 2019.0822 44361.11 41742.39 47144.12 40419.29 48687.35
## 2019.0849 44240.48 41594.57 47054.69 40258.59 48616.20
## 2019.0877 44542.22 41844.22 47414.17 40482.78 49008.71
## 2019.0904 45151.81 42382.85 48101.68 40986.46 49740.47
## 2019.0932 45673.72 42838.78 48696.27 41409.99 50376.46
## 2019.0959 45577.18 42714.78 48631.41 41273.01 50330.22
## 2019.0986 45695.31 42792.36 48795.19 41331.05 50520.40
## 2019.1014 45545.57 42619.53 48672.49 41147.46 50413.77
## 2019.1041 45731.42 42761.11 48908.05 41267.64 50678.04
## 2019.1068 45600.26 42606.61 48804.25 41102.27 50590.49
## 2019.1096 45713.94 42681.26 48962.10 41158.17 50773.99
## 2019.1123 46180.85 43085.67 49498.38 41532.07 51349.99
## 2019.1151 46047.92 42930.56 49391.63 41366.70 51258.88
## 2019.1178 46104.29 42952.34 49487.54 41371.99 51377.90
## 2019.1205 46027.30 42850.22 49439.95 41258.13 51347.77
## 2019.1233 46053.06 42844.10 49502.37 41236.91 51431.71
## 2019.1260 45601.02 42394.07 49050.58 40788.73 50981.07
## 2019.1288 45939.43 42679.26 49448.63 41048.15 51413.54
## 2019.1315 45926.19 42637.85 49468.14 40993.52 51452.41
## 2019.1342 46214.82 42876.80 49812.70 41208.50 51829.34
## 2019.1370 46224.64 42857.18 49856.70 41175.03 51893.53
## 2019.1397 45983.56 42605.35 49629.64 40918.69 51675.36
## 2019.1425 46354.06 42920.35 50062.47 41206.85 52144.22
## 2019.1452 46191.30 42741.73 49919.28 41021.17 52013.05
## 2019.1479 45974.83 42513.88 49717.52 40788.51 51820.59
## 2019.1507 46244.96 42736.22 50041.78 40987.89 52176.30
## 2019.1534 46591.26 43028.82 50448.63 41254.60 52618.25
## 2019.1562 46348.90 42777.95 50217.94 41000.35 52395.16
## 2019.1589 46345.00 42747.53 50245.21 40957.61 52441.03
## 2019.1616 46465.06 42831.61 50406.73 41024.65 52626.94
## 2019.1644 46805.03 43118.36 50806.90 41285.80 53062.08
## 2019.1671 47289.49 43537.98 51364.27 41674.06 53661.59
## 2019.1699 46906.90 43159.47 50979.72 41298.46 53277.00
## 2019.1726 46624.93 42874.12 50703.88 41012.29 53005.67
## 2019.1753 47009.34 43201.69 51152.59 41312.53 53491.73
## 2019.1781 46769.08 42955.31 50921.46 41063.97 53266.82
## 2019.1808 46173.35 42383.09 50302.57 40504.26 52635.90
## 2019.1836 45925.86 42131.17 50062.35 40250.99 52400.82
## 2019.1863 45825.74 42014.80 49982.35 40127.43 52333.25
## 2019.1890 45798.40 41965.41 49981.48 40067.97 52348.39
## 2019.1918 46099.17 42216.71 50338.69 40295.62 52738.58
## 2019.1945 46080.39 42175.38 50346.96 40243.99 52763.21
## 2019.1973 46106.64 42175.44 50404.28 40231.95 52839.17
## 2019.2000 46264.56 42296.01 50605.48 40334.90 53065.95
## 2019.2027 46160.71 42177.40 50520.22 40209.85 52992.28
## 2019.2055 46345.03 42322.21 50750.24 40336.00 53249.27
## 2019.2082 46069.93 42047.68 50476.95 40062.59 52978.06
## 2019.2110 46401.62 42327.09 50868.38 40317.06 53404.46
## 2019.2137 46450.14 42348.16 50949.46 40325.43 53505.09
## 2019.2164 46450.31 42325.26 50977.38 40292.02 53549.84
## 2019.2192 46657.39 42490.96 51232.37 40438.17 53833.11
## 2019.2219 46146.64 42003.20 50698.80 39962.60 53287.63
## 2019.2247 46016.08 41861.97 50582.42 39816.94 53180.36
## 2019.2274 46060.83 41880.39 50658.55 39823.25 53275.41
## 2019.2301 45983.80 41788.24 50600.59 39724.50 53229.36
## 2019.2329 45954.19 41739.37 50594.62 39666.99 53237.90
## 2019.2356 45918.92 41685.52 50582.25 39604.85 53239.63
## 2019.2384 45616.21 41389.16 50274.95 39312.45 52930.77
## 2019.2411 46118.54 41823.30 50854.91 39713.92 53556.04
## 2019.2438 46129.20 41811.42 50892.86 39691.82 53610.61
## 2019.2466 45863.62 41549.41 50625.78 39432.40 53343.73
## 2019.2493 45932.23 41590.37 50727.36 39460.63 53465.19
## 2019.2521 46103.75 41724.52 50942.61 39577.28 53706.47
## 2019.2548 46235.63 41822.77 51114.10 39659.88 53901.66
## 2019.2575 46291.66 41852.44 51201.74 39677.48 54008.43
## 2019.2603 46631.05 42138.23 51602.89 39937.85 54445.96
## 2019.2630 46982.40 42434.64 52017.55 40208.20 54897.91
## 2019.2658 46664.32 42126.50 51690.94 39905.79 54567.49
## 2019.2685 46766.19 42197.70 51829.29 39962.81 54727.80
## 2019.2712 47063.04 42444.75 52183.83 40186.36 55116.45
## 2019.2740 47142.40 42495.60 52297.31 40224.12 55250.57
## 2019.2767 46851.73 42213.09 52000.09 39946.45 54950.68
## 2019.2795 47452.34 42733.59 52692.14 40428.67 55696.24
## 2019.2822 46618.22 41962.24 51790.81 39688.82 54757.45
## 2019.2849 46488.65 41825.59 51671.59 39549.55 54645.25
## 2019.2877 46578.04 41886.06 51795.62 39596.73 54790.23
## 2019.2904 46920.75 42174.23 52201.47 39859.15 55233.41
## 2019.2932 46888.04 42124.93 52189.71 39802.60 55234.78
## 2019.2959 47074.71 42272.76 52422.13 39932.34 55494.56
## 2019.2986 47552.37 42681.72 52978.85 40308.67 56097.81
## 2019.3014 47613.23 42716.42 53071.37 40331.49 56209.65
## 2019.3041 48066.06 43102.68 53600.99 40686.19 56784.53
## 2019.3068 48500.39 43472.07 54110.33 41024.83 57338.16
## 2019.3096 48677.16 43610.43 54332.54 41145.38 57587.65
## 2019.3123 47899.32 42893.90 53488.85 40459.54 56707.16
## 2019.3151 46683.79 41786.31 52155.26 39405.29 55306.69
## 2019.3178 46110.94 41254.81 51538.69 38894.71 54666.01
## 2019.3205 46980.34 42013.63 52534.20 39600.63 55735.29
## 2019.3233 45980.97 41101.37 51439.87 38731.52 54587.30
## 2019.3260 45804.75 40925.48 51265.75 38556.61 54415.46
## 2019.3288 45854.47 40951.58 51344.35 38572.06 54511.79
## 2019.3315 45848.34 40927.87 51360.36 38540.64 54541.65
## 2019.3342 46139.83 41169.81 51709.83 38759.36 54925.67
## 2019.3370 46084.70 41102.44 51670.88 38686.89 54897.14
## 2019.3397 46812.53 41733.21 52510.05 39271.43 55801.71
## 2019.3425 47019.05 41898.94 52764.85 39418.23 56085.50
## 2019.3452 46658.61 41559.59 52383.25 39089.93 55692.76
## 2019.3479 47500.22 42290.80 53351.33 39768.53 56735.08
## 2019.3507 47406.05 42188.67 53268.66 39663.37 56660.18
## 2019.3534 47951.54 42655.68 53904.89 40093.26 57350.03
## 2019.3562 47759.48 42466.55 53712.11 39906.40 57157.95
## 2019.3589 47492.26 42210.83 53434.50 39657.09 56875.44
## 2019.3616 47571.17 42262.91 53546.16 39697.03 57007.19
## 2019.3644 47591.78 42263.21 53592.17 39688.37 57069.04
## 2019.3671 47926.51 42542.42 53992.01 39941.59 57507.74
## 2019.3699 47734.29 42353.88 53798.21 39755.68 57314.14
## 2019.3726 46819.82 41524.99 52789.80 38968.95 56252.38
## 2019.3753 46805.30 41494.68 52795.59 38931.86 56271.05
## 2019.3781 46911.38 41571.33 52937.39 38995.13 56434.67
## 2019.3808 47080.58 41703.87 53150.47 39110.83 56674.35
## 2019.3836 46902.10 41528.52 52971.00 38937.82 56495.39
## 2019.3863 47092.43 41679.78 53207.98 39071.07 56760.58
## 2019.3890 46733.80 41345.30 52824.57 38749.06 56363.89
## 2019.3918 47228.19 41765.51 53405.36 39134.36 56996.00
## 2019.3945 47443.57 41938.78 53670.90 39288.19 57291.83
## 2019.3973 47667.17 42119.23 53945.89 39448.70 57597.83
## 2019.4000 47403.36 41869.07 53669.19 39205.95 57314.74
## 2019.4027 47575.77 42004.29 53886.25 39324.12 57558.92
## 2019.4055 47321.21 41762.64 53619.61 39089.52 57286.37
## 2019.4082 47212.52 41649.93 53518.04 38975.69 57190.06
## 2019.4110 46608.14 41100.22 52854.18 38453.10 56492.67
## 2019.4137 46194.26 40718.94 52405.83 38088.29 56025.34
## 2019.4164 46310.22 40804.85 52558.37 38160.59 56200.30
## 2019.4192 46506.22 40961.23 52801.83 38298.76 56472.53
## 2019.4219 46281.35 40747.00 52567.38 38090.45 56233.60
## 2019.4247 46116.39 40585.70 52400.75 37931.72 56067.09
## 2019.4274 46583.40 40980.54 52952.28 38292.74 56669.05
## 2019.4301 46326.98 40738.93 52681.52 38059.06 56391.01
## 2019.4329 46420.25 40804.95 52808.28 38112.82 56538.44
## 2019.4356 45925.77 40354.51 52266.18 37684.30 55969.63
## 2019.4384 46128.33 40516.71 52517.18 37827.96 56250.01
## 2019.4411 45908.02 40307.53 52286.66 37624.93 56014.62
## 2019.4438 46025.01 40394.60 52440.22 37698.47 56190.65
## 2019.4466 45925.75 40291.92 52347.33 37594.95 56102.59
## 2019.4493 46109.10 40437.21 52576.57 37722.83 56359.76
## 2019.4521 46200.40 40501.71 52700.90 37775.32 56504.52
## 2019.4548 46302.64 40575.81 52837.75 37836.77 56662.74
## 2019.4575 46157.26 40432.97 52691.96 37695.95 56517.81
## 2019.4603 46273.12 40519.04 52844.34 37768.58 56692.68
## 2019.4630 46256.74 40489.32 52845.68 37733.30 56705.51
## 2019.4658 46197.03 40421.75 52797.45 37662.78 56665.10
## 2019.4685 46045.59 40274.04 52644.23 37517.66 56511.95
## 2019.4712 46289.72 40472.34 52943.27 37694.87 56844.29
## 2019.4740 45902.39 40118.63 52519.97 37358.01 56401.00
## 2019.4767 46087.38 40265.24 52751.38 37487.11 56660.73
## 2019.4795 45976.04 40152.97 52643.58 37375.20 56556.11
## 2019.4822 46036.09 40190.46 52731.96 37402.72 56662.23
## 2019.4849 45900.10 40056.86 52595.71 37271.07 56526.92
## 2019.4877 45744.82 39906.58 52437.19 37123.96 56367.60
## 2019.4904 45833.43 39969.12 52558.16 37174.88 56508.68
## 2019.4932 46613.00 40633.98 53471.79 37785.89 57502.19
## 2019.4959 46737.47 40727.53 53634.26 37865.52 57688.12
## 2019.4986 46466.31 40476.41 53342.62 37624.76 57385.56
## 2019.5014 46471.13 40465.83 53367.65 37607.65 57423.59
## 2019.5041 46439.76 40423.79 53351.05 37561.33 57416.80
## 2019.5068 46767.93 40694.66 53747.59 37805.75 57854.68
## 2019.5096 46444.20 40398.32 53394.88 37523.25 57486.05
## 2019.5123 46348.41 40300.43 53304.02 37425.17 57399.21
## 2019.5151 46228.05 40181.29 53184.77 37307.40 57281.73
## 2019.5178 46093.31 40049.77 53048.83 37178.22 57146.19
## 2019.5205 46293.32 40209.13 53298.13 37319.06 57425.65
## 2019.5233 46117.47 40042.06 53114.67 37156.97 57238.82
## 2019.5260 46750.71 40577.40 53863.21 37646.62 58056.45
## 2019.5288 46642.89 40469.41 53758.12 37539.36 57954.10
## 2019.5315 46778.66 40572.80 53933.74 37628.18 58154.35
## 2019.5342 46678.00 40471.16 53836.76 37526.89 58060.67
## 2019.5370 46725.32 40497.88 53910.37 37544.63 58150.93
## 2019.5397 46394.03 40196.57 53547.01 37258.35 57769.77
## 2019.5425 46215.26 40027.60 53359.43 37094.83 57578.11
## 2019.5452 45978.94 39808.96 53105.20 36885.36 57314.42
## 2019.5479 45706.24 39559.01 52808.71 36646.98 57004.98
## 2019.5507 45831.54 39653.62 52971.97 36727.84 57191.78
## 2019.5534 45618.02 39455.14 52743.54 36537.27 56955.65
## 2019.5562 45542.10 39375.80 52674.05 36457.09 56891.08
## 2019.5589 45585.90 39400.01 52742.98 36472.81 56975.98
## 2019.5616 45745.51 39524.30 52945.95 36581.17 57205.70
## 2019.5644 45705.03 39475.71 52917.35 36529.53 57185.24
## 2019.5671 45598.96 39370.55 52812.71 36425.58 57082.56
## 2019.5699 46194.63 39871.16 53520.98 36882.05 57858.60
## 2019.5726 46573.98 40184.82 53978.98 37165.45 58364.30
## 2019.5753 45614.24 39343.30 52884.71 36380.58 57191.48
## 2019.5781 45873.18 39553.15 53203.05 36568.03 57546.12
## 2019.5808 45768.00 39449.04 53099.12 36465.21 57444.05
## 2019.5836 46085.98 39709.65 53486.19 36699.51 57873.18
## 2019.5863 45975.60 39601.13 53376.15 36592.66 57764.47
## 2019.5890 45717.19 39365.25 53094.08 36368.20 57469.49
## 2019.5918 45913.84 39521.25 53340.43 36505.81 57746.44
## 2019.5945 45679.49 39306.32 53086.03 36300.81 57481.26
## 2019.5973 45666.45 39281.91 53088.68 36271.83 57494.34
## 2019.6000 45188.01 38857.35 52550.07 35873.44 56921.11
## 2019.6027 44964.87 38652.55 52308.04 35678.07 56668.97
## 2019.6055 45232.81 38869.93 52637.28 35872.38 57035.73
## 2019.6082 45094.14 38737.88 52493.37 35744.22 56889.80
## 2019.6110 44697.00 38383.98 52048.33 35411.45 56417.40
## 2019.6137 44864.19 38514.80 52260.32 35525.91 56657.11
## 2019.6164 44513.74 38201.32 51869.23 35230.60 56242.96
## 2019.6192 44224.08 37940.23 51548.70 34983.70 55905.16
## 2019.6219 44017.83 37750.86 51325.18 34803.03 55672.44
## 2019.6247 44947.49 38535.50 52426.36 35520.23 56876.78
## 2019.6274 44902.80 38484.58 52391.40 35467.14 56848.70
## 2019.6301 44822.52 38403.22 52314.83 35386.04 56775.45
## 2019.6329 44710.78 38295.00 52201.44 35280.22 56662.17
## 2019.6356 44615.56 38201.00 52107.22 35187.56 56569.65
## 2019.6384 44396.54 38001.12 51868.27 34997.43 56319.92
## 2019.6411 44647.76 38203.77 52178.69 35178.03 56666.70
## 2019.6438 44683.67 38222.13 52237.55 35188.91 56740.33
## 2019.6466 45112.20 38576.24 52755.55 35508.85 57312.78
## 2019.6493 45225.99 38661.08 52905.65 35580.87 57485.66
## 2019.6521 45921.90 39243.36 53737.01 36110.61 58398.91
## 2019.6548 45959.39 39262.80 53798.14 36122.37 58475.28
## 2019.6575 46059.05 39335.34 53932.06 36182.97 58630.78
## 2019.6603 46076.45 39337.63 53969.68 36178.96 58681.61
## 2019.6630 46327.70 39539.52 54281.27 36358.50 59030.37
## 2019.6658 46168.76 39391.33 54112.26 36216.13 58856.48
## 2019.6685 45969.23 39208.64 53895.52 36042.10 58630.59
## 2019.6712 46063.43 39276.54 54023.09 36098.46 58779.23
## 2019.6740 46116.20 39309.09 54102.08 36122.33 58875.04
## 2019.6767 46310.79 39462.50 54347.53 36257.24 59152.03
## 2019.6795 45450.94 38717.60 53355.27 35566.91 58081.74
## 2019.6822 45373.83 38639.76 53281.51 35489.50 58011.09
## 2019.6849 46135.15 39275.76 54192.51 36067.65 59012.77
## 2019.6877 46216.19 39332.43 54304.72 36113.70 59144.76
## 2019.6904 45894.51 39046.45 53943.60 35845.19 58761.18
## 2019.6932 46424.06 39484.66 54583.05 36241.49 59467.56
## 2019.6959 46352.34 39411.39 54515.70 36168.27 59403.98
## 2019.6986 46541.09 39559.57 54754.71 36298.29 59674.24
## 2019.7014 47156.29 40070.05 55495.69 36760.65 60491.73
## 2019.7041 46845.19 39793.38 55146.66 36500.84 60121.13
## 2019.7068 46740.91 39692.53 55040.90 36402.38 60015.65
## 2019.7096 46859.98 39781.37 55198.14 36477.90 60196.94
## 2019.7123 46561.66 39515.95 54863.64 36228.61 59841.89
## 2019.7151 46428.88 39391.15 54724.00 36108.32 59699.30
## 2019.7178 46633.48 39552.60 54982.01 36250.43 59990.51
## 2019.7205 46769.49 39655.81 55159.26 36339.13 60193.65
## 2019.7233 46801.72 39671.02 55214.15 36347.18 60263.30
## 2019.7260 46240.92 39183.70 54569.19 35894.91 59568.98
## 2019.7288 46432.91 39334.41 54812.44 36027.16 59844.17
## 2019.7315 46264.01 39179.42 54629.66 35879.42 59654.20
## 2019.7342 45885.50 38847.08 54199.15 35569.37 59193.60
## 2019.7370 45636.77 38624.81 53921.69 35360.18 58900.01
## 2019.7397 46211.88 39099.73 54617.70 35789.23 59669.84
## 2019.7425 46422.94 39266.46 54883.71 35936.10 59970.03
## 2019.7452 46426.30 39257.48 54904.23 35922.16 60002.01
## 2019.7479 46309.75 39147.15 54782.86 35815.50 59878.90
## 2019.7507 45879.20 38771.56 54289.82 35466.24 59349.44
## 2019.7534 46032.73 38889.65 54487.82 35568.62 59575.33
## 2019.7562 46105.23 38939.25 54589.95 35608.34 59696.45
## 2019.7589 45817.22 38684.46 54265.14 35369.76 59350.64
## 2019.7616 45550.82 38448.07 53965.70 35148.08 59032.44
## 2019.7644 45508.18 38400.65 53931.22 35099.20 59004.02
## 2019.7671 45443.74 38334.89 53870.86 35033.59 58947.24
## 2019.7699 45794.86 38619.63 54303.18 35288.27 59429.63
## 2019.7726 45806.93 38618.38 54333.57 35281.60 59472.20
## 2019.7753 45853.82 38646.50 54405.26 35301.77 59559.99
## 2019.7781 45747.50 38545.53 54295.13 35204.04 59448.70
## 2019.7808 45596.10 38406.65 54131.36 35071.73 59278.63
## 2019.7836 45530.90 38340.46 54069.85 35005.84 59220.48
## 2019.7863 45522.72 38322.33 54076.00 34983.85 59236.42
## 2019.7890 45221.24 38057.38 53733.61 34736.61 58870.48
## 2019.7918 45781.88 38517.94 54415.69 35151.53 59626.99
## 2019.7945 45744.06 38474.89 54386.62 35106.83 59604.35
## 2019.7973 45727.22 38449.52 54382.44 35078.26 59608.96
## 2019.8000 45771.97 38475.95 54451.49 35096.97 59693.84
## 2019.8027 45726.32 38426.42 54412.99 35046.40 59660.81
## 2019.8055 45585.02 38296.57 54260.58 34922.61 59502.83
## 2019.8082 45518.85 38229.91 54197.50 34856.48 59442.76
## 2019.8110 45425.97 38140.88 54102.54 34769.98 59347.69
## 2019.8137 45055.47 37818.89 53676.77 34471.19 58889.63
## 2019.8164 45583.85 38251.38 54321.89 34860.08 59606.50
## 2019.8192 45575.64 38233.50 54327.73 34838.48 59621.98
## 2019.8219 45362.13 38043.46 54088.75 34660.05 59368.73
## 2019.8247 45163.43 37865.96 53867.25 34493.10 59134.59
## 2019.8274 45054.94 37764.19 53753.24 34395.18 59018.36
## 2019.8301 45215.42 37887.88 53960.11 34502.62 59254.46
## 2019.8329 44949.89 37654.64 53658.54 34285.04 58932.19
## 2019.8356 44620.14 37367.76 53280.07 34018.71 58525.35
## 2019.8384 44616.77 37354.32 53291.20 34001.35 58546.39
## 2019.8411 44807.93 37503.71 53534.71 34132.21 58822.76
## 2019.8438 44701.89 37404.36 53423.17 34036.68 58709.00
## 2019.8466 44858.69 37524.94 53625.73 34141.29 58940.43
## 2019.8493 44663.21 37350.87 53407.13 33977.83 58708.95
## 2019.8521 44480.02 37187.18 53203.08 33823.87 58493.38
## 2019.8548 44563.69 37246.64 53318.17 33872.90 58628.65
## 2019.8575 43634.42 36459.69 52221.03 33152.30 57430.78
## 2019.8603 43385.86 36241.83 51938.14 32949.30 57128.16
## 2019.8630 42564.87 35546.05 50969.59 32311.94 56071.15
## 2019.8658 42666.69 35621.11 51105.82 32375.38 56229.34
## 2019.8685 42855.70 35768.92 51346.57 32504.91 56502.58
## 2019.8712 42812.47 35722.86 51309.08 32458.26 56469.67
## 2019.8740 43136.64 35983.33 51711.99 32690.10 56921.50
## 2019.8767 43366.92 36165.36 52002.51 32850.63 57249.71
## 2019.8795 43339.11 36132.14 51983.61 32815.63 57237.32
## 2019.8822 43312.19 36099.68 51965.72 32781.34 57226.03
## 2019.8849 43383.75 36149.31 52065.99 32821.60 57344.85
## 2019.8877 43330.52 36094.98 52016.49 32767.47 57298.71
## 2019.8904 43139.59 35926.01 51801.58 32609.31 57070.32
## 2019.8932 43230.89 35992.12 51925.53 32664.56 57215.22
## 2019.8959 43548.33 36246.43 52321.21 32890.57 57659.61
## 2019.8986 43757.47 36410.50 52586.93 33034.63 57960.87
## 2019.9014 43621.08 36287.05 52437.40 32917.85 57804.46
## 2019.9041 43932.49 36536.09 52826.22 33138.96 58241.53
## 2019.9068 44117.26 36679.72 53062.92 33264.42 58510.96
## 2019.9096 43712.23 36333.04 52590.12 32945.25 57998.00
## 2019.9123 43764.20 36366.31 52667.00 32970.66 58091.18
## 2019.9151 43701.24 36304.11 52605.57 32909.53 58031.79
## 2019.9178 43937.80 36490.71 52904.72 33073.91 58370.20
## 2019.9205 44058.38 36580.91 53064.32 33150.90 58554.70
## 2019.9233 44377.17 36835.60 53462.76 33376.92 59002.84
## 2019.9260 44435.69 36874.20 53547.77 33407.10 59105.13
## 2019.9288 44407.00 36840.42 53527.66 33371.72 59091.39
## 2019.9315 44323.62 36761.32 53441.58 33295.32 59004.80
## 2019.9342 44147.15 36605.09 53243.16 33149.08 58794.11
## 2019.9370 44327.11 36744.42 53474.60 33270.51 59058.10
## 2019.9397 44393.05 36789.19 53568.55 33306.31 59170.27
## 2019.9425 44212.31 36629.57 53364.78 33157.09 58953.57
## 2019.9452 44158.86 36575.47 53314.54 33103.42 58906.44
## 2019.9479 44275.88 36662.59 53470.14 33177.57 59086.73
## 2019.9507 44289.44 36664.01 53500.81 33174.16 59128.99
## 2019.9534 44119.21 36513.35 53309.41 33033.17 58925.78
## 2019.9562 44469.54 36793.46 53747.03 33281.89 59417.89
## 2019.9589 44805.45 37061.53 54167.45 33519.65 59891.10
## 2019.9616 44261.30 36601.70 53523.82 33099.10 59187.79
## 2019.9644 44590.40 36864.06 53936.11 33331.67 59652.09
## 2019.9671 45115.94 37288.65 54586.26 33710.85 60379.62
## 2019.9699 44807.86 37024.22 54227.86 33467.10 59991.58
## 2019.9726 45299.54 37420.59 54837.40 33820.66 60674.40
## 2019.9753 45202.71 37330.75 54734.63 33734.74 60569.15
## 2019.9781 45173.33 37296.66 54713.48 33699.23 60554.19
## 2019.9808 45173.93 37287.34 54728.62 33686.12 60579.39
## 2019.9836 45178.06 37280.94 54748.00 33675.65 60609.28
## 2019.9863 44886.04 37030.24 54408.41 33444.55 60241.70
## 2019.9890 45370.66 37420.23 55010.25 33792.09 60916.53
## 2019.9918 45481.28 37501.65 55158.81 33860.91 61089.50
## 2019.9945 45976.07 37899.72 55773.47 34215.61 61778.80
## 2019.9973 45629.24 37604.00 55367.19 33943.94 61337.25
arima_p <- autoplot(arima_forcast, series = "ARIMA", fcol = "red") +
autolayer(data_ts, series = "Actual", color = "black") +
labs(subtitle = "Unilever Stock Price, from Jan 2015 - Dec 2018",
y = "Closing Price") +
theme_minimal()
arima_pFor the evaluation of prediction accuracy we use root mean squared error (RMSE). that measure the standard deviation of the residuals (prediction errors).
data.frame(ETS = RMSE(ets_forcast$mean, test),
ARIMA = RMSE(arima_forcast$mean, test))From the analysis above, we can conclude that we have successfully forecast the stock price and found ARIMA as the best model with the lowest error (RMSE ~2632.69, although not very different from the ETS model).
The assumptions in the time series are tested to measure whether the residuals obtained from the modeling results are good enough to describe and capture information in the data. Why we use residual data? Because by using residual data, we can get information from the actual data as well as from the prediction results using the model. A good forecasting method produces the following residual values1:
To test those assumption, there are two assumption for a time series analysis:
H0 : residuals are normally distributed H1 : residuals are not normally distributed
For normality test, we want to make sure that the data is normally distributed (p-value > 0.05)
H0 : No autocorrelations in the forecast errors H1 : there is an autocorrelations in the forecast errors
For Autocorrelations test, we want to make sure that the forecast errors has no autocorrelation (p-value > 0.05)
# p-value < 0.05 = reject H0
shapiro.test(arima_forcast$residuals) ##
## Shapiro-Wilk normality test
##
## data: arima_forcast$residuals
## W = 0.96849, p-value < 2.2e-16
hist(arima_forcast$residuals, breaks = 20)plot(arima_forcast$residuals)Box.test(arima_forcast$residuals, type = "Ljung-Box")##
## Box-Ljung test
##
## data: arima_forcast$residuals
## X-squared = 0.0065312, df = 1, p-value = 0.9356
Based on the assumption check, there is no autocorrelation on our forecast residuals (p-value > 0.05). Still, our forecast’s residuals are not distributed normally, therefore the residuals may not be appeared around its mean as seen in the histogram. But, if we inspect the distribution of residuals through a line plot, it is actually resembles the error plot from our time series object decomposition.
In a time series, such errors might emerge from various unpredictable events and is actually quite unavoidable. One strategy to overcome it is to analyze what kinds of unpredictable events that might occur and occurs frequently. This can be done by time series analysis using seasonality adjustment. From that insight, investors could a better buy/hold/sell strategy to deal with the uncertainty in the future.