Tugas Individu MPDW
Input Data
data <- read.csv("C:/Users/M Irsyad Robbani/Downloads/powerconsumption.csv/powerconsumption.csv")
data <- data[,c(2,3)]
str(data)## 'data.frame': 52416 obs. of 2 variables:
## $ Temperature: num 6.56 6.41 6.31 6.12 5.92 ...
## $ Humidity : num 73.8 74.5 74.5 75 75.7 76.9 77.7 78.2 78.1 77.3 ...
colnames(data)[1] <- "Xt"
colnames(data)[2] <- "Yt"
# Train test split
train <- data[1:3456, ]
test <- data[3457:4320, ]
# Time-Series Object
train.ts<-ts(train)
test.ts<-ts(test)
data.ts<-ts(data)Data yang digunakan adalah data temperatur dan kelembaban udara di Kota Tetouan Moroko pada bulan Januari 2017, data diukur setiap 10 menit selama 3 hari. Diasumsikan temperatur mempengaruhi tingkat kelembaban udara
Eksplorasi Data
plot(y = data$Xt[1:3456], x = c(1:3456), col = "steelblue", pch = 16, cex = .8, main = "Time-Series Plot Temperatur", xlab = "Suhu (Celcius)", ylab = "", lwd = 0.5, type = "l")plot(y = data$Yt[1:3456], x = c(1:3456), col = "steelblue", pch = 16, cex = .8, main = "Time-Series Plot Kelembaban", xlab = "Kelembaban", ylab = "", lwd = 0.5, type = "l") Dari plot time series diatas terlihat bahwa kedua peubah memiliki pola data yang cenderung stasioner
Model KOYCK
model.koyck = dLagM::koyckDlm(x = train$Xt, y = train$Yt)
summary(model.koyck)##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.9682 -0.5271 0.0552 0.6083 11.9296
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.195356 0.227838 0.857 0.391
## Y.1 0.995004 0.002202 451.960 <2e-16 ***
## X.t 0.011809 0.008750 1.350 0.177
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.324 on 3452 degrees of freedom
## Multiple R-Squared: 0.9872, Adjusted R-squared: 0.9872
## Wald test: 1.33e+05 on 2 and 3452 DF, p-value: < 2.2e-16
##
## Diagnostic tests:
## NULL
##
## alpha beta phi
## Geometric coefficients: 39.10336 0.01180861 0.9950041
AIC(model.koyck)## [1] 11746.85
BIC(model.koyck)## [1] 11771.44
# Ramalan
(fore.koyck <- forecast(model = model.koyck, x = test$Xt, h = 864))## $forecasts
## [1] 71.30655 71.21236 71.11821 71.02388 70.92772 70.82940 70.73057 70.63438
## [9] 70.54125 70.44877 70.35689 70.26680 70.17775 70.08905 69.99558 69.90066
## [17] 69.80654 69.71131 69.61398 69.51521 69.41584 69.31561 69.21646 69.11856
## [25] 69.01851 68.91925 68.81697 68.71779 68.61900 68.51805 68.41292 68.30483
## [33] 68.19958 68.09768 67.99751 67.89944 67.80037 67.70161 67.60104 67.50065
## [41] 67.40163 67.30321 67.20557 67.10894 67.01580 66.92380 66.83173 66.74117
## [49] 66.65086 66.56037 66.46789 66.37646 66.28594 66.20025 66.11279 66.02661
## [57] 65.94613 65.86782 65.79456 65.72329 65.65871 65.60018 65.54724 65.50298
## [65] 65.46320 65.42397 65.38753 65.35659 65.33278 65.31652 65.30660 65.30487
## [73] 65.31178 65.32491 65.34211 65.36595 65.40278 65.44935 65.50017 65.55546
## [81] 65.61473 65.67653 65.73874 65.80252 65.86905 65.93608 66.00537 66.07656
## [89] 66.14905 66.22188 66.29600 66.37176 66.44950 66.52874 66.61090 66.69063
## [97] 66.76891 66.84856 66.92971 67.01187 67.09420 67.17424 67.25400 67.33087
## [105] 67.40288 67.46862 67.52907 67.58568 67.64213 67.69829 67.74957 67.79681
## [113] 67.84027 67.88068 67.91841 67.95442 67.98836 68.01823 68.04511 68.06868
## [121] 68.08847 68.10284 68.11301 68.12029 68.12530 68.12390 68.11566 68.10734
## [129] 68.09977 68.09142 68.08039 68.06776 68.05343 68.03491 68.00669 67.97683
## [137] 67.94748 67.92158 67.89097 67.85768 67.82633 67.79230 67.75915 67.72321
## [145] 67.68320 67.64232 67.60000 67.55541 67.51128 67.46595 67.42026 67.37219
## [153] 67.32614 67.28068 67.23473 67.18464 67.13351 67.08357 67.03589 66.98821
## [161] 66.94019 66.88803 66.83495 66.78202 66.72711 66.68085 66.62928 66.57466
## [169] 66.52539 66.47413 66.42170 66.36977 66.31822 66.26787 66.21322 66.15973
## [177] 66.11041 66.05680 65.99911 65.94189 65.88517 65.82858 65.77153 65.71496
## [185] 65.65739 65.59977 65.54435 65.48863 65.43311 65.37766 65.32167 65.26579
## [193] 65.20758 65.14751 65.08784 65.03167 64.97298 64.91561 64.85944 64.80513
## [201] 64.75100 64.69975 64.65110 64.60407 64.56122 64.52508 64.49408 64.47044
## [209] 64.45305 64.44332 64.43953 64.44143 64.45088 64.46878 64.49475 64.52743
## [217] 64.56620 64.61317 64.66699 64.72609 64.78867 64.85531 64.92433 64.99573
## [225] 65.06948 65.14440 65.21930 65.29583 65.37493 65.45399 65.53620 65.61906
## [233] 65.70246 65.78673 65.87035 65.95567 66.04022 66.12564 66.21134 66.29697
## [241] 66.38099 66.46636 66.55001 66.62190 66.68812 66.75212 66.81485 66.87503
## [249] 66.93431 66.99378 67.05247 67.11016 67.16615 67.21252 67.25111 67.28407
## [257] 67.31191 67.33654 67.35645 67.37365 67.38793 67.40215 67.40790 67.41009
## [265] 67.41652 67.41653 67.41159 67.41896 67.43207 67.44783 67.46127 67.47028
## [273] 67.47440 67.47436 67.47055 67.46321 67.45390 67.44263 67.42811 67.41201
## [281] 67.39647 67.37864 67.35995 67.34372 67.32698 67.31020 67.28808 67.26311
## [289] 67.23366 67.20330 67.17486 67.14621 67.11983 67.09134 67.05909 67.02417
## [297] 66.98942 66.95721 66.92280 66.88596 66.84919 66.81165 66.77277 66.73243
## [305] 66.68981 66.64670 66.60663 66.56653 66.52581 66.48540 66.44402 66.40272
## [313] 66.36081 66.31804 66.27536 66.23302 66.18759 66.14049 66.09622 66.04721
## [321] 65.99798 65.95018 65.90474 65.86141 65.81771 65.77104 65.72331 65.67416
## [329] 65.62235 65.57253 65.52566 65.48069 65.43193 65.38156 65.33223 65.28336
## [337] 65.23641 65.19017 65.14122 65.09294 65.04647 65.00330 64.95606 64.90773
## [345] 64.86159 64.82041 64.77872 64.73654 64.70105 64.67201 64.64724 64.62827
## [353] 64.61482 64.60805 64.60958 64.61866 64.63549 64.66133 64.69259 64.73302
## [361] 64.77927 64.82742 64.88040 64.93749 64.99784 65.06319 65.13130 65.20095
## [369] 65.27226 65.34652 65.42171 65.49794 65.57461 65.65150 65.72941 65.80835
## [377] 65.88749 65.96518 66.04318 66.12091 66.19979 66.27827 66.35671 66.43524
## [385] 66.51432 66.59324 66.67094 66.74707 66.82222 66.89642 66.96882 67.03933
## [393] 67.10677 67.17175 67.23439 67.29389 67.35002 67.40221 67.44989 67.49379
## [401] 67.53428 67.57149 67.60593 67.63771 67.66720 67.69502 67.72246 67.74374
## [409] 67.76338 67.78528 67.80494 67.82321 67.84104 67.85641 67.86569 67.86677
## [417] 67.86654 67.86526 67.86492 67.86860 67.87699 67.88593 67.89222 67.90013
## [425] 67.90506 67.90523 67.89927 67.88825 67.87304 67.85661 67.83683 67.81550
## [433] 67.79522 67.78189 67.76910 67.75921 67.74913 67.73296 67.71522 67.69497
## [441] 67.67388 67.64876 67.61833 67.58345 67.55075 67.52270 67.49373 67.46337
## [449] 67.43481 67.41100 67.39215 67.36903 67.34980 67.33492 67.32046 67.30797
## [457] 67.29106 67.27269 67.25134 67.23294 67.21840 67.20430 67.19097 67.17522
## [465] 67.16806 67.16554 67.16398 67.16396 67.16312 67.16145 67.15861 67.15590
## [473] 67.15297 67.15277 67.15292 67.15213 67.15052 67.14785 67.14448 67.13948
## [481] 67.13262 67.12851 67.12984 67.12952 67.12920 67.12853 67.12928 67.12719
## [489] 67.12735 67.12976 67.13440 67.14374 67.15858 67.17642 67.19547 67.21548
## [497] 67.24095 67.26888 67.29904 67.33248 67.37035 67.41311 67.45801 67.50470
## [505] 67.55470 67.60823 67.66397 67.72097 67.77839 67.83706 67.89603 67.95506
## [513] 68.01603 68.07682 68.13707 68.19726 68.25690 68.31732 68.37778 68.43735
## [521] 68.49698 68.55749 68.61652 68.67325 68.72910 68.78645 68.84374 68.89992
## [529] 68.95559 69.01204 69.06584 69.11926 69.16946 69.21787 69.26557 69.31067
## [537] 69.35413 69.39501 69.43450 69.47262 69.50972 69.54521 69.58018 69.61213
## [545] 69.64145 69.66743 69.69115 69.71311 69.73389 69.75209 69.76795 69.78185
## [553] 69.79532 69.80896 69.82229 69.83415 69.84346 69.85166 69.85853 69.86016
## [561] 69.86391 69.86941 69.87406 69.87964 69.88671 69.89151 69.89251 69.89185
## [569] 69.89166 69.88982 69.88918 69.88641 69.87893 69.87396 69.86336 69.84985
## [577] 69.83322 69.81373 69.79799 69.78044 69.75979 69.74338 69.72705 69.70608
## [585] 69.68202 69.65762 69.63451 69.61258 69.59372 69.57613 69.56016 69.54510
## [593] 69.53129 69.51980 69.50884 69.49982 69.50466 69.51657 69.53443 69.55127
## [601] 69.56117 69.56830 69.55993 69.54652 69.53141 69.51732 69.50377 69.48841
## [609] 69.47512 69.45718 69.44003 69.42238 69.40341 69.38393 69.36491 69.34350
## [617] 69.32161 69.30196 69.28181 69.26460 69.24416 69.22159 69.20220 69.18267
## [625] 69.16607 69.14943 69.13477 69.12101 69.10696 69.09204 69.08168 69.09239
## [633] 69.11332 69.13910 69.16653 69.19430 69.22204 69.25236 69.28418 69.31643
## [641] 69.34971 69.38399 69.41811 69.45631 69.49620 69.53720 69.57893 69.62235
## [649] 69.66567 69.71078 69.75684 69.80291 69.84875 69.89625 69.94847 70.00350
## [657] 70.05826 70.11345 70.16766 70.22077 70.27243 70.32183 70.36968 70.41765
## [665] 70.46644 70.51688 70.56541 70.61275 70.65762 70.70179 70.74408 70.78463
## [673] 70.82414 70.86406 70.90341 70.94269 70.97918 71.01595 71.05361 71.09131
## [681] 71.12693 71.16120 71.19446 71.22674 71.25708 71.28585 71.31307 71.33731
## [689] 71.36084 71.38544 71.40908 71.43249 71.45661 71.48049 71.50637 71.53355
## [697] 71.56224 71.58831 71.61531 71.64454 71.67456 71.70456 71.73417 71.76292
## [705] 71.79755 71.83578 71.87005 71.90049 71.92734 71.95407 71.98290 72.01053
## [713] 72.03471 72.05523 72.07813 72.10174 72.12405 72.14684 72.17164 72.19549
## [721] 72.21934 72.24685 72.27398 72.30181 72.33127 72.35763 72.38444 72.40995
## [729] 72.43627 72.46210 72.48899 72.51361 72.53576 72.55578 72.57452 72.59105
## [737] 72.60607 72.62067 72.63483 72.65259 72.67002 72.69008 72.71146 72.73427
## [745] 72.75602 72.77636 72.79778 72.82169 72.84158 72.86787 72.89438 72.92265
## [753] 72.95397 72.98478 73.01259 73.03850 73.06404 73.08757 73.10850 73.12826
## [761] 73.14567 73.16182 73.18085 73.19859 73.21708 73.23488 73.25200 73.26726
## [769] 73.28292 73.29851 73.31236 73.32673 73.33973 73.35019 73.36425 73.37919
## [777] 73.39441 73.40968 73.42498 73.44221 73.46054 73.47984 73.50141 73.52499
## [785] 73.55035 73.57652 73.60162 73.62600 73.65250 73.67829 73.70594 73.73500
## [793] 73.76604 73.79905 73.82835 73.86092 73.89735 73.93419 73.96955 74.00307
## [801] 74.03525 74.07093 74.11068 74.15129 74.19277 74.23368 74.27439 74.31454
## [809] 74.35378 74.39306 74.43144 74.46939 74.50715 74.53704 74.55758 74.57683
## [817] 74.60118 74.62836 74.65447 74.67996 74.69943 74.71856 74.73902 74.75878
## [825] 74.77951 74.80072 74.82065 74.84272 74.86846 74.89265 74.91094 74.92464
## [833] 74.94135 74.95786 74.97500 74.99216 75.00546 75.02082 75.03398 75.04424
## [841] 75.05480 75.06815 75.08343 75.09888 75.11046 75.11869 75.12935 75.14539
## [849] 75.16466 75.18406 75.20302 75.22271 75.24005 75.25365 75.26659 75.28502
## [857] 75.30560 75.32654 75.34715 75.36895 75.39112 75.41305 75.43334 75.45401
##
## $call
## forecast.koyckDlm(model = model.koyck, x = test$Xt, h = 864)
##
## attr(,"class")
## [1] "forecast.koyckDlm" "dLagM"
# MAPE data testing
mape.koyck <- MAPE(fore.koyck$forecasts, test$Yt)
# Akurasi data training
mape_train <- dLagM::GoF(model.koyck)["MAPE"]
c("MAPE_testing" = mape.koyck, "MAPE_training" = mape_train)## $MAPE_testing
## [1] 0.2162198
##
## $MAPE_training.MAPE
## [1] 0.01354931
Regression with Distributed Lag
Regression with Distributed Lag (lag = 2)
model.dlm = dLagM::dlm(x = train$Xt,y = train$Yt , q = 2)
summary(model.dlm)##
## Call:
## lm(formula = model.formula, data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -33.610 -6.469 0.903 7.489 22.676
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 92.7520 0.7641 121.392 < 2e-16 ***
## x.t -2.2696 0.8374 -2.710 0.00676 **
## x.1 -3.0959 1.4523 -2.132 0.03310 *
## x.2 3.4789 0.8379 4.152 3.38e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.21 on 3450 degrees of freedom
## Multiple R-squared: 0.2383, Adjusted R-squared: 0.2377
## F-statistic: 359.8 on 3 and 3450 DF, p-value: < 2.2e-16
##
## AIC and BIC values for the model:
## AIC BIC
## 1 25855.59 25886.33
AIC(model.dlm)## [1] 25855.59
BIC(model.dlm)## [1] 25886.33
# Ramalan
(fore.dlm <- forecast(model = model.dlm, x = test$Xt, h = 864))## $forecasts
## [1] 83.60184 83.05074 82.53555 82.41781 82.90110 83.82615 84.02758 83.10188
## [9] 81.74796 81.66990 82.35153 82.11585 81.69738 81.94811 83.14915 84.86166
## [17] 83.75767 83.41811 84.42165 85.00032 84.95762 84.93721 84.85767 84.16495
## [25] 84.63909 85.50422 85.32472 85.83064 84.13985 85.43797 87.00343 88.12357
## [33] 87.20886 85.04077 84.73890 84.94856 85.17492 86.06869 86.12162 86.73751
## [41] 85.97129 85.62784 85.80294 85.66009 85.02862 84.26288 85.07566 85.21128
## [49] 84.81778 85.30032 85.87733 86.22114 85.25340 84.47344 83.88004 85.57882
## [57] 83.70319 82.22900 82.42198 81.41084 81.13780 78.85776 78.20190 76.88090
## [65] 75.41852 76.71637 77.37658 75.77854 73.81171 72.12081 71.02008 70.00496
## [73] 68.05583 66.99340 67.09782 66.56441 63.49815 60.13825 60.53685 61.37484
## [81] 60.64142 60.37377 60.74698 61.03303 60.15633 59.74916 59.93765 59.06886
## [89] 58.92826 59.01965 59.00320 58.39268 57.89952 57.50862 57.07358 57.14918
## [97] 58.85383 58.20061 57.06000 56.81414 56.88578 57.51159 58.15817 58.04720
## [105] 59.59456 61.17522 62.35440 62.59609 62.04103 60.96640 61.88633 63.81998
## [113] 64.13477 64.49498 64.67094 64.78118 64.81621 65.60826 66.61797 66.82573
## [121] 67.53026 68.57199 69.68102 69.74378 69.70040 70.67925 73.00639 72.94609
## [129] 70.82312 70.76145 71.70890 72.49517 72.46888 73.26327 75.73970 77.39730
## [137] 74.90613 73.65594 73.82399 76.61208 75.58831 74.83370 75.96236 75.50907
## [145] 77.30882 77.75787 77.10184 77.69878 77.81647 77.29634 77.85090 78.08753
## [153] 78.25424 76.95642 77.52155 78.65142 79.83781 78.70960 77.69343 77.49083
## [161] 78.25764 79.18260 80.38108 79.42618 79.54047 78.48249 76.69015 81.25068
## [169] 79.50653 77.63245 79.98893 79.65405 79.15198 79.00903 79.66994 80.96993
## [177] 78.64942 78.76022 81.93226 81.70160 80.33409 80.35778 80.60280 80.72061
## [185] 80.69272 81.15285 80.49267 80.00494 80.73610 80.62589 80.81304 81.00238
## [193] 81.30378 82.35232 82.12651 80.85271 80.58376 82.05849 80.79421 80.55006
## [201] 80.42555 80.40833 79.25042 79.14073 78.70929 76.83404 75.34003 74.56871
## [209] 72.96118 72.02092 70.71380 70.30295 69.10385 67.15826 65.58971 64.64200
## [217] 64.04395 62.80950 61.09349 60.63928 60.54528 60.34994 59.79571 59.84884
## [225] 59.41493 59.20798 59.53757 59.51112 58.52180 58.27115 58.36712 57.33847
## [233] 57.92194 57.73771 57.72087 57.75694 57.19820 57.66762 57.08653 57.21537
## [241] 57.55818 57.63170 57.06908 60.11026 63.72092 62.13746 61.24887 61.37114
## [249] 61.79452 61.19755 60.99055 61.38972 61.70866 63.66440 67.14520 67.42224
## [257] 67.57308 67.86315 68.09208 68.89426 68.76329 68.74094 69.51741 72.39635
## [265] 70.03805 69.10545 72.98284 70.04414 64.25122 65.83028 67.25410 69.48220
## [273] 70.89721 71.67368 72.05716 72.51110 72.71245 72.58091 73.15128 73.74445
## [281] 73.11300 72.95604 73.89594 72.99391 72.20991 73.08317 73.98420 75.94090
## [289] 75.99971 76.54164 75.12307 74.41368 74.61986 74.38946 76.35284 77.25818
## [297] 76.85316 75.56431 75.39906 77.21331 77.22132 76.66849 77.17642 77.61831
## [305] 78.07609 78.37535 77.28584 76.37949 77.43521 77.55965 77.51212 77.87920
## [313] 77.72114 78.10732 78.16512 77.86029 78.43002 79.69478 78.71673 78.43224
## [321] 80.58864 79.02439 78.16712 77.59462 77.83896 79.16316 80.07475 79.79374
## [329] 80.40280 80.34598 78.51618 77.99431 79.13269 81.02637 80.17672 79.38883
## [337] 79.24043 78.77266 79.70568 80.53317 79.26020 78.38012 78.86175 81.14425
## [345] 79.85367 78.04539 77.51723 79.23071 77.95946 74.84513 74.32335 73.99421
## [353] 72.68179 71.65660 69.93449 68.26303 67.21897 65.65461 64.50015 63.93087
## [361] 61.96272 62.72363 62.96468 61.41991 61.08949 60.42660 59.48704 59.88448
## [369] 59.90782 59.30266 58.77758 59.13877 58.99107 59.07835 58.89472 58.42482
## [377] 58.35730 58.82423 59.14063 58.61908 58.50181 58.13414 58.51831 58.33465
## [385] 58.13361 57.97971 58.35497 58.86822 59.04776 58.96814 59.22134 59.71395
## [393] 60.22095 60.88927 61.03221 61.47700 62.21869 62.89226 63.76451 64.48144
## [401] 64.77059 65.15290 65.51784 65.77103 66.06433 66.18607 66.00772 66.77487
## [409] 68.57923 66.75355 66.09064 67.59333 67.37576 67.53988 69.21217 71.66129
## [417] 72.27286 70.41724 70.13163 68.79920 67.11709 66.94808 68.68415 69.22144
## [425] 68.59006 70.75890 72.30771 73.50192 73.84118 73.70942 73.45575 74.28861
## [433] 73.53159 71.48052 69.87245 71.22167 70.66321 72.74024 74.59825 73.72196
## [441] 74.09757 74.37424 76.22349 77.31511 76.53639 73.79089 73.41013 75.30578
## [449] 75.07740 73.30659 71.65572 72.58292 74.42847 71.33356 71.26420 72.06059
## [457] 72.53206 74.56015 74.23073 74.03870 71.66492 71.44109 72.32528 72.72050
## [465] 71.94527 68.10055 69.21639 70.03044 70.06516 70.89299 71.09314 71.13651
## [473] 70.80305 70.37776 69.52804 70.41688 70.92778 71.07044 71.24172 71.43212
## [481] 72.01994 71.50623 69.19356 68.88734 70.92105 70.50209 70.32262 70.39145
## [489] 71.12070 69.26633 68.90789 68.07283 66.42877 65.77518 66.35567 66.71537
## [497] 65.75272 64.11146 64.61152 64.09953 63.01237 61.83794 61.40956 61.90048
## [505] 61.38908 60.32547 59.90185 60.06991 60.26184 60.23330 59.92609 60.15546
## [513] 59.80531 59.29877 59.97419 60.02550 59.93940 59.86663 59.45034 59.78404
## [521] 59.97511 59.48133 59.50307 60.54638 60.83826 60.06121 59.37750 59.99628
## [529] 60.32796 59.94209 60.04780 61.00277 60.90535 61.93957 61.56310 61.68859
## [537] 62.44096 62.57060 62.99927 62.84004 62.96060 63.10178 63.29785 63.51795
## [545] 64.63321 65.06119 65.57504 65.51073 65.52222 65.79042 66.55867 66.77945
## [553] 66.68189 66.17275 66.05186 66.45570 67.23424 67.67117 67.46889 68.49495
## [561] 69.06592 66.63753 66.95822 67.51519 66.72896 67.03602 68.80276 69.45019
## [569] 68.67958 68.38645 68.73206 68.34396 70.15693 70.29247 69.34018 72.12416
## [577] 71.84105 72.37460 71.50570 70.03940 72.22598 71.71088 69.68804 71.81348
## [585] 73.66461 73.19972 72.15730 71.50430 71.00616 70.31834 70.58343 70.36998
## [593] 70.37857 69.88128 69.55017 69.72419 66.71260 62.28532 63.34061 64.03061
## [601] 67.36886 69.40815 71.07560 75.30695 72.42128 71.20818 70.34789 70.86550
## [609] 71.11417 70.93908 72.63266 71.16884 71.80471 72.11575 71.78499 71.99478
## [617] 72.86276 71.87846 71.26074 71.49704 71.21557 73.34856 72.37260 70.95208
## [625] 71.37380 70.58392 71.08667 70.39768 70.80567 71.32364 70.60450 65.10991
## [633] 58.94672 61.49250 62.87842 63.78439 64.15969 63.74588 62.75088 63.00413
## [641] 63.10942 62.74682 62.78512 62.31596 60.83832 61.34572 61.38023 61.15211
## [649] 60.91238 61.05222 60.33375 60.57018 60.85615 60.56260 59.11404 57.78031
## [657] 58.43651 59.20484 59.15527 59.70862 59.94356 60.39545 60.82351 60.50456
## [665] 59.82475 59.28735 59.42285 60.59446 60.78631 61.18699 60.96758 61.55689
## [673] 61.63118 61.28216 60.95193 61.19606 61.56004 62.18513 61.09169 60.90682
## [681] 61.52114 62.31301 62.22484 62.25254 62.56616 63.05937 63.18139 63.68013
## [689] 64.11915 63.21205 62.88739 63.47469 63.10325 62.87445 62.74041 61.87601
## [697] 61.81297 62.27362 63.20654 61.74343 61.25579 61.68120 61.97394 62.20682
## [705] 61.16551 58.65163 60.16144 62.96893 63.47358 63.29293 61.85284 61.46888
## [713] 63.04398 64.27860 63.75666 61.90399 62.64480 63.08443 62.17323 61.94879
## [721] 62.76900 61.76825 60.85776 61.87405 61.24732 61.59386 62.77618 61.97862
## [729] 62.28059 61.75312 61.89734 61.89192 63.25098 63.62978 63.68726 63.81396
## [737] 64.29567 64.10907 63.85256 63.13750 62.11881 62.73718 61.68320 61.81680
## [745] 62.01337 62.96294 62.79822 61.60665 62.02241 62.56113 59.64229 61.09966
## [753] 60.09590 59.88473 61.46160 62.44068 62.11552 62.01874 62.92111 63.21888
## [761] 63.19816 63.70024 62.78144 61.88655 62.90698 62.45586 62.96766 63.28894
## [769] 63.48859 62.84293 63.29982 63.61977 63.22758 64.21868 63.78257 61.91072
## [777] 62.67342 62.83616 62.88687 62.50487 61.78640 61.86396 61.47931 60.76471
## [785] 60.54010 60.48939 60.97991 61.61937 61.06463 60.41595 60.84591 59.85062
## [793] 59.63104 59.11752 59.86733 60.76411 58.05099 57.89380 59.17148 60.00370
## [801] 60.28141 59.40038 57.27573 57.03541 57.80491 57.90747 58.31345 58.27717
## [809] 58.50622 58.54221 58.40774 58.70846 58.56164 59.96729 63.74987 64.13033
## [817] 60.72778 58.45032 59.38862 60.59680 61.57711 63.03128 61.08141 60.75380
## [825] 61.12180 60.55575 60.94101 60.99332 59.33096 59.27362 61.87046 63.83240
## [833] 62.71409 60.60989 61.40918 61.16594 62.06998 62.68692 61.42495 63.15310
## [841] 63.20182 61.72932 60.70485 60.96809 62.22385 63.91958 63.19657 60.52835
## [849] 59.19934 59.88739 60.86764 60.87123 60.98137 62.51667 62.92888 60.93852
## [857] 58.87830 59.83438 60.41692 60.36834 59.86744 60.14897 60.61413 60.89102
##
## $call
## forecast.dlm(model = model.dlm, x = test$Xt, h = 864)
##
## attr(,"class")
## [1] "forecast.dlm" "dLagM"
# MPAE data testing
mape.dlm <- MAPE(fore.dlm$forecasts, test$Yt)
# Akurasi data training
mape_train <- GoF(model.dlm)["MAPE"]
c("MAPE_testing" = mape.dlm, "MAPE_training" = mape_train)## $MAPE_testing
## [1] 0.1508803
##
## $MAPE_training.MAPE
## [1] 0.1293836
Regression withn Distributed Lag (Optimum)
finiteDLMauto(formula = Yt ~ Xt,
data = data.frame(train), q.min = 1, q.max = 4 ,
model.type = "dlm", error.type = "AIC", trace = TRUE)## q - k MASE AIC BIC GMRAE MBRAE R.Adj.Sq Ljung-Box
## 4 4 9.32989 25815.03 25858.06 24.80838 0.82762 0.24406 0
## 3 3 9.35393 25835.17 25872.05 24.72514 1.11823 0.24091 0
## 2 2 9.38676 25855.59 25886.33 24.84159 0.99656 0.23766 0
## 1 1 9.42512 25877.71 25902.30 25.41424 1.09357 0.23403 0
model.dlm2 = dLagM::dlm(x = train$Xt,y = train$Yt , q = 4)
summary(model.dlm2)##
## Call:
## lm(formula = model.formula, data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -33.838 -6.378 0.989 7.378 22.196
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 92.3093 0.7672 120.325 < 2e-16 ***
## x.t -1.5926 0.8449 -1.885 0.0595 .
## x.1 -2.2150 1.4934 -1.483 0.1381
## x.2 0.1865 1.5420 0.121 0.9037
## x.3 -1.5281 1.4941 -1.023 0.3065
## x.4 3.2981 0.8455 3.901 9.78e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.17 on 3446 degrees of freedom
## Multiple R-squared: 0.2452, Adjusted R-squared: 0.2441
## F-statistic: 223.8 on 5 and 3446 DF, p-value: < 2.2e-16
##
## AIC and BIC values for the model:
## AIC BIC
## 1 25815.03 25858.06
AIC(model.dlm2)## [1] 25815.03
BIC(model.dlm2)## [1] 25858.06
# Ramalan
(fore.dlm2 <- forecast(model = model.dlm2, x = test$Xt, h = 864))## $forecasts
## [1] 82.10872 83.17784 84.09197 83.12899 82.84233 83.34168 83.89491 83.87316
## [9] 82.80135 81.72139 81.14904 81.21419 81.58324 81.53897 82.13774 83.66705
## [17] 84.07362 84.85107 84.28510 84.43031 85.19261 85.44095 85.12978 84.50321
## [25] 84.59242 84.61315 85.05018 85.92040 84.61882 85.56936 85.38350 87.42752
## [33] 88.00814 87.01081 85.48802 83.82356 84.01749 84.97978 85.43505 86.54716
## [41] 86.05992 86.12669 85.47718 85.15350 84.88471 84.23033 84.23522 83.95922
## [49] 84.53467 84.93009 85.09115 85.78026 85.59291 85.07205 83.79030 84.26614
## [57] 82.92399 83.21345 81.61828 80.10640 80.26231 78.22104 77.62024 75.21672
## [65] 74.17447 74.37572 74.41732 75.02033 74.26646 71.80299 69.71145 68.13866
## [73] 66.52973 65.46529 64.56367 64.13963 62.77227 60.29532 58.31989 57.18151
## [81] 58.17027 59.25494 59.33695 59.76309 59.82636 59.86867 59.36513 58.71868
## [89] 58.86643 58.39089 58.49637 58.33942 58.04051 57.35836 56.79728 56.73272
## [97] 57.71993 57.74849 58.32788 57.38722 56.54559 56.96225 57.65435 58.25616
## [105] 59.73776 60.79360 62.85298 64.05588 64.13691 63.05160 62.74784 63.11661
## [113] 64.26340 65.84640 65.85924 65.88972 65.77065 66.15573 66.74511 67.46090
## [121] 68.48448 69.11582 70.23320 70.88997 71.32414 71.61094 72.90772 73.60641
## [129] 73.62338 72.70548 71.34042 71.93510 72.74604 73.74611 75.29276 77.07041
## [137] 77.25548 76.79618 74.32639 75.12843 75.01571 76.57092 76.04948 75.24921
## [145] 77.24894 77.25981 78.19488 78.54826 77.90567 77.93042 78.13876 77.85434
## [153] 78.34276 77.60234 77.83071 77.60367 79.03607 79.27392 79.17299 77.79104
## [161] 77.46164 78.16198 79.72268 79.90153 80.60813 78.82890 77.65483 79.53160
## [169] 77.66769 80.02546 79.59542 78.21337 79.83927 79.25019 79.26168 80.06060
## [177] 79.20783 79.95462 80.06843 80.53109 82.07572 81.35366 80.24892 80.38333
## [185] 80.58503 80.93245 80.47909 80.41571 80.24891 79.94244 80.69944 80.72270
## [193] 81.09551 81.92316 82.06126 81.86892 81.19766 81.01980 80.27815 81.16073
## [201] 79.98207 79.83486 79.08272 78.94839 77.83344 76.66583 75.31524 73.39154
## [209] 71.55167 70.66653 69.00266 68.46730 67.21509 66.08707 64.42830 62.71563
## [217] 61.72607 60.84977 59.80978 58.96768 58.19192 58.40627 58.54073 58.79509
## [225] 58.45222 58.64745 58.76171 58.85584 58.64664 58.45973 57.80130 57.17771
## [233] 57.68558 56.99048 57.64549 57.59822 57.33932 57.65751 56.97168 57.45102
## [241] 57.28799 57.54729 57.52361 59.57588 61.83937 63.57465 65.07674 63.04822
## [249] 62.29415 61.90032 61.89260 61.53400 61.62451 63.33031 66.03678 68.02508
## [257] 70.40494 70.03604 69.74690 70.03732 69.84622 70.07526 70.21118 71.90277
## [265] 71.06996 72.16159 72.21054 69.84425 68.69447 66.29771 63.20781 66.94200
## [273] 69.64363 72.08905 73.23623 73.76377 73.82195 73.74797 73.94179 74.02360
## [281] 73.91688 73.98790 73.85625 73.15477 73.21403 72.84065 73.01659 75.16778
## [289] 76.10720 77.73771 76.49035 75.96056 74.61961 73.99187 75.51240 76.21611
## [297] 77.57014 77.08451 76.23843 76.27757 76.43785 77.51161 77.57056 77.35626
## [305] 78.06582 78.53522 78.03192 77.38017 76.97981 76.55057 77.49671 77.77701
## [313] 77.64584 78.12815 78.01585 78.07927 78.40785 79.00318 78.90671 79.51932
## [321] 79.87540 78.86251 79.71428 77.75537 77.22945 77.85478 78.96782 79.98816
## [329] 80.91721 80.48108 79.59667 78.80570 78.04555 79.20324 79.92486 80.70220
## [337] 79.56555 78.57532 79.09834 79.44174 79.51334 79.32211 78.47773 79.42082
## [345] 79.37973 79.76854 77.98285 77.66439 76.84309 76.18051 74.44557 71.96639
## [353] 71.23991 70.63183 68.78325 67.19809 65.52132 63.72973 62.72943 61.67605
## [361] 60.20172 60.75406 60.10853 60.42652 60.61636 59.24077 58.73867 58.75374
## [369] 58.47885 58.77303 58.62236 58.50773 58.28376 58.82683 58.71743 58.55865
## [377] 58.39007 58.42656 58.75207 58.90581 58.99025 58.31566 58.47473 58.17890
## [385] 58.39724 58.14981 58.26973 58.59744 59.11879 59.46344 59.67793 59.88803
## [393] 60.43140 61.22173 61.65115 62.29907 62.72954 63.42050 64.43806 65.26119
## [401] 65.90475 66.38864 66.53569 66.73211 66.94972 66.99498 66.87654 67.29129
## [409] 68.22924 67.70535 68.23816 67.36600 66.88947 68.18860 69.01266 70.88694
## [417] 72.70200 73.08002 72.50385 69.66083 68.06037 66.73910 66.79761 67.58135
## [425] 68.87118 70.58916 71.31715 73.92290 75.13841 75.50619 75.08665 75.06341
## [433] 74.17280 73.12616 71.05020 70.10359 68.98883 71.75779 72.89397 74.27954
## [441] 75.59680 74.78932 76.15669 77.12808 77.90637 76.40053 74.81275 73.74400
## [449] 73.77217 74.20750 72.61865 71.72984 71.98197 71.29054 72.42268 70.45928
## [457] 71.22091 73.44093 73.92651 75.20431 73.05999 72.31676 70.99020 71.49987
## [465] 71.83907 69.59127 69.25312 67.14878 68.76586 70.22062 70.58706 71.31529
## [473] 71.18244 70.78426 69.87823 70.04563 69.92247 70.91864 71.42168 71.60387
## [481] 72.06426 71.82111 70.56529 69.59504 69.11178 69.18905 70.79543 70.44454
## [489] 70.74176 69.69124 69.76577 67.66145 66.39867 65.35446 64.70642 64.96894
## [497] 65.19436 64.50914 64.01625 62.73104 62.71879 61.64418 60.66242 60.38935
## [505] 60.20148 60.17160 59.58415 59.07389 59.22997 59.64875 59.78630 59.98908
## [513] 59.62859 59.54976 59.71396 59.53687 60.13204 60.10028 59.75290 59.87939
## [521] 59.74446 59.76041 59.87911 60.17926 60.56291 60.88567 60.44223 60.05313
## [529] 59.84964 60.20169 60.49006 60.76547 60.94497 62.30633 61.96702 62.69894
## [537] 62.69973 62.87912 63.63269 63.49991 63.72410 63.54480 63.66833 63.87178
## [545] 64.68474 65.18519 66.29854 66.39921 66.53907 66.43134 66.80257 67.11487
## [553] 67.50568 67.10819 66.70802 66.46532 66.93232 67.61494 68.06771 68.92046
## [561] 69.03280 68.18441 68.30682 66.63624 66.60337 67.23462 67.83623 68.79772
## [569] 69.70352 69.67414 68.99100 68.50721 69.90745 69.81088 70.64043 72.15855
## [577] 71.41262 73.78828 72.59692 71.70655 72.04033 70.75288 71.19418 71.78141
## [585] 71.67207 73.41352 73.90376 72.62484 71.21665 70.23571 70.04608 69.58009
## [593] 69.96173 69.58185 69.43773 69.20781 67.03700 64.08529 62.04975 59.89920
## [601] 64.03707 66.87260 71.16440 75.33040 74.71597 76.08391 72.15169 71.14389
## [609] 70.61804 71.05141 72.24997 71.33462 72.81960 71.74479 72.05966 72.33681
## [617] 72.56782 72.14198 72.23344 71.37936 70.84440 72.48200 71.90489 72.54482
## [625] 71.62229 70.07895 70.77910 69.87865 70.60804 70.53747 70.52460 67.10989
## [633] 61.87589 58.76747 56.29374 60.51718 62.66812 63.44310 63.14614 62.91596
## [641] 62.35357 62.52676 62.70923 62.16664 61.29143 61.15881 60.26747 60.79877
## [649] 60.80296 60.78045 60.26586 60.55663 60.30418 60.46095 59.73691 58.48835
## [657] 57.74630 57.58511 58.53564 59.64870 59.86013 60.62888 61.07104 61.15715
## [665] 60.85683 60.01569 59.49242 59.92117 60.42717 61.63842 61.57507 62.11124
## [673] 61.91905 62.05223 61.71314 61.45121 61.46657 62.10277 61.71557 61.86101
## [681] 61.30162 61.81339 62.38278 62.94112 62.94713 63.23459 63.53962 64.16362
## [689] 64.44112 64.13546 63.98710 63.46160 63.04150 63.33729 62.87024 62.13862
## [697] 61.92959 61.66827 62.42647 62.05126 62.28028 61.29434 61.31016 61.98924
## [705] 61.55475 59.96784 59.88954 60.17449 62.45629 64.58518 63.64685 62.79010
## [713] 62.51438 63.30521 64.34719 63.84566 63.42403 62.26863 62.43819 62.54398
## [721] 62.31046 61.65546 61.68101 61.42737 60.57368 61.73858 62.06774 62.07126
## [729] 63.05142 62.00243 62.24226 61.84978 62.89533 63.32373 64.42710 64.61553
## [737] 64.78686 64.65900 64.69610 63.85298 62.84268 62.52541 61.24846 61.87149
## [745] 61.31590 62.26770 62.53428 62.49289 62.45406 61.83451 60.50056 61.51174
## [753] 58.80411 60.05178 60.40525 61.28522 62.54087 63.07982 63.20261 63.31710
## [761] 63.95841 64.31495 63.54780 63.12818 62.81102 62.00510 63.18587 63.08940
## [769] 63.65589 63.45081 63.74556 63.42019 63.59043 64.39179 63.80458 63.28436
## [777] 63.07533 61.84156 62.70923 62.63620 62.18592 61.87050 61.14449 60.83947
## [785] 60.41554 59.95851 60.32311 60.94401 61.14268 61.17823 60.86624 59.81809
## [793] 59.97822 58.89242 59.36709 59.75699 58.83579 59.10926 57.80454 58.71734
## [801] 60.21111 60.24579 58.81831 57.62651 56.54745 56.88493 58.01793 58.21941
## [809] 58.72408 58.72059 58.80650 58.96773 58.77239 59.96149 62.47612 64.17584
## [817] 64.54440 62.20123 59.43730 58.72265 60.66173 62.74037 62.29757 62.73982
## [825] 61.11116 60.57352 61.11099 60.73679 60.00808 59.84356 60.32926 62.13502
## [833] 63.70998 63.43216 62.37190 60.57064 61.94208 62.24140 62.25229 63.58876
## [841] 62.70856 63.08384 62.06020 60.85920 61.08843 62.77862 63.53478 62.83979
## [849] 60.78665 58.97605 59.02140 60.06932 61.10416 62.14357 62.66849 62.49411
## [857] 60.98825 59.64538 58.74095 59.87726 60.13168 60.24201 60.24460 60.76864
##
## $call
## forecast.dlm(model = model.dlm2, x = test$Xt, h = 864)
##
## attr(,"class")
## [1] "forecast.dlm" "dLagM"
# Akurasi testing
mape.dlm2 <- MAPE(fore.dlm2$forecasts, test$Yt)
# Akurasi data training
mape_train <- GoF(model.dlm2)["MAPE"]
c("MAPE_testing" = mape.dlm2, "MAPE_training" = mape_train)## $MAPE_testing
## [1] 0.1496921
##
## $MAPE_training.MAPE
## [1] 0.1287086
Model Autoregressive / Dynamic Regression
model.ardl = ardlDlm(x = train$Xt, y = train$Yt, p = 1 , q = 1)
summary(model.ardl)##
## Time series regression with "ts" data:
## Start = 2, End = 3456
##
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.7279 -0.4237 0.0381 0.4639 9.1164
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.467530 0.185107 2.526 0.0116 *
## X.t -3.175789 0.076035 -41.768 <2e-16 ***
## X.1 3.174360 0.076050 41.740 <2e-16 ***
## Y.1 0.993468 0.001791 554.705 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.078 on 3451 degrees of freedom
## Multiple R-squared: 0.9915, Adjusted R-squared: 0.9915
## F-statistic: 1.343e+05 on 3 and 3451 DF, p-value: < 2.2e-16
AIC(model.ardl)## [1] 10326.66
BIC(model.ardl)## [1] 10357.4
(fore.ardl <- forecast(model = model.ardl, x = test$Xt, h = 864))## $forecasts
## [1] 72.22775 72.53917 72.64228 72.79875 73.40524 74.09380 74.33991 73.73660
## [9] 73.02265 72.95456 72.89959 72.52739 72.35436 72.36340 73.75704 74.24664
## [17] 74.13622 74.53779 75.20369 75.69088 75.95282 76.27987 76.09047 75.84825
## [25] 76.52532 76.41069 77.31621 76.57753 76.56744 77.24023 78.46152 79.34513
## [33] 78.67360 77.86009 77.48663 77.01385 77.37284 77.37715 77.95627 77.99518
## [41] 77.71312 77.63923 77.51816 77.33434 76.48157 76.26280 76.36932 76.04965
## [49] 76.06857 76.20172 76.82633 76.62462 76.46544 75.25289 75.81029 75.55131
## [57] 74.10301 73.60356 72.33226 71.88171 70.16994 68.63056 67.21486 64.96936
## [65] 63.85857 63.80253 63.14341 61.75785 59.93609 57.99836 56.38996 54.28319
## [73] 52.06216 50.48976 49.49851 47.81456 44.42588 41.91520 40.88059 39.78869
## [81] 38.83037 38.25889 38.26245 37.94832 37.31843 37.29569 36.79663 36.39579
## [89] 36.15608 36.17180 35.93327 35.60083 35.17504 34.87878 34.20313 34.96059
## [97] 35.45929 35.19268 34.89583 34.72772 34.78285 35.50445 35.68169 36.55644
## [105] 37.96565 39.74729 41.26395 42.39020 42.52503 42.69072 44.09389 45.26614
## [113] 46.36768 47.27191 48.07529 48.61967 49.25594 50.42818 51.30740 52.27650
## [121] 53.36669 54.89481 56.09601 56.94052 57.62108 59.40898 61.31301 61.39523
## [129] 61.25462 61.52770 62.30722 62.79615 63.31385 64.49529 67.16216 67.65325
## [137] 67.56970 66.69272 68.01235 68.78407 68.31253 69.08241 68.89487 69.69296
## [145] 70.83554 71.11370 71.54896 72.20389 72.12440 72.49002 72.63111 73.31124
## [153] 72.81220 72.69730 72.86892 74.02401 74.34637 74.06339 73.49632 73.53611
## [161] 73.67094 74.82121 75.10704 75.10532 75.67527 73.38356 74.85323 75.71058
## [169] 74.30791 74.88278 75.23187 75.13423 75.06896 74.78180 75.97314 75.69639
## [177] 74.61151 75.80076 76.93197 76.84000 76.73907 76.73406 76.89423 76.79622
## [185] 77.09896 77.14265 76.58269 76.69625 76.67575 76.68716 76.86683 76.86759
## [193] 77.52574 78.05606 77.97660 77.06876 77.77342 77.45121 77.15638 76.68871
## [201] 76.66850 75.92436 75.25781 74.85257 73.76066 71.98944 70.64185 68.69907
## [209] 67.05393 65.03770 63.47833 61.99196 60.00648 57.77899 55.66030 53.90380
## [217] 52.31674 50.16765 48.38091 47.01784 46.13938 45.10741 44.52626 43.94857
## [225] 43.37433 43.12110 43.18691 42.80764 42.17654 42.24788 41.46124 41.34624
## [233] 41.26361 41.08614 41.32252 40.92222 41.19120 41.01386 40.99630 41.07405
## [241] 41.56410 41.25715 41.77769 44.99441 46.57183 47.21861 47.60734 48.34297
## [249] 48.62947 48.62834 48.88122 49.19602 49.69940 52.32745 54.46308 56.01404
## [257] 57.42849 58.32617 59.63122 60.38841 61.20449 61.25339 63.55678 64.54406
## [265] 63.42930 65.17952 66.53798 63.25152 61.73172 61.04686 61.69998 62.92074
## [273] 64.26108 65.40271 66.44211 67.41166 67.96245 68.50989 69.40333 69.84672
## [281] 69.71577 70.34782 70.59492 69.95131 70.10556 70.13184 71.58707 72.36653
## [289] 73.58587 73.84507 73.34051 73.41067 72.81351 73.39503 74.41763 75.14821
## [297] 75.11216 74.44119 75.04464 75.70794 75.70031 75.91505 76.28729 76.68904
## [305] 77.31068 77.45218 76.64011 76.65871 76.83600 76.75817 77.03017 77.01472
## [313] 77.18993 77.42761 77.40980 77.32861 78.16892 78.62303 77.86762 79.14932
## [321] 79.21646 78.83860 78.20901 77.64678 77.75492 78.56109 78.85426 79.24095
## [329] 79.96194 79.43366 78.64186 78.14073 79.16704 79.60280 79.33090 79.21312
## [337] 78.70229 78.51853 79.25053 79.07936 78.59803 77.71633 78.81854 79.11694
## [345] 78.53385 77.20803 77.35116 77.49345 75.69765 73.97632 72.83712 71.29201
## [353] 69.81982 68.03901 65.82442 63.81385 61.75198 59.35331 57.92193 55.48299
## [361] 53.94807 53.47046 52.20176 51.13128 50.28958 48.97657 48.27490 47.89502
## [369] 47.48564 46.72935 46.51748 46.27508 46.19289 46.17465 45.93415 45.69505
## [377] 45.67964 46.10888 46.05907 46.16829 45.89569 46.03753 46.08318 46.09673
## [385] 45.98310 46.06064 46.42347 46.87931 47.17352 47.46587 47.97870 48.52011
## [393] 49.37574 50.06732 50.72289 51.59672 52.52870 53.61375 54.85095 55.89003
## [401] 56.82748 57.72743 58.49485 59.22581 59.85702 60.32557 60.44191 62.11366
## [409] 62.56841 61.97237 62.58674 62.97504 63.10691 63.77784 65.42916 67.64207
## [417] 67.99955 68.29134 68.04147 66.96741 65.70933 65.57043 66.28982 65.86155
## [425] 66.67443 67.95872 69.61630 70.97796 72.10904 72.43930 73.33920 73.75727
## [433] 73.47413 71.60484 71.46185 70.68458 70.73775 72.37850 72.80247 73.47794
## [441] 73.70470 74.78755 76.21317 77.40782 76.81679 75.56246 75.80840 76.17989
## [449] 75.69168 74.41251 73.07763 74.22800 73.18008 72.01152 71.89809 71.37251
## [457] 72.56506 72.95641 73.75824 72.96732 71.92715 71.81430 71.60687 72.25818
## [465] 69.95204 68.70796 68.45593 68.04665 68.27502 68.50199 68.82285 68.79243
## [473] 68.85746 68.12815 68.03843 68.29859 68.52541 68.81436 69.00628 69.45110
## [481] 69.95673 69.22072 67.75876 68.21117 68.21621 68.31649 67.93979 68.70867
## [489] 68.10728 67.50954 66.91544 65.65803 64.18596 63.38974 63.07473 62.82513
## [497] 61.37024 60.71812 60.13347 59.26653 58.08726 56.78810 56.22725 55.76505
## [505] 54.89277 53.96225 53.38669 53.06865 52.97480 52.65918 52.59950 52.60365
## [513] 52.09960 52.17022 52.33564 52.37297 52.53706 52.35077 52.35612 52.61545
## [521] 52.61910 52.40037 52.81809 53.45553 53.70795 53.32364 53.35448 53.67090
## [529] 53.82657 53.63192 54.35938 54.47898 55.36001 55.85454 56.06020 56.77271
## [537] 57.22678 57.93212 58.31556 58.69664 58.98009 59.42059 59.57256 60.39049
## [545] 61.10815 62.01197 62.62445 63.10616 63.42613 64.12523 64.75655 65.28874
## [553] 65.40483 65.36142 65.44529 65.84622 66.53053 66.82957 67.19030 68.59685
## [561] 68.02584 67.55358 67.78287 67.53439 67.12863 67.74158 68.76366 69.20788
## [569] 69.07775 69.52005 69.19748 69.76609 71.02992 70.34883 71.86319 72.63791
## [577] 73.47144 74.23639 73.21827 73.69897 74.52610 73.37922 73.35085 74.59299
## [585] 75.41474 75.50107 75.14228 74.81746 73.98649 73.63697 73.19432 72.94492
## [593] 72.60177 71.97490 71.82823 71.30136 67.57015 65.67185 64.07092 64.35342
## [601] 66.22210 66.96786 71.13894 72.48994 72.94352 72.66391 72.51305 72.99827
## [609] 72.43254 73.68047 73.45995 73.59012 73.94182 74.06909 73.94153 74.57696
## [617] 74.70040 74.09268 74.21911 73.42380 74.28475 74.85466 73.99202 74.02385
## [625] 73.22981 73.23455 72.69939 72.45333 72.52634 72.75772 71.52683 65.85734
## [633] 63.11231 61.81307 61.37918 61.29725 61.31107 60.62611 60.23112 60.12433
## [641] 59.85938 59.59601 59.65180 58.56395 58.11784 57.83321 57.64555 57.20494
## [649] 57.24336 56.77337 56.52853 56.53920 56.61329 56.17876 54.92115 54.17927
## [657] 54.26758 54.16476 54.44362 54.75250 55.15474 55.77680 56.20449 56.18494
## [665] 55.97492 55.54384 56.06808 56.39856 57.07632 57.27356 57.78715 58.26582
## [673] 58.55101 58.45334 58.61030 58.63924 59.39841 59.32724 59.09768 59.09179
## [681] 59.65756 60.02932 60.30351 60.57601 61.10090 61.52730 61.95108 62.75337
## [689] 62.94735 62.66377 62.92179 62.98767 62.79907 62.86567 62.32844 61.98502
## [697] 61.58015 62.28925 62.04129 61.44548 61.23437 61.24683 61.35446 61.58846
## [705] 60.01081 59.04614 60.11982 61.15518 62.12071 62.15937 61.59437 61.92202
## [713] 62.85105 63.83793 63.19914 63.00883 63.35955 63.23175 62.69186 62.94919
## [721] 62.95088 61.96805 62.07094 61.88738 61.45085 62.28727 62.16585 62.52152
## [729] 62.30336 62.43586 62.15467 62.76441 63.43393 64.00409 64.34847 64.94480
## [737] 65.34694 65.46081 65.57398 64.60669 64.69327 63.98538 63.63112 63.24724
## [745] 63.53260 63.91148 63.62114 62.95145 64.03250 62.31227 62.25390 61.78302
## [753] 60.96564 61.10596 61.91232 62.42794 62.52755 63.07114 63.77020 64.08391
## [761] 64.71327 65.05297 64.27906 64.62138 64.42173 64.60437 64.78589 65.28388
## [769] 65.17543 65.19466 65.65837 65.51586 65.88233 66.56414 65.59039 65.35299
## [777] 65.27581 65.26262 65.24949 64.72831 64.43260 64.17043 63.56051 63.01780
## [785] 62.54190 62.32294 62.61343 62.80685 62.23690 62.43259 61.92839 61.55428
## [793] 61.02364 60.49620 61.49634 60.61665 59.58351 59.47761 59.88045 60.37609
## [801] 60.74167 59.80293 58.71108 58.48332 58.25691 58.41296 58.47275 58.62742
## [809] 58.87640 58.86978 59.11723 59.23613 59.29075 61.40929 63.92776 64.27137
## [817] 62.89794 62.13626 62.42720 62.58933 64.21132 64.29905 63.94163 64.12625
## [825] 63.86512 63.73261 64.07726 63.49882 62.51104 62.92659 64.51465 65.74370
## [833] 64.93275 64.98420 64.81301 64.80165 65.83836 65.28086 65.87003 66.64616
## [841] 66.56009 65.80763 65.28205 65.23602 66.27004 67.17072 66.50979 65.05892
## [849] 64.18852 64.14911 64.26872 64.07001 64.69820 65.70366 65.87729 64.39844
## [857] 63.81780 63.71705 63.80746 63.48444 63.38569 63.44631 63.88764 63.78640
##
## $call
## forecast.ardlDlm(model = model.ardl, x = test$Xt, h = 864)
##
## attr(,"class")
## [1] "forecast.ardlDlm" "dLagM"
# Akurasi testing
mape.ardl <- MAPE(fore.ardl$forecasts, test$Yt) #data testing
# Akurasi data training
mape_train <- GoF(model.ardl)["MAPE"]
c("MAPE_testing" = mape.ardl, "MAPE_training" = mape_train)## $MAPE_testing
## [1] 0.08647988
##
## $MAPE_training.MAPE
## [1] 0.01086986
Perbandingan Akurasi
akurasi <- matrix(c(mape.koyck, mape.dlm, mape.dlm2, mape.ardl))
row.names(akurasi)<- c("Koyck","DLM 1","DLM 2","Autoregressive")
colnames(akurasi) <- c("MAPE")
akurasi## MAPE
## Koyck 0.21621979
## DLM 1 0.15088026
## DLM 2 0.14969215
## Autoregressive 0.08647988
Dari perbandingan MAPE, metode autoregressive memiliki tingkat akurasi yang paling tinggi
Plotting Forecasting
index = c(1:864)
test <- cbind(test, index)
par(mfrow=c(1,1))
plot(x = test$Xt, y = test$Yt, type = "b", col = "black", ylim = c(70,80), xlim = c(5,10))
points(test$Xt, fore.koyck$forecasts,col = "red")
lines(test$Xt, fore.koyck$forecasts,col = "red")
points(test$Xt, fore.dlm$forecasts,col = "blue")
lines(test$Xt, fore.dlm$forecasts,col = "blue")
points(test$Xt, fore.dlm2$forecasts,col = "orange")
lines(test$Xt, fore.dlm2$forecasts,col = "orange")
points(test$Xt, fore.ardl$forecasts,col = "green")
lines(test$Xt, fore.ardl$forecasts,col = "green")
legend("topleft",c("aktual", "koyck","DLM 1","DLM 2", "autoregressive"), lty=1, col = c("black","red","blue","orange","green"), cex = 0.8)Dilihat dari perbandingan dengan plot data aktual, data forecasting belum terlalu mengikuti data aktual, ditambah karena banyaknya obsevasi membuat plot lebih sulit untuk di-interpretasikan.