Data yang dipakai dalam peramalan kali ini adalah data mengenai Tingkat Perubahan Upah Nominal Buruh Nasional 2017 - 2021. Agar memperjelas, sebelumnya diberitahukan mengenai keterangan-keterangan objek yang di pakai :
model.1 : Model yang terbentuk dari double exponential smoothingmodel.2 : Model yang terbentuk dari triple exponential smoothingprediksi.1 : Nilai peramalan dari Model yang terbentuk dari double exponential smoothingprediksi.2 : Nilai peramalan dari Model yang terbentuk dari triple exponential smoothingtk.unhb.data: Data Tingkat Perubahan Upah Nominal Buruh Nasional 2017 - 2021vis.1 : Visualisasi awal dataif (!require(ggplot2)) install.packages("ggplot2")
## Loading required package: ggplot2
if (!require(tidyverse)) install.packages("tidyverse")
## Loading required package: tidyverse
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v tibble 3.1.0 v dplyr 1.0.5
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 1.4.0 v forcats 0.5.1
## v purrr 0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
if (!require(tidyr)) install.packages("tidyr")
if (!require(forecast)) install.packages("forecast")
## Loading required package: forecast
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
if (!require(TSstudio)) install.packages("TSstudio")
## Loading required package: TSstudio
if (!require(plotly)) install.packages("plotly")
## Loading required package: plotly
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
if (!require(readxl)) install.packages("readxl")
## Loading required package: readxl
library(ggplot2)
library(tidyverse)
library(tidyr)
library(forecast)
library(TSstudio)
library(plotly)
library(readxl)
tk.unhb.data <- read_xlsx("data.xlsx")
tk.unhb.data$Bulan <- NULL
head(tk.unhb.data, n = 12)
## # A tibble: 12 x 3
## Tahun time unhb
## <dbl> <dbl> <dbl>
## 1 2017 1 0.77
## 2 2017 2 0.55
## 3 2017 3 0.42
## 4 2017 4 0.33
## 5 2017 5 0.29
## 6 2017 6 0.26
## 7 2017 7 0.18
## 8 2017 8 0.15
## 9 2017 9 0.27
## 10 2017 10 0.25
## 11 2017 11 0.21
## 12 2017 12 0.24
glimpse(tk.unhb.data)
## Rows: 51
## Columns: 3
## $ Tahun <dbl> 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017~
## $ time <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 1~
## $ unhb <dbl> 0.77, 0.55, 0.42, 0.33, 0.29, 0.26, 0.18, 0.15, 0.27, 0.25, 0.21~
tk.unhb <- ts(tk.unhb.data$unhb, start = range(tk.unhb.data$time)[1], frequency = 12)
head(tk.unhb)
## Jan Feb Mar Apr May Jun
## 1 0.77 0.55 0.42 0.33 0.29 0.26
tk.unhb
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
## 1 0.77 0.55 0.42 0.33 0.29 0.26 0.18 0.15 0.27 0.25 0.21 0.24
## 2 1.07 0.52 0.43 0.52 0.36 0.28 0.34 0.24 0.30 0.31 0.24 0.19
## 3 1.03 0.33 0.17 0.15 0.19 0.18 0.16 0.22 0.13 0.17 0.25 0.13
## 4 0.59 0.23 0.15 0.12 0.14 0.19 0.20 0.12 0.08 0.09 0.15 0.13
## 5 0.46 0.35 0.17
Keterangan frequency = 12 berarti dalam 1 tahun ada 12 bulan
vis.1 <- tk.unhb.data %>%
ggplot(aes(x = time, y = unhb))+
geom_line()+
labs(title = "Data Tingkat UNHB", y = "", x = "Waktu",
caption = "SUmber : BPS")+
theme(plot.title = element_text(hjust = 0.5),
plot.caption = element_text(size = 8, face = "italic"))
ggplotly(vis.1)
decompose(tk.unhb) %>%
autoplot()
Interpretasi
Dari visualisasi yang terbentuk, dapat dilihat bahwa data memiliki trend yang turun. Selain itu, jika kita lihat, data tersebut juga memiliki sifat seasonal atau musiman. Sehingga coba nanti kita lihat lebih akurat mana antara metode double exponential smoothing atau triple exponential smoothing (holt winter).
model.1 <- HoltWinters(tk.unhb, gamma = F)
model.1
## Holt-Winters exponential smoothing with trend and without seasonal component.
##
## Call:
## HoltWinters(x = tk.unhb, gamma = F)
##
## Smoothing parameters:
## alpha: 0.5445657
## beta : 0.2408308
## gamma: FALSE
##
## Coefficients:
## [,1]
## a 0.26966141
## b 0.01306575
Diperoleh :
model.2 <- HoltWinters(tk.unhb)
model.2
## Holt-Winters exponential smoothing with trend and additive seasonal component.
##
## Call:
## HoltWinters(x = tk.unhb)
##
## Smoothing parameters:
## alpha: 0.2947187
## beta : 0.01641693
## gamma: 1
##
## Coefficients:
## [,1]
## a 0.255816626
## b 0.002292012
## s1 -0.094178934
## s2 -0.058511607
## s3 -0.023816954
## s4 -0.035833768
## s5 -0.106323883
## s6 -0.151440439
## s7 -0.136959859
## s8 -0.080944208
## s9 -0.134302073
## s10 0.244214379
## s11 0.095035195
## s12 -0.085816626
Diperoleh :
Setelah didapatkan model di atas, dilakukanlah permalan untuk 9 bulan ke depan di tahun 2021.
prediksi.1 <- forecast(object = model.1, h = 9)
prediksi.1
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Apr 5 0.2827272 -0.02659746 0.5920518 -0.1903440 0.7557983
## May 5 0.2957929 -0.07752862 0.6691144 -0.2751531 0.8667389
## Jun 5 0.3088586 -0.14020736 0.7579247 -0.3779285 0.9956458
## Jul 5 0.3219244 -0.21272233 0.8565711 -0.4957472 1.1395960
## Aug 5 0.3349901 -0.29367581 0.9636561 -0.6264715 1.2964517
## Sep 5 0.3480559 -0.38206259 1.0781743 -0.7685640 1.4646757
## Oct 5 0.3611216 -0.47714734 1.1993906 -0.9209001 1.6431434
## Nov 5 0.3741874 -0.57837651 1.3267513 -1.0826334 1.8310081
## Dec 5 0.3872531 -0.68532026 1.4598265 -1.2531063 2.0276125
Keterangan :
Nilai prediksi 9 bulan (April - December 2021) dengan metode double exponential smoothing bisa dilihat pada Point Forecast
prediksi.2 <- forecast(object = model.2, h = 9)
prediksi.2
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Apr 5 0.1639297 0.021344448 0.3065150 -0.054135628 0.3819950
## May 5 0.2018890 0.053043799 0.3507343 -0.025750115 0.4295282
## Jun 5 0.2388757 0.083831626 0.3939198 0.001756247 0.4759952
## Jul 5 0.2291509 0.067959130 0.3903427 -0.017370642 0.4756725
## Aug 5 0.1609528 -0.006344007 0.3282496 -0.094905589 0.4168112
## Sep 5 0.1181283 -0.055238176 0.2914947 -0.147012825 0.3832693
## Oct 5 0.1349009 -0.044506049 0.3143078 -0.139478326 0.4092800
## Nov 5 0.1932085 0.007784894 0.3786321 -0.090372443 0.4767895
## Dec 5 0.1421427 -0.049278660 0.3335640 -0.150610988 0.4348963
Keterangan :
Nilai prediksi 9 bulan (April - December 2021) dengan metode triple exponential smoothing bisa dilihat pada Point Forecast
accuracy(model.1$fitted[,1], tk.unhb)
## ME RMSE MAE MPE MAPE ACF1 Theil's U
## Test set 0.0362677 0.241629 0.1593001 -1.908503 55.17488 -0.008685728 1.088782
Interpretasi :
Prediksi nilai tingkat perubahan upah nominal buruh nasional dengan metode double exponential smoothing memiliki tingkat kesalahan sebesar 0.241629 dilihat dari nilai RMSE.
accuracy(model.2$fitted[,1], tk.unhb)
## ME RMSE MAE MPE MAPE ACF1
## Test set -0.02068201 0.1117546 0.07318068 -8.017759 31.68158 0.1396902
## Theil's U
## Test set 0.6565907
Interpretasi :
Prediksi nilai tingkat perubahan upah nominal buruh nasional dengan metode triple exponential smoothing memiliki tingkat kesalahan sebesar 0.1117546 dilihat dari nilai RMSE.
Plot hasil prediksi didasarkan pada 9 data terakhir dari data series tk.unhb
train <- tk.unhb %>% head(-9)
test <- tk.unhb %>% tail(9)
autoplot(prediksi.1)+autolayer(test)
autoplot(prediksi.2)+autolayer(test)