Dosen Pengempu : Prof. Dr. Suhartono, M.Kom

UIN Maulana Malik Ibrahim Malang - Teknik Informatika

Data Beberapa Wilayah di Sumatera

library(readxl)
## Warning: package 'readxl' was built under R version 4.1.2

Data Inflow

datainflowkelasC <- read_excel(path = "C:/Users/ASUS PC/Documents/BUKU NOVA/RStudio/RMarkdown/kelascup.xlsx")
datainflowkelasC
## # A tibble: 11 x 12
##    Keterangan Sumatera   Aceh `Sumatera Utara` `Sumatera Barat`   Riau
##         <dbl>    <dbl>  <dbl>            <dbl>            <dbl>  <dbl>
##  1       2011   57900.  2308.           23238.            9385.  3012.
##  2       2012   65911.  2620.           25981.           11192.  4447.
##  3       2013   98369. 36337.           18120.           14056.  8933.
##  4       2014   86024.  4567.           30503.           14103.  6358.
##  5       2015   86549.  4710.           30254.           13309.  7156.
##  6       2016   97764.  5775.           34427.           14078.  8211.
##  7       2017  103748.  5514.           35617.           15312.  8553.
##  8       2018  117495.  5799.           41769.           15058. 10730.
##  9       2019  133762.  7509.           47112.           14750. 10915.
## 10       2020  109345.  6641.           36609.           10696.  9148.
## 11       2021   89270.  3702.           31840.           10748.  7769.
## # ... with 6 more variables: Kep. Riau <dbl>, Jambi <dbl>,
## #   Sumatera Selatan <dbl>, Bengkulu <dbl>, Lampung <dbl>,
## #   Kep. Bangka Belitung <dbl>

Data Outflow

dataoutflowkelasB <- read_excel(path = "C:/Users/ASUS PC/Documents/BUKU NOVA/RStudio/RMarkdown/kelasout.xlsx")
dataoutflowkelasB
## # A tibble: 11 x 12
##    Keterangan Sumatera   Aceh `Sumatera Utara` `Sumatera Barat`   Riau
##         <dbl>    <dbl>  <dbl>            <dbl>            <dbl>  <dbl>
##  1       2011   80092.  6338.           22176.            5300. 12434.
##  2       2012   85235.  6378.           22495.            6434. 13014.
##  3       2013  103288. 23278.           19235.            6511. 15460.
##  4       2014  102338.  8630.           26391.            7060. 15158.
##  5       2015  109186.  9637.           27877.            7471. 15789.
##  6       2016  121992. 11311.           31959.            9198. 17645.
##  7       2017  133606. 11760.           35243.           10754. 18128.
##  8       2018  135676. 11450.           36908.            8447. 17926.
##  9       2019  153484. 13087.           44051.            9465. 19277.
## 10       2020  140589. 12874.           39758.            8763. 19139.
## 11       2021   86627.  5770.           23453.            5941. 12631.
## # ... with 6 more variables: Kep. Riau <dbl>, Jambi <dbl>,
## #   Sumatera Selatan <dbl>, Bengkulu <dbl>, Lampung <dbl>,
## #   Kep. Bangka Belitung <dbl>

Visualisasi dan Prediksi Inflow di Daerah Sumatera Selatan

datainflowkelasC$`Sumatera Selatan`
##  [1]  7820.341  9125.976  8647.320 10037.880 10797.201 12751.708 13075.276
##  [8] 14266.500 14811.729 11756.282  9105.942
plot(datainflowkelasC$`Sumatera Selatan`, type = "l", col = "red")

Visualisasi dan Prediksi Outflow di Daerah Sumatera Selatan

dataoutflowkelasB$`Sumatera Selatan`
##  [1] 14523.56 15600.08 12693.21 13372.22 13483.73 15755.86 16981.14 17931.03
##  [9] 19121.28 18308.87 11435.81
plot(dataoutflowkelasB$`Sumatera Selatan`, type = "l", col = "blue")

Visualisasi dan Prediksi Inflow-Outflow di Daerah Sumatera Selatan Setiap Periode

plot(datainflowkelasC$`Sumatera Selatan`, type = "l", col = "red")
lines(dataoutflowkelasB$`Sumatera Selatan`, type = "l", col = "blue")
legend("top",c("Inflow","Outflow"),fill=c("red","blue"))

Data pada Beberapa Wilayah di Sumatera Setiap Bulan

Data Inflow PerBulan

datainflowperbulan <- read_excel(path = "C:/Users/ASUS PC/Documents/BUKU NOVA/RStudio/RMarkdown/InflowperBulan.xlsx")
dataoutflowperbulan <- read_excel(path = "C:/Users/ASUS PC/Documents/BUKU NOVA/RStudio/RMarkdown/OutflowperBulan.xlsx")
datainflowperbulan
## # A tibble: 128 x 12
##    Keterangan          Sumatera  Aceh `Sumatera Utara` `Sumatera Barat`   Riau
##    <dttm>                 <dbl> <dbl>            <dbl>            <dbl>  <dbl>
##  1 2011-01-01 00:00:00    4164.  124.            2068.             545.   94.2
##  2 2011-02-01 00:00:00    3338.  115.            1826.             450.   96.4
##  3 2011-03-01 00:00:00    4878.  154.            2028.             849.  288. 
##  4 2011-04-01 00:00:00    3157.  122.            1429.             539.  160. 
##  5 2011-05-01 00:00:00    3821.  123.            1539.             692.  195. 
##  6 2011-06-01 00:00:00    3686.  151.            1637.             592.  101. 
##  7 2011-07-01 00:00:00    4370.  107.            1791.             800.  143. 
##  8 2011-08-01 00:00:00    3668.  184.            1256.             586.  134. 
##  9 2011-09-01 00:00:00   12875.  606.            4172.            2176. 1014. 
## 10 2011-10-01 00:00:00    4777.  158.            1941.             787.  341. 
## # ... with 118 more rows, and 6 more variables: Kep. Riau <dbl>, Jambi <dbl>,
## #   Sumatera Selatan <dbl>, Bengkulu <dbl>, Lampung <dbl>,
## #   Kep. Bangka Belitung <dbl>

Data Outflow PerBulan

dataoutflowperbulan
## # A tibble: 128 x 12
##    Keterangan          Sumatera  Aceh `Sumatera Utara` `Sumatera Barat`  Riau
##    <dttm>                 <dbl> <dbl>            <dbl>            <dbl> <dbl>
##  1 2011-01-01 00:00:00    3442.  350.             941.             307.  478.
##  2 2011-02-01 00:00:00    3989.  193.             990.             228.  400.
##  3 2011-03-01 00:00:00    4229.  230.            1209.             347.  621.
##  4 2011-04-01 00:00:00    6721.  529.            1653.             336. 1006.
##  5 2011-05-01 00:00:00    5787.  523.            1465.             328. 1000.
##  6 2011-06-01 00:00:00    7395.  406.            2167.             399. 1366.
##  7 2011-07-01 00:00:00    7154.  958.            1695.             449.  815.
##  8 2011-08-01 00:00:00   16043. 1046.            4104.            1376. 2729.
##  9 2011-09-01 00:00:00    1915.  124.             824.             148.  154.
## 10 2011-10-01 00:00:00    5174.  634.            1392.             299.  830.
## # ... with 118 more rows, and 6 more variables: Kep. Riau <dbl>, Jambi <dbl>,
## #   Sumatera Selatan <dbl>, Bengkulu <dbl>, Lampung <dbl>,
## #   Kep. Bangka Belitung <dbl>

Visualisasi dan Prediksi Inflow-Outflow di Daerah Sumatera Selatan pada Setiap Bulan

plot(datainflowperbulan$`Sumatera Selatan`, type = "l", col = "red")
lines(dataoutflowperbulan$`Sumatera Selatan`,col="blue")
legend("top",c("Inflow","Outflow"),fill=c("red","blue"))

Time Series dan Log pada Daerah Sumatera Selatan

SumateraSelatantimeseries <- datainflowperbulan$`Sumatera Selatan`
plot.ts(SumateraSelatantimeseries , type = "l", col = "green")

logSumateraSelatan <- log(datainflowperbulan$`Sumatera Selatan`)
plot.ts(logSumateraSelatan)

library(TTR)
## Warning: package 'TTR' was built under R version 4.1.2
SumateraSelatanSMA3 <- SMA(datainflowperbulan$`Sumatera Selatan` ,n=3)
plot.ts(SumateraSelatanSMA3 )

library("TTR")
SumateraSelatanSMA3 <- SMA(datainflowperbulan$`Sumatera Selatan` ,n=8)
plot.ts(SumateraSelatanSMA3 )

Visualisasi Prediksi Data Inflow-Outflow Time Series Uang Kartal di Daerah Sumatera Selatan

Inflow TimeSeries
SumateraSelataninflowtimeseries <- ts(datainflowperbulan$`Sumatera Selatan`, frequency=12, start=c(2011,1))
SumateraSelataninflowtimeseries
##            Jan       Feb       Mar       Apr       May       Jun       Jul
## 2011  456.4919  363.4010  661.9322  355.8931  655.5655  445.7856  533.9543
## 2012  847.7118  557.6804  842.2304  433.0244  852.8930  791.5389  572.3589
## 2013 1241.6259  583.4391  369.7243  594.3824  606.8414  451.6471  436.7965
## 2014 1290.5744  697.7210  539.5584  601.5915  496.8451  761.1483  292.8094
## 2015 1373.5722  467.9884  507.1713  316.2315  646.5083  769.0185 2218.0190
## 2016 1724.9435  757.5883  698.3839  580.2943  975.7450  820.2649 3028.2880
## 2017 1247.4278  649.6430  715.8801  816.9179  919.5968  497.3588 3480.9746
## 2018 1386.1845  640.7069  770.9428  855.5950  824.7960 2888.6614 1826.9664
## 2019 1729.8884  787.8768  710.2534 1126.8944  967.7749 3393.1168 1151.6163
## 2020 2054.0128  914.8161  680.3686  665.8459 1019.4927 1432.5599 1025.4901
## 2021 1825.6471  768.0047  782.0909 1035.3983 1947.4074 1072.3469  963.1947
##            Aug       Sep       Oct       Nov       Dec
## 2011  744.7032 1712.5480  561.2395  979.5828  349.2438
## 2012 1688.2790  825.1074  638.0242  767.6416  309.4864
## 2013 2094.8131  390.1139  941.0992  631.0574  305.7795
## 2014 2458.0650  693.6043  957.7864  685.5728  562.6037
## 2015 1058.1097  827.1355  979.8054  933.4509  700.1903
## 2016  969.6394  966.3684  828.4733  743.3749  658.3444
## 2017 1085.7413 1042.5878 1027.7669  931.9672  659.4133
## 2018 1187.7423 1109.3445  995.0373  993.8724  786.6507
## 2019 1222.7634 1014.0402 1049.8722  925.4907  732.1411
## 2020  933.0685  922.3794  619.9658  929.7524  558.5297
## 2021  711.8520
plot.ts(SumateraSelataninflowtimeseries)

Outflow TimeSeries
SumateraSelatanoutflowtimeseries <- ts(dataoutflowperbulan$`Sumatera Selatan`, frequency=12, start=c(2011,1))
SumateraSelatanoutflowtimeseries
##            Jan       Feb       Mar       Apr       May       Jun       Jul
## 2011  665.0204 1327.9789  784.5960 1664.4175 1013.5138 1173.7556 1295.7944
## 2012  585.9661 1172.7767 1566.9525 1156.5310 1230.6371 1367.3602 1140.7971
## 2013  313.1714  522.0305  822.0748  370.0617  820.6871  914.3388 2150.1090
## 2014  681.3193  728.3859 1107.6390 1145.9336  970.1190 1138.7692 3375.7872
## 2015  303.5811  730.8745  947.5489 1528.0217  971.6950 1253.9235 3292.4818
## 2016  291.6833  754.0870  998.3022 1389.9930 1557.6113 3449.6370 1082.9331
## 2017  846.0081 1142.9021 1533.7630 1016.7147 1223.4515 4005.3341  441.6113
## 2018  577.3886 1086.3337 1585.9543 1302.7789 2209.9709 3882.2670  783.2563
## 2019  539.7334 1120.4360 1655.8566 2078.5155 4646.7802  448.9773 1286.7151
## 2020  516.0607 1086.5070 1851.9668 1261.4710 2590.3465  607.8210 1445.3980
## 2021  338.7335 1037.2551 1384.9886 2483.6447 2709.4180 1017.8561 1575.3735
##            Aug       Sep       Oct       Nov       Dec
## 2011 2621.9702  312.8544  903.8191  872.5556 1887.2803
## 2012 2552.5039  668.3767 1229.9850  806.9955 2121.1970
## 2013 1120.7014 1160.2111 1070.8040 1267.4096 2161.6112
## 2014  255.9222  760.6027  899.5059 1009.9874 1298.2534
## 2015  637.9153  689.0966  528.2202 1125.9204 1474.4510
## 2016 1108.8282 1044.8214 1044.6620 1210.0297 1823.2746
## 2017 1246.7486  781.9704 1137.4882 1686.9596 1918.1924
## 2018 1204.7220 1000.8916  973.8639 1416.3610 1907.2461
## 2019 1315.9151  889.2873  967.7377 1603.9596 2567.3698
## 2020 1494.1643 1371.2573 1979.2621 1571.4548 2533.1589
## 2021  888.5372
plot.ts(SumateraSelatanoutflowtimeseries)

Visualisasi Prediksi Data Inflow-Outflow Time Series Komponen Uang Kartal di Daerah Sumatera Selatan

Inflow Time Series Komponen

SumateraSelatanintimeseriescomponents <- decompose(SumateraSelataninflowtimeseries)
SumateraSelatanintimeseriescomponents$seasonal
##              Jan         Feb         Mar         Apr         May         Jun
## 2011  491.487816 -299.776183 -327.111996 -306.363005 -159.769086  338.917294
## 2012  491.487816 -299.776183 -327.111996 -306.363005 -159.769086  338.917294
## 2013  491.487816 -299.776183 -327.111996 -306.363005 -159.769086  338.917294
## 2014  491.487816 -299.776183 -327.111996 -306.363005 -159.769086  338.917294
## 2015  491.487816 -299.776183 -327.111996 -306.363005 -159.769086  338.917294
## 2016  491.487816 -299.776183 -327.111996 -306.363005 -159.769086  338.917294
## 2017  491.487816 -299.776183 -327.111996 -306.363005 -159.769086  338.917294
## 2018  491.487816 -299.776183 -327.111996 -306.363005 -159.769086  338.917294
## 2019  491.487816 -299.776183 -327.111996 -306.363005 -159.769086  338.917294
## 2020  491.487816 -299.776183 -327.111996 -306.363005 -159.769086  338.917294
## 2021  491.487816 -299.776183 -327.111996 -306.363005 -159.769086  338.917294
##              Jul         Aug         Sep         Oct         Nov         Dec
## 2011  509.571884  389.746351   -6.409713 -100.157546 -116.102210 -414.033605
## 2012  509.571884  389.746351   -6.409713 -100.157546 -116.102210 -414.033605
## 2013  509.571884  389.746351   -6.409713 -100.157546 -116.102210 -414.033605
## 2014  509.571884  389.746351   -6.409713 -100.157546 -116.102210 -414.033605
## 2015  509.571884  389.746351   -6.409713 -100.157546 -116.102210 -414.033605
## 2016  509.571884  389.746351   -6.409713 -100.157546 -116.102210 -414.033605
## 2017  509.571884  389.746351   -6.409713 -100.157546 -116.102210 -414.033605
## 2018  509.571884  389.746351   -6.409713 -100.157546 -116.102210 -414.033605
## 2019  509.571884  389.746351   -6.409713 -100.157546 -116.102210 -414.033605
## 2020  509.571884  389.746351   -6.409713 -100.157546 -116.102210 -414.033605
## 2021  509.571884  389.746351

Outflow Time Series Komponen

SumateraSelatanouttimeseriescomponents <- decompose(SumateraSelatanoutflowtimeseries)
SumateraSelatanouttimeseriescomponents$seasonal
##             Jan        Feb        Mar        Apr        May        Jun
## 2011 -840.21380 -395.36177   37.92850  -63.06564  481.08395  568.98365
## 2012 -840.21380 -395.36177   37.92850  -63.06564  481.08395  568.98365
## 2013 -840.21380 -395.36177   37.92850  -63.06564  481.08395  568.98365
## 2014 -840.21380 -395.36177   37.92850  -63.06564  481.08395  568.98365
## 2015 -840.21380 -395.36177   37.92850  -63.06564  481.08395  568.98365
## 2016 -840.21380 -395.36177   37.92850  -63.06564  481.08395  568.98365
## 2017 -840.21380 -395.36177   37.92850  -63.06564  481.08395  568.98365
## 2018 -840.21380 -395.36177   37.92850  -63.06564  481.08395  568.98365
## 2019 -840.21380 -395.36177   37.92850  -63.06564  481.08395  568.98365
## 2020 -840.21380 -395.36177   37.92850  -63.06564  481.08395  568.98365
## 2021 -840.21380 -395.36177   37.92850  -63.06564  481.08395  568.98365
##             Jul        Aug        Sep        Oct        Nov        Dec
## 2011  311.95619   40.97787 -448.31460 -248.63179  -75.48302  630.14046
## 2012  311.95619   40.97787 -448.31460 -248.63179  -75.48302  630.14046
## 2013  311.95619   40.97787 -448.31460 -248.63179  -75.48302  630.14046
## 2014  311.95619   40.97787 -448.31460 -248.63179  -75.48302  630.14046
## 2015  311.95619   40.97787 -448.31460 -248.63179  -75.48302  630.14046
## 2016  311.95619   40.97787 -448.31460 -248.63179  -75.48302  630.14046
## 2017  311.95619   40.97787 -448.31460 -248.63179  -75.48302  630.14046
## 2018  311.95619   40.97787 -448.31460 -248.63179  -75.48302  630.14046
## 2019  311.95619   40.97787 -448.31460 -248.63179  -75.48302  630.14046
## 2020  311.95619   40.97787 -448.31460 -248.63179  -75.48302  630.14046
## 2021  311.95619   40.97787

Grafik TimeSeries Sumatera Selatan

plot(SumateraSelatanintimeseriescomponents$seasonal,type = "l", col = "red")
lines(SumateraSelatanouttimeseriescomponents$seasonal,col="blue")
legend("top",c("Inflow","Outflow"),fill=c("red","blue"))

plot(SumateraSelatanintimeseriescomponents$trend,type = "l", col = "red")
lines(SumateraSelatanouttimeseriescomponents$trend,col="blue")
legend("top",c("Inflow","Outflow"),fill=c("red","blue"))

plot(SumateraSelatanintimeseriescomponents$random ,type = "l", col = "red")
lines(SumateraSelatanouttimeseriescomponents$random,col="blue")
legend("top",c("Inflow","Outflow"),fill=c("red","blue"))

plot(SumateraSelatanintimeseriescomponents$figure ,type = "l", col = "red")
lines(SumateraSelatanouttimeseriescomponents$figure,col="blue")
legend("top",c("Inflow","Outflow"),fill=c("red","blue"))


Referensi