MPDW Individu
2022-09-14
Data and Preparations
Package
library(dLagM)
library(dynlm)
library(MLmetrics)
library(lmtest)
library(car)
library(readxl)Data
Data yang digunakan adalah data pejualan product yang berasal dari situs web kaggle links. Variabel yang akan digunakan untuk analisis adalah Date, Product P3 (Yt), dan temperature (Xt) dengan jumlah 100 amatan. Data dikumpulkan dari tanggal 11 Agustus 2019 hingga 19 November 2019.
data <- read_excel("C:/Users/HP/Downloads/time-series-data.xlsx", sheet=2)
str(data)## tibble [100 x 3] (S3: tbl_df/tbl/data.frame)
## $ t : num [1:100] 1 2 3 4 5 6 7 8 9 10 ...
## $ Yt: num [1:100] 266 264 317 390 440 436 493 203 308 388 ...
## $ Xt: num [1:100] 18 21 19 17 18 19 21 23 25 25 ...
knitr::kable(head(data), align="l")| t | Yt | Xt |
|---|---|---|
| 1 | 266 | 18 |
| 2 | 264 | 21 |
| 3 | 317 | 19 |
| 4 | 390 | 17 |
| 5 | 440 | 18 |
| 6 | 436 | 19 |
t<-data$t
Xt<-data$Xt
Yt<-data$Yt
datareg1<-cbind(t, Xt, Yt)
datareg <- as.data.frame(datareg1)Tujuan Pengamatan
Pengamatan dilakukan untuk memprediksi pergerkan penjualan produk yang dipengaruhi oleh temperatur atau suhu lingkungan.
Splitting Data
Dilakukan splitting data dengan data train dengan jumlah amatan 80% dari jumlah seluruh amatan yaitu 80 dan data test yaitu 20% dari jumlah seluruh amatan yaitu 20 amatan.
train<-data[1:80,]
test<-data[81:100,]# Data time series
train.ts<-ts(train)
test.ts<-ts(test)
data.ts<-ts(data)Eksplorasi Data
Plot Time Series
Plot time series untuk Product P3
data.ts1<-ts(Yt)
plot(data.ts1, main = "Time Series Plot of Sales Product P3", xlab = "Period", ylab="Counts")
points(data.ts1)
Berdasarkan plot diatas, terlihat bahwa peubah Product P3 memiliki pola
data yang stasioner. Peubah Product P3 ini akan dijadikan peubah respon
untuk analisis regresi.
Plot time series untuk temperature
data.ts<-ts(Xt)
plot(data.ts, main = "Time Series Plot of Temperature", xlab = "Period", ylab="Celcius")
points(data.ts)
Berdasarkan plot diatas, terlihat bahwa peubah temperature memiliki pola
data yang stasioner. Peubah temperature ini akan dijadikan peubah
penjelas untuk analisis regresi.
Korelasi antar Peubah
cor(Xt,Yt)## [1] -0.7742278
Peubah Xt dan Yt memiliki korelasi yang cukup kuat namun bersifat liniear negatif, artinya perubahan nilai yang terjadi akan saling bertolak belakang.
Scatter Plot antara Xt dan Yt
plot(Xt, Yt, pch = 20, col = "red", main = "Scatter Plot Xt dan Yt")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
## -314.80 -59.56 22.11 70.09 271.50
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 543.13079 108.15427 5.022 3.29e-06 ***
## Y.1 0.43708 0.09912 4.410 3.36e-05 ***
## X.t -14.34809 4.04453 -3.548 0.00067 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 111.5 on 76 degrees of freedom
## Multiple R-Squared: 0.5834, Adjusted R-squared: 0.5725
## Wald test: 48.96 on 2 and 76 DF, p-value: 2.174e-14
##
## Diagnostic tests:
## NULL
##
## alpha beta phi
## Geometric coefficients: 964.851 -14.34809 0.4370832
AIC(model.koyck)## [1] 974.0142
BIC(model.koyck)## [1] 983.492
Ramalan model koyck
(fore.koyck <- forecast(model = model.koyck, x=test$Xt, h=20))## $forecasts
## [1] 744.4329 739.3771 751.5154 785.5170 800.3785 864.2666 877.8430 855.0808
## [9] 859.4799 847.0546 841.6237 867.9461 850.7550 857.5892 860.5762 890.5780
## [17] 889.3432 888.8035 831.1752 834.6831
##
## $call
## forecast.koyckDlm(model = model.koyck, x = test$Xt, h = 20)
##
## attr(,"class")
## [1] "forecast.koyckDlm" "dLagM"
MAPE testing dan akurasi Data Training
# 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.117827
##
## $MAPE_training.MAPE
## [1] 0.1723665
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
## -300.27 -68.27 10.19 68.16 308.42
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 981.893 48.857 20.097 <2e-16 ***
## x.t -17.905 6.946 -2.578 0.0119 *
## x.1 4.322 9.788 0.442 0.6601
## x.2 -13.089 6.839 -1.914 0.0595 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 121.4 on 74 degrees of freedom
## Multiple R-squared: 0.4979, Adjusted R-squared: 0.4775
## F-statistic: 24.46 on 3 and 74 DF, p-value: 4.213e-11
##
## AIC and BIC values for the model:
## AIC BIC
## 1 975.8501 987.6336
AIC(model.dlm)## [1] 975.8501
BIC(model.dlm)## [1] 987.6336
Ramalan Lag
(fore.dlm <- forecast(model = model.dlm, x=test$Xt, h=20)) ## $forecasts
## [1] 711.2263 715.6709 759.7531 791.2411 795.6858 893.4830 858.2900 879.1564
## [9] 892.6167 844.2126 861.6231 884.3446 839.8906 892.6167 862.1176 911.0162
## [17] 884.4672 914.9664 830.2578 883.3557
##
## $call
## forecast.dlm(model = model.dlm, x = test$Xt, h = 20)
##
## attr(,"class")
## [1] "forecast.dlm" "dLagM"
MAPE testing dan akurasi Data Training
#mape 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.1192812
##
## $MAPE_training.MAPE
## [1] 0.1814271
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 max lag maksimum## q - k MASE AIC BIC GMRAE MBRAE R.Adj.Sq Ljung-Box
## 4 4 0.88265 952.0099 968.3251 1.08309 0.05609 0.46992 0.0008298941
## 3 3 0.89768 963.9574 978.0202 1.08471 0.36050 0.46965 0.0005249876
## 2 2 0.91871 975.8501 987.6336 1.12561 0.53590 0.47754 0.0003803644
## 1 1 0.98942 991.4444 1000.9222 1.23127 0.33587 0.46691 0.0002982106
#model dlm dengan lag optimum
model.dlm2 = dLagM::dlm(x=train$Xt,y = train$Yt , q = 4) #terdapat lag yang tidak signifikan sehingga dapat dikurangi jumlah lagnya
summary(model.dlm2)##
## Call:
## lm(formula = model.formula, data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -283.35 -66.61 9.35 66.29 321.38
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 997.235 51.854 19.231 < 2e-16 ***
## x.t -19.841 7.065 -2.808 0.00645 **
## x.1 8.945 10.296 0.869 0.38794
## x.2 -15.108 10.442 -1.447 0.15238
## x.3 8.537 10.720 0.796 0.42854
## x.4 -9.865 7.620 -1.295 0.19967
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 120.7 on 70 degrees of freedom
## Multiple R-squared: 0.5053, Adjusted R-squared: 0.4699
## F-statistic: 14.3 on 5 and 70 DF, p-value: 1.234e-09
##
## AIC and BIC values for the model:
## AIC BIC
## 1 952.0099 968.3251
AIC(model.dlm2)## [1] 952.0099
BIC(model.dlm2)## [1] 968.3251
Ramalan Lag Optimum
(fore.dlm2 <- forecast(model = model.dlm2,x=test$Xt, h=20))## $forecasts
## [1] 787.5475 707.1706 758.5569 782.0856 799.0346 900.0784 837.2488 886.6762
## [9] 875.1521 864.1480 895.4095 891.7154 852.5454 910.6279 854.3925 945.9873
## [17] 879.9883 929.0156 817.4699 921.2001
##
## $call
## forecast.dlm(model = model.dlm2, x = test$Xt, h = 20)
##
## attr(,"class")
## [1] "forecast.dlm" "dLagM"
MAPE testing dan akurasi Data Training
mape.dlm2 <- MAPE(fore.dlm2$forecasts, test$Yt)
mape_train <- GoF(model.dlm2)["MAPE"]
c("MAPE_testing" = mape.dlm2, "MAPE_training" = mape_train)## $MAPE_testing
## [1] 0.1168301
##
## $MAPE_training.MAPE
## [1] 0.1738383
Model Autoregressive / Dynamic Regression
model.ardl = ardlDlm(x = train$Xt, y = train$Yt, p = 1 , q = 1) #p:lag x, q:lag y
#model untuk p=1, q=1: yt=b0+b1yt-1+b2xt+b3xt-1
#model untuk p=2, q=3: yt=b0+b1yt-1+b2yt-2+b3xt+b4xt-1+b5xt-2
summary(model.ardl)##
## Time series regression with "ts" data:
## Start = 2, End = 80
##
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -312.31 -60.59 15.44 73.22 271.97
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 547.7875 104.7241 5.231 1.48e-06 ***
## X.t -18.6258 6.2346 -2.987 0.0038 **
## X.1 3.8969 6.7771 0.575 0.5670
## Y.1 0.4383 0.1003 4.371 3.93e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 111.9 on 75 degrees of freedom
## Multiple R-squared: 0.586, Adjusted R-squared: 0.5695
## F-statistic: 35.39 on 3 and 75 DF, p-value: 2.336e-14
AIC(model.ardl)## [1] 975.5198
BIC(model.ardl)## [1] 987.3671
Ramalan Autoregressive
(fore.ardl <- forecast(model = model.ardl, x=test$Xt, h=20))## $forecasts
## [1] 754.4019 745.9077 760.8101 800.6970 810.3869 889.1374 889.4430 856.2224
## [9] 868.0802 850.7552 847.0580 882.6889 853.2618 866.7825 868.8122 906.9534
## [17] 897.2524 896.8970 822.2382 842.3518
##
## $call
## forecast.ardlDlm(model = model.ardl, x = test$Xt, h = 20)
##
## attr(,"class")
## [1] "forecast.ardlDlm" "dLagM"
MAPE testing dan akurasi Data Training
mape.ardl <- MAPE(fore.ardl$forecasts, test$Yt) #data testing
mape_train <- GoF(model.ardl)["MAPE"]
c("MAPE_testing" = mape.ardl, "MAPE_training" = mape_train)## $MAPE_testing
## [1] 0.1164552
##
## $MAPE_training.MAPE
## [1] 0.171635
Penentuan lag optimum
ardlBoundOrders(data = data.frame(datareg), formula = Yt ~ Xt ) ## $p
## Xt
## 1 15
##
## $q
## [1] 15
##
## $Stat.table
## q = 1 q = 2 q = 3 q = 4 q = 5 q = 6 q = 7 q = 8
## p = 1 1221.121 1210.285 1200.500 1188.554 1168.307 1099.233 1087.030 1078.194
## p = 2 1210.844 1212.262 1202.444 1190.551 1170.258 1100.970 1088.704 1079.956
## p = 3 1201.009 1201.009 1203.009 1191.277 1171.643 1102.956 1090.625 1081.901
## p = 4 1191.356 1192.184 1192.184 1192.836 1173.486 1104.240 1091.711 1082.950
## p = 5 1178.087 1178.034 1179.143 1179.143 1174.243 1106.096 1093.580 1084.789
## p = 6 1157.012 1156.821 1157.387 1159.301 1159.301 1108.056 1095.170 1086.230
## p = 7 1090.186 1090.609 1092.119 1093.874 1094.172 1094.172 1096.090 1087.188
## p = 8 1137.529 1136.517 1137.828 1139.799 1134.381 1087.472 1087.472 1089.177
## p = 9 1128.145 1127.305 1128.517 1130.493 1125.244 1077.961 1079.831 1079.831
## p = 10 1115.280 1116.903 1117.833 1119.833 1114.783 1069.340 1071.164 1072.595
## p = 11 1104.586 1104.695 1106.610 1108.575 1103.760 1057.962 1059.552 1061.154
## p = 12 1092.589 1090.995 1091.107 1092.798 1091.840 1047.013 1048.949 1050.624
## p = 13 1078.096 1076.170 1076.317 1078.055 1077.081 1038.049 1040.014 1041.597
## p = 14 1020.063 1021.611 1022.784 1024.589 1022.176 1016.012 1018.008 1019.987
## p = 15 1051.999 1047.677 1047.758 1049.655 1043.778 1013.137 1014.104 1015.237
## q = 9 q = 10 q = 11 q = 12 q = 13 q = 14 q = 15
## p = 1 1068.948 1059.302 1047.548 1037.613 1018.117 1009.480 999.4976
## p = 2 1070.672 1060.938 1048.607 1038.762 1019.468 1010.785 1000.4197
## p = 3 1072.625 1062.937 1050.512 1040.696 1021.445 1012.766 1002.4104
## p = 4 1073.679 1063.715 1051.871 1041.760 1023.347 1014.662 1004.3631
## p = 5 1075.536 1065.625 1053.737 1043.687 1025.319 1016.585 1006.2919
## p = 6 1076.933 1067.057 1055.099 1045.220 1025.334 1016.351 1005.3782
## p = 7 1077.860 1068.202 1056.188 1046.215 1026.634 1017.228 1005.5266
## p = 8 1079.757 1070.180 1058.172 1048.181 1028.632 1019.227 1007.4150
## p = 9 1081.664 1072.003 1060.143 1050.073 1030.563 1021.200 1009.4150
## p = 10 1072.595 1073.027 1061.671 1051.484 1032.033 1022.645 1010.6922
## p = 11 1063.008 1063.008 1063.439 1053.440 1033.921 1024.543 1012.5561
## p = 12 1052.489 1051.629 1051.629 1053.330 1034.593 1024.714 1012.2833
## p = 13 1043.545 1042.885 1043.811 1043.811 1035.861 1026.152 1013.5145
## p = 14 1021.974 1022.836 1022.843 1024.381 1024.381 1025.979 1012.6151
## p = 15 1017.213 1017.427 1018.352 1019.972 1011.932 1011.932 1012.9666
##
## $min.Stat
## [1] 999.4976
#PEMODELAN DLM dan ARDL dengan library dynlm
#library(dynlm)
#sama dengan model dlm p=1
cons_lm1 <- dynlm(Yt ~ Xt+L(Xt),data = train.ts)
#sama dengan model ardl p=0 q=1
cons_lm2 <- dynlm(Yt ~ Xt+L(Yt),data = train.ts)
#sama dengan ardl p=1 q=1
cons_lm3 <- dynlm(Yt ~ Xt+L(Xt)+L(Yt),data = train.ts)
#sama dengan dlm p=2
cons_lm4 <- dynlm(Yt ~ Xt+L(Xt)+L(Xt,2),data = train.ts)
summary(cons_lm1)##
## Time series regression with "ts" data:
## Start = 2, End = 80
##
## Call:
## dynlm(formula = Yt ~ Xt + L(Xt), data = train.ts)
##
## Residuals:
## Min 1Q Median 3Q Max
## -291.80 -83.51 13.07 83.69 325.91
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 964.030 48.466 19.891 <2e-16 ***
## Xt -18.131 6.936 -2.614 0.0108 *
## L(Xt) -7.580 6.952 -1.090 0.2790
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 124.6 on 76 degrees of freedom
## Multiple R-squared: 0.4806, Adjusted R-squared: 0.4669
## F-statistic: 35.16 on 2 and 76 DF, p-value: 1.548e-11
summary(cons_lm1)##
## Time series regression with "ts" data:
## Start = 2, End = 80
##
## Call:
## dynlm(formula = Yt ~ Xt + L(Xt), data = train.ts)
##
## Residuals:
## Min 1Q Median 3Q Max
## -291.80 -83.51 13.07 83.69 325.91
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 964.030 48.466 19.891 <2e-16 ***
## Xt -18.131 6.936 -2.614 0.0108 *
## L(Xt) -7.580 6.952 -1.090 0.2790
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 124.6 on 76 degrees of freedom
## Multiple R-squared: 0.4806, Adjusted R-squared: 0.4669
## F-statistic: 35.16 on 2 and 76 DF, p-value: 1.548e-11
summary(cons_lm2)##
## Time series regression with "ts" data:
## Start = 2, End = 80
##
## Call:
## dynlm(formula = Yt ~ Xt + L(Yt), data = train.ts)
##
## Residuals:
## Min 1Q Median 3Q Max
## -316.20 -64.28 19.16 71.04 265.75
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 574.29382 93.61796 6.134 3.56e-08 ***
## Xt -15.62134 3.38643 -4.613 1.58e-05 ***
## L(Yt) 0.41599 0.09205 4.519 2.24e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 111.4 on 76 degrees of freedom
## Multiple R-squared: 0.5842, Adjusted R-squared: 0.5733
## F-statistic: 53.39 on 2 and 76 DF, p-value: 3.295e-15
summary(cons_lm3)##
## Time series regression with "ts" data:
## Start = 2, End = 80
##
## Call:
## dynlm(formula = Yt ~ Xt + L(Xt) + L(Yt), data = train.ts)
##
## Residuals:
## Min 1Q Median 3Q Max
## -312.31 -60.59 15.44 73.22 271.97
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 547.7875 104.7241 5.231 1.48e-06 ***
## Xt -18.6258 6.2346 -2.987 0.0038 **
## L(Xt) 3.8969 6.7771 0.575 0.5670
## L(Yt) 0.4383 0.1003 4.371 3.93e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 111.9 on 75 degrees of freedom
## Multiple R-squared: 0.586, Adjusted R-squared: 0.5695
## F-statistic: 35.39 on 3 and 75 DF, p-value: 2.336e-14
summary(cons_lm4)##
## Time series regression with "ts" data:
## Start = 3, End = 80
##
## Call:
## dynlm(formula = Yt ~ Xt + L(Xt) + L(Xt, 2), data = train.ts)
##
## Residuals:
## Min 1Q Median 3Q Max
## -300.27 -68.27 10.19 68.16 308.42
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 981.893 48.857 20.097 <2e-16 ***
## Xt -17.905 6.946 -2.578 0.0119 *
## L(Xt) 4.322 9.788 0.442 0.6601
## L(Xt, 2) -13.089 6.839 -1.914 0.0595 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 121.4 on 74 degrees of freedom
## Multiple R-squared: 0.4979, Adjusted R-squared: 0.4775
## F-statistic: 24.46 on 3 and 74 DF, p-value: 4.213e-11
SSE
deviance(cons_lm1)## [1] 1179067
deviance(cons_lm2)## [1] 943866.3
deviance(cons_lm3)## [1] 939723.6
deviance(cons_lm4)## [1] 1089822
Diagnostik Model
Uji Non Autokorelasi
dwtest(cons_lm1)##
## Durbin-Watson test
##
## data: cons_lm1
## DW = 1.1672, p-value = 3.08e-05
## alternative hypothesis: true autocorrelation is greater than 0
dwtest(cons_lm2)##
## Durbin-Watson test
##
## data: cons_lm2
## DW = 2.1266, p-value = 0.6585
## alternative hypothesis: true autocorrelation is greater than 0
dwtest(cons_lm3)##
## Durbin-Watson test
##
## data: cons_lm3
## DW = 2.1483, p-value = 0.6851
## alternative hypothesis: true autocorrelation is greater than 0
dwtest(cons_lm4)##
## Durbin-Watson test
##
## data: cons_lm4
## DW = 1.1735, p-value = 4.149e-05
## alternative hypothesis: true autocorrelation is greater than 0
Uji Heterogenitas
bptest(cons_lm1)##
## studentized Breusch-Pagan test
##
## data: cons_lm1
## BP = 0.94649, df = 2, p-value = 0.623
bptest(cons_lm2)##
## studentized Breusch-Pagan test
##
## data: cons_lm2
## BP = 11.152, df = 2, p-value = 0.003787
bptest(cons_lm3)##
## studentized Breusch-Pagan test
##
## data: cons_lm3
## BP = 10.744, df = 3, p-value = 0.01319
bptest(cons_lm4)##
## studentized Breusch-Pagan test
##
## data: cons_lm4
## BP = 1.101, df = 3, p-value = 0.7768
Normalitas
shapiro.test(residuals(cons_lm1))##
## Shapiro-Wilk normality test
##
## data: residuals(cons_lm1)
## W = 0.99163, p-value = 0.8916
shapiro.test(residuals(cons_lm2))##
## Shapiro-Wilk normality test
##
## data: residuals(cons_lm2)
## W = 0.96723, p-value = 0.03987
shapiro.test(residuals(cons_lm3))##
## Shapiro-Wilk normality test
##
## data: residuals(cons_lm3)
## W = 0.96631, p-value = 0.03492
shapiro.test(residuals(cons_lm4))##
## Shapiro-Wilk normality test
##
## data: residuals(cons_lm4)
## W = 0.98688, p-value = 0.6085
Perbandingan Keakuratan Ramalan
#PERBANDINGAN
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.1178270
## DLM 1 0.1192812
## DLM 2 0.1168301
## Autoregressive 0.1164552
#PLOT
par(mfrow=c(1,1))
plot(test$Xt, test$Yt, col="black")
points(test$Xt, fore.koyck$forecasts,col="red")
points(test$Xt, fore.dlm$forecasts,col="blue")
points(test$Xt, fore.dlm2$forecasts,col="orange")
points(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.5)