library(readxl)
library(forecast)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(TTR)
library(imputeTS)
library(tseries)
## 
## Attaching package: 'tseries'
## The following object is masked from 'package:imputeTS':
## 
##     na.remove
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(graphics)
library(TSA)
## Registered S3 methods overwritten by 'TSA':
##   method       from    
##   fitted.Arima forecast
##   plot.Arima   forecast
## 
## Attaching package: 'TSA'
## The following objects are masked from 'package:stats':
## 
##     acf, arima
## The following object is masked from 'package:utils':
## 
##     tar
library(tidyverse)
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ tibble  3.1.8     ✔ purrr   0.3.5
## ✔ tidyr   1.2.1     ✔ stringr 1.5.0
## ✔ readr   2.1.3     ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ✖ readr::spec()   masks TSA::spec()
library(lubridate)
## Loading required package: timechange
## 
## Attaching package: 'lubridate'
## 
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(gridExtra)
## 
## Attaching package: 'gridExtra'
## 
## The following object is masked from 'package:dplyr':
## 
##     combine
library(ggfortify)
## Registered S3 methods overwritten by 'ggfortify':
##   method                 from    
##   autoplot.Arima         forecast
##   autoplot.acf           forecast
##   autoplot.ar            forecast
##   autoplot.bats          forecast
##   autoplot.decomposed.ts forecast
##   autoplot.ets           forecast
##   autoplot.forecast      forecast
##   autoplot.stl           forecast
##   autoplot.ts            forecast
##   fitted.ar              forecast
##   fortify.ts             forecast
##   residuals.ar           forecast
library(cowplot)
## 
## Attaching package: 'cowplot'
## 
## The following object is masked from 'package:lubridate':
## 
##     stamp
library(graphics)
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following object is masked from 'package:imputeTS':
## 
##     na.locf
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(stats)
library(MASS)
## 
## Attaching package: 'MASS'
## 
## The following object is masked from 'package:dplyr':
## 
##     select
library(fpp2)
## ── Attaching packages ────────────────────────────────────────────── fpp2 2.4 ──
## ✔ fma       2.4     ✔ expsmooth 2.3
library(hrbrthemes)
## NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.
##       Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and
##       if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow
setwd("D:/SATRIA DATA")
mpdw <- read_xlsx("Data CO.xlsx")
## New names:
## • `` -> `...4`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
mpdw <- mpdw[,1:2]
mpdw$`Data CO`<- as.numeric(mpdw$`Data CO`)
ts.mpdw <- ts(mpdw)
kableExtra::kable(head(mpdw) ,caption = 'Subset Data CO DKI Jakarta 2021-2022')
## Warning in !is.null(rmarkdown::metadata$output) && rmarkdown::metadata$output
## %in% : 'length(x) = 2 > 1' in coercion to 'logical(1)'
Subset Data CO DKI Jakarta 2021-2022
t Data CO
2021-01-01 0.38
2021-01-02 0.41
2021-01-03 0.30
2021-01-04 0.35
2021-01-05 0.76
2021-01-06 0.40
view(mpdw)
# Train-test Split (80/20)
train <- mpdw[1:363,]
test <- mpdw[364:454,]
datampdw <- ts(mpdw$`Data CO`, start = 2021)
ts.plot(datampdw, main = "Kadar CO DKI Jakarta Tahun 2021 - 2022", ylab = "Harga", lwd = 1.5)
points(datampdw)
legend("topleft", c("Premium"), cex = 0.7,
       col = c("black", "red", "blue"), lty = 1)

plot(x = mpdw$t,
     y = mpdw$`Data CO`,
     col = "black",
     lwd = 1,
     type = "o",
     xlab = "Tahun",
     ylab = "Kadar CO DKI Jakarta",
     main = "Time Series Plot Kadar CO DKI Jakarta")

# Time-Series Object
data.ts <- ts(mpdw[,2], start = 2020, frequency = 91)
train.ts <- ts(train)
test.ts <- ts(test)
acf(mpdw$`Data CO`, lag = 35, start= 1)
## Warning in plot.window(...): "start" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "start" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "start" is not a
## graphical parameter

## Warning in axis(side = side, at = at, labels = labels, ...): "start" is not a
## graphical parameter
## Warning in box(...): "start" is not a graphical parameter
## Warning in title(...): "start" is not a graphical parameter

pacf(mpdw$`Data CO`, lag =35)

adf.test(data.ts)
## Warning in adf.test(data.ts): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  data.ts
## Dickey-Fuller = -4.8343, Lag order = 7, p-value = 0.01
## alternative hypothesis: stationary

ARIMA

CEK TAILS OFF/CUT OFF

ggAcf(ts(mpdw$`Data CO`),col="white",lwd=2)+labs( x="Lag",y = "ACF",
         title="Plot ACF Data CO DKI Jakarta ",
        subtitle = "(Polusi udara 2021-2022)")+
  theme_ft_rc()+
  theme(
    plot.title = element_text(size = 14L,
                              face = "bold",
                              hjust = 0.5),
    plot.subtitle = element_text(size = 11L,
                              face = "plain",
                              hjust = 0.5),plot.background=element_rect(fill="#141415",color="#141415"),panel.background=element_rect(fill="#141415",color="#141415"),
      axis.title = element_text(color="white"),axis.text = element_text(color="white")
  )
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

ggPacf(ts(mpdw$`Data CO`),col="white",lwd=2)+labs( x="Lag",y = "PACF",
         title="Plot PACF Kadar CO DKI Jakarta  ",
        subtitle = "(Juli 2012-2022)",col="white")+
  theme_ft_rc()+
  theme(
    plot.title = element_text(size = 14L,
                              face = "bold",
                              hjust = 0.5),
    plot.subtitle = element_text(size = 11L,
                              face = "plain",
                              hjust = 0.5),plot.background=element_rect(fill="#141415",color="#141415"),panel.background=element_rect(fill="#141415",color="#141415"),
      axis.title = element_text(color="white"),axis.text = element_text(color="white")
  )
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

Uji Statistik

adf.test(data.ts)
## Warning in adf.test(data.ts): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  data.ts
## Dickey-Fuller = -4.8343, Lag order = 7, p-value = 0.01
## alternative hypothesis: stationary
options(knitr.duplicate.label = "allow")

SUdah Stasioner

EACF

eacf(data.ts)
## AR/MA
##   0 1 2 3 4 5 6 7 8 9 10 11 12 13
## 0 x x x x x x x x x x o  o  o  o 
## 1 o o x x x o o o o x o  o  o  o 
## 2 x o x o x o o o o o x  o  o  o 
## 3 x x x o o o o o o o x  o  o  o 
## 4 x x x x x o o o o o x  o  o  o 
## 5 x x x x x x o o o o x  o  o  o 
## 6 x x x o o x o o o o x  o  o  o 
## 7 x x x x o x o o o o o  o  o  o

ARIMA (1,0,5) ARIMA (1,0,6) ARIMA (0,0,10) ARIMA (1,0,10)

Perbandingan Kebaikan Model Tentatif

model1 <- Arima(data.ts,order = c(1,0,5),method ="ML")
model2 <- Arima(data.ts,order = c(1,0,6),method ="ML")
model3 <- Arima(data.ts,order = c(0,0,10),method ="ML")
model4 <- Arima(data.ts,order = c(1,1,5),method = "ML")
model5 <- Arima(data.ts,order = c(1,0,10),method = "ML")
summary(model5)
## Series: data.ts 
## ARIMA(1,0,10) with non-zero mean 
## 
## Coefficients:
##           ar1     ma1     ma2     ma3     ma4     ma5     ma6     ma7     ma8
##       -0.4787  1.0682  0.5657  0.2628  0.2756  0.1804  0.0994  0.0933  0.1639
## s.e.   0.2573  0.2572  0.1645  0.0988  0.0821  0.0938  0.0769  0.0757  0.0739
##          ma9    ma10    mean
##       0.1792  0.1606  1.0388
## s.e.  0.0667  0.0445  0.0338
## 
## sigma^2 = 0.07164:  log likelihood = -40.12
## AIC=106.24   AICc=107.07   BIC=159.77
## 
## Training set error measures:
##                       ME      RMSE      MAE       MPE     MAPE      MASE
## Training set 0.001789545 0.2640976 0.209385 -6.970133 22.26822 0.5681048
##                       ACF1
## Training set -0.0009899079
Model <- c("ARIMA (1,0,5)","ARIMA (1,0,6)","ARIMA (0,0,10)","ARIMA (1,1,5)","ARIMA (1,0,10")
AIC <- c(model1$aic,model2$aic,model3$aic,model4$aic,model5$aic)
BIC <- c(model1$bic,model2$bic,model3$bic,model4$bic,model5$bic)
Akurasi <- data.frame(Model,AIC,BIC)
kableExtra::kable(Akurasi)
Model AIC BIC
ARIMA (1,0,5) 105.2526 138.1974
ARIMA (1,0,6) 107.1280 144.1908
ARIMA (0,0,10) 105.6776 155.0947
ARIMA (1,1,5) 111.1426 139.9539
ARIMA (1,0,10 106.2388 159.7740
model6 <- auto.arima(data.ts)
summary(model6)
## Series: data.ts 
## ARIMA(1,0,0)(1,0,0)[91] with non-zero mean 
## 
## Coefficients:
##          ar1    sar1    mean
##       0.5745  0.0303  1.0401
## s.e.  0.0375  0.0509  0.0306
## 
## sigma^2 = 0.07433:  log likelihood = -52.92
## AIC=113.84   AICc=113.93   BIC=130.32
## 
## Training set error measures:
##                       ME      RMSE       MAE       MPE     MAPE      MASE
## Training set 0.001117116 0.2717418 0.2132066 -7.409326 22.82473 0.5784736
##                     ACF1
## Training set 0.002919417
coeftest(model6)
## 
## z test of coefficients:
## 
##           Estimate Std. Error z value Pr(>|z|)    
## ar1       0.574543   0.037526 15.3106   <2e-16 ***
## sar1      0.030340   0.050884  0.5963    0.551    
## intercept 1.040099   0.030639 33.9467   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
paste("Model yang terbaik adalah model",Akurasi$Model[which.min(Akurasi[,"AIC"])])
## [1] "Model yang terbaik adalah model ARIMA (1,0,5)"
coeftest(model1)
## 
## z test of coefficients:
## 
##            Estimate Std. Error z value  Pr(>|z|)    
## ar1        0.922349   0.052995 17.4045 < 2.2e-16 ***
## ma1       -0.337115   0.071384 -4.7225 2.329e-06 ***
## ma2       -0.248415   0.057858 -4.2935 1.759e-05 ***
## ma3       -0.153593   0.052832 -2.9072  0.003647 ** 
## ma4        0.108716   0.050292  2.1617  0.030642 *  
## ma5       -0.093699   0.054761 -1.7110  0.087073 .  
## intercept  1.036335   0.043863 23.6266 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(model1)
## Series: data.ts 
## ARIMA(1,0,5) with non-zero mean 
## 
## Coefficients:
##          ar1      ma1      ma2      ma3     ma4      ma5    mean
##       0.9223  -0.3371  -0.2484  -0.1536  0.1087  -0.0937  1.0363
## s.e.  0.0530   0.0714   0.0579   0.0528  0.0503   0.0548  0.0439
## 
## sigma^2 = 0.07229:  log likelihood = -44.63
## AIC=105.25   AICc=105.58   BIC=138.2
## 
## Training set error measures:
##                       ME     RMSE       MAE       MPE     MAPE      MASE
## Training set 0.002939849 0.266793 0.2092675 -6.894237 22.24377 0.5677862
##                    ACF1
## Training set -0.0053471

Signifikan semua

coeftest(model4)
## 
## z test of coefficients:
## 
##      Estimate Std. Error z value Pr(>|z|)   
## ar1  0.129202   0.274105  0.4714 0.637384   
## ma1 -0.529883   0.270387 -1.9597 0.050029 . 
## ma2 -0.231853   0.116862 -1.9840 0.047257 * 
## ma3 -0.137042   0.095664 -1.4325 0.151992   
## ma4  0.111462   0.075964  1.4673 0.142298   
## ma5 -0.145583   0.049091 -2.9656 0.003021 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
sisaan <- model1$residuals
par(mfrow=c(2,2))
par(bg = '#141415')
qqnorm(sisaan)
box(col="white",lwd=2)
qqline(sisaan, col = "red", lwd =1, col.lab="white",
       col.axis="white",col.sub = "white")
box(col="white",lwd=2)
plot(c(1:length(sisaan)),sisaan,col="white",col.lab="white",col.axis="white")
box(col="white",lwd=2)
acf(sisaan,col="white",col.sub = "white",col.axis="white", col.lab="white")
box(col="white",lwd=2)
pacf(sisaan,col="white",col.sub = "white",col.axis="white", col.lab="white",col.main="white")
box(col="white",lwd=2)

Berdasarkan hasil eksplorasi menggunakan Q-Q plot, terlihat bahwa sisaan berdistribusi mengikuti garis normal, sehingga dapat dikatakan bahwa sisaan menyebar normal. Kemudian, plot sisaan yang diperoleh menunjukkan bahwa sisaan memiliki pola acak dan tersebar di sekitar nilai nol. Sedangkan pada plot ACF dan PACF, nilai awal amatan tidak melewati garis signifikan, atau dapat dikatakan bahwa sisaan saling bebas.

Diagnostik Model: Uji Formal

1. Sisaan Menyebar Normal

Uji formal ini dilakukan dengan Jarque Bera test dan Shapiro-Wilk test.

Hipotesis yang diuji: H0 : Sisaan Menyebar Normal H1: Sisaan Tidak Menyebar Normal

jarque.bera.test(sisaan)
## 
##  Jarque Bera Test
## 
## data:  sisaan
## X-squared = 12.305, df = 2, p-value = 0.002128
shapiro.test(sisaan)
## 
##  Shapiro-Wilk normality test
## 
## data:  sisaan
## W = 0.98896, p-value = 0.001686

2. Sisaan Saling Bebas

Uji formal ini dilakukan dengan LJung-Box test.

Hipotesis yang diuji: H0 : Sisaan antara lag saling bebas H1: Sisaan antara lag tidak saling bebas

Box.test(sisaan, type = "Ljung")
## 
##  Box-Ljung test
## 
## data:  sisaan
## X-squared = 0.013066, df = 1, p-value = 0.909

Berdasarkan LJung-Box test, diperoleh p-value (0.909) > α (0.05), maka tak tolak H0. Artinya, cukup bukti untuk menyatakan bahwa sisaan antara lag saling bebas atau dapat dikatakan tidak ada autokorelasi antara sisaan lag pada taraf nyata 5%.

3. Nilai Tengah Sisaan Sama dengan Nol

Uji formal ini dilakukan dengan t-test.

Hipotesis yang diuji: H0 : Nilai tengah sisaan sama dengan nol H1: Nilai tengah sisaan tidak sama dengan nol

t.test(sisaan, mu = 0, conf.level = 0.95)
## 
##  One Sample t-test
## 
## data:  sisaan
## t = 0.23454, df = 453, p-value = 0.8147
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  -0.02169267  0.02757237
## sample estimates:
##   mean of x 
## 0.002939849

FORECASTING

ramalan <- forecast::forecast(Arima(train.ts[,2], order=c(1,0,5),method="ML",include.drift = TRUE), h=10) 
data.ramalan <- ramalan$mean
plot(ramalan,lwd=2)

over2 <- Arima(train.ts[,2], order = c(2,0,4) )
summary(model1)
## Series: data.ts 
## ARIMA(1,0,5) with non-zero mean 
## 
## Coefficients:
##          ar1      ma1      ma2      ma3     ma4      ma5    mean
##       0.9223  -0.3371  -0.2484  -0.1536  0.1087  -0.0937  1.0363
## s.e.  0.0530   0.0714   0.0579   0.0528  0.0503   0.0548  0.0439
## 
## sigma^2 = 0.07229:  log likelihood = -44.63
## AIC=105.25   AICc=105.58   BIC=138.2
## 
## Training set error measures:
##                       ME     RMSE       MAE       MPE     MAPE      MASE
## Training set 0.002939849 0.266793 0.2092675 -6.894237 22.24377 0.5677862
##                    ACF1
## Training set -0.0053471
summary(model2)
## Series: data.ts 
## ARIMA(1,0,6) with non-zero mean 
## 
## Coefficients:
##          ar1      ma1      ma2      ma3     ma4      ma5     ma6    mean
##       0.9162  -0.3339  -0.2445  -0.1542  0.1070  -0.0937  0.0167  1.0365
## s.e.  0.0571   0.0732   0.0591   0.0537  0.0503   0.0546  0.0472  0.0438
## 
## sigma^2 = 0.07243:  log likelihood = -44.56
## AIC=107.13   AICc=107.53   BIC=144.19
## 
## Training set error measures:
##                       ME      RMSE       MAE       MPE     MAPE      MASE
## Training set 0.002919148 0.2667553 0.2093248 -6.905529 22.25193 0.5679417
##                      ACF1
## Training set -0.003182477
summary(model3)
## Series: data.ts 
## ARIMA(0,0,10) with non-zero mean 
## 
## Coefficients:
##          ma1     ma2     ma3     ma4     ma5     ma6     ma7     ma8     ma9
##       0.5931  0.2890  0.1314  0.2091  0.0782  0.0623  0.0681  0.1256  0.1337
## s.e.  0.0470  0.0543  0.0567  0.0580  0.0591  0.0577  0.0553  0.0544  0.0499
##         ma10    mean
##       0.1462  1.0387
## s.e.  0.0479  0.0350
## 
## sigma^2 = 0.07172:  log likelihood = -40.84
## AIC=105.68   AICc=106.39   BIC=155.09
## 
## Training set error measures:
##                       ME      RMSE       MAE       MPE     MAPE      MASE
## Training set 0.001912595 0.2645338 0.2096406 -6.926985 22.28423 0.5687984
##                      ACF1
## Training set -0.008607111
summary(model4)
## Series: data.ts 
## ARIMA(1,1,5) 
## 
## Coefficients:
##          ar1      ma1      ma2      ma3     ma4      ma5
##       0.1292  -0.5299  -0.2319  -0.1370  0.1115  -0.1456
## s.e.  0.2741   0.2704   0.1169   0.0957  0.0760   0.0491
## 
## sigma^2 = 0.07326:  log likelihood = -48.57
## AIC=111.14   AICc=111.39   BIC=139.95
## 
## Training set error measures:
##                      ME      RMSE      MAE       MPE     MAPE      MASE
## Training set 0.01196715 0.2685653 0.209047 -5.261551 21.64866 0.5671878
##                       ACF1
## Training set -0.0006589821
over3 <- Arima(test.ts[,2], order = c(1,0,5))
summary(over3)
## Series: test.ts[, 2] 
## ARIMA(1,0,5) with non-zero mean 
## 
## Coefficients:
##          ar1      ma1      ma2      ma3     ma4      ma5    mean
##       0.8200  -0.1841  -0.5219  -0.2249  0.0898  -0.1589  1.0691
## s.e.  0.1001   0.1430   0.1235   0.1250  0.1292   0.1138  0.0120
## 
## sigma^2 = 0.07597:  log likelihood = -9.63
## AIC=35.25   AICc=37.01   BIC=55.34
## 
## Training set error measures:
##                       ME      RMSE       MAE       MPE     MAPE      MASE
## Training set 0.007734555 0.2648058 0.2127762 -5.414469 20.94837 0.9003225
##                    ACF1
## Training set -0.0141433
coeftest(over2)
## 
## z test of coefficients:
## 
##            Estimate Std. Error z value  Pr(>|z|)    
## ar1        0.462641   0.342551  1.3506  0.176831    
## ar2        0.400714   0.321138  1.2478  0.212107    
## ma1        0.088365   0.340875  0.2592  0.795458    
## ma2       -0.340981   0.146863 -2.3218  0.020246 *  
## ma3       -0.249598   0.082993 -3.0074  0.002635 ** 
## ma4        0.039732   0.090935  0.4369  0.662161    
## intercept  1.019902   0.052817 19.3102 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
perbandingan.temp<-matrix(data=c(test.ts[1:5], data.ramalan[1:5]), nrow = 5, ncol = 2)
colnames(perbandingan.temp)<-c("Aktual","Hasil Forecast")
head(perbandingan.temp)
##          Aktual Hasil Forecast
## [1,] 1640822400      0.9611172
## [2,] 1640908800      1.0259902
## [3,] 1640995200      1.0004032
## [4,] 1641081600      0.9623544
## [5,] 1641168000      0.9736433
accuracy(ramalan)
##                       ME      RMSE      MAE       MPE     MAPE      MASE
## Training set 0.001429286 0.2616619 0.207188 -7.256317 22.63398 0.8995209
##                      ACF1
## Training set -0.005858512
accuracy(ramalan,test = test.ts)
## Warning in trainingaccuracy(object, test, d, D): test elements must be within
## sample
##                      ME      RMSE       MAE      MPE    MAPE MASE ACF1
## Training set -0.5579996 0.5579996 0.5579996 -146.842 146.842  Inf  NaN