setwd("c:/Users/Ilham Kurnia/Documents/SEMESTER 6/UTS/MPDW")

library(TTR)
library(tseries)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(graphics)
library(forecast)

Dataset Daily Minimum Temperatures

setwd("c:/Users/Ilham Kurnia/Documents/SEMESTER 6/UTS/MPDW")
dt1<-read.csv("daily-minimum-temperatures-in-me.csv")
head(dt1)
##       Date Daily.minimum.temperatures
## 1 1/1/1990                       14.8
## 2 1/2/1990                       13.3
## 3 1/3/1990                       15.6
## 4 1/4/1990                       14.5
## 5 1/5/1990                       14.3
## 6 1/6/1990                       15.3

Menjadikan data time series dan membuat plot

dt1.ts1<-ts(dt1$Daily.minimum.temperatures)

ts.plot(dt1.ts1, xlab="Time Period", ylab ="Temperatures", main="Plot Data Time Series Daily Minimum Temperatures", col ="red")

Berdasarkan plot di atas terlihat bahwa data memiliki trend naik turun sehingga dapat diasmusikan tidak stationer.

Plot ACF dan PACF

acf(dt1.ts1, lag.max = 20, main = "Plot ACF Daily Minimum Temperatures")

pacf(dt1.ts1, lag.max = 20, main = "Plot ACF Daily Minimum Temperatures")

Plot ACF terlihat tails off atau menurun secara perlahan menunjukan data tidak tidak stationer. Sedangkan plot PACF terlihat cuts off setelah lag ke-1 menunjukan stationer dengan model tentatif AR(1). Selanjutnya melakukan Uji Augmented Fuller untuk uji lebih lanjut.

Uji Augmented Fuller

adf.test(dt1.ts1)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  dt1.ts1
## Dickey-Fuller = -2.3545, Lag order = 7, p-value = 0.4273
## alternative hypothesis: stationary

Berdasarkan Uji Augmented Fuller di atas kita mendapatkan p-value = 0.4273 H1 data stationer sehingga tak tolak H0. Artinya belum cukup bukti menyatakan bahwa data stationer pada taraf nyata 5%.

Melakukan differencing pertama dan Plot differrencing pertama

dif1 <- diff(dt1.ts1, differences = 1)

plot.ts(dif1, lty=1, ylab = expression(Ydif[t]), col = "red", main="Plot Data Time Series Daily Minimum Temperatures Setelah Differencing Pertama")

Berdasarkan plot di atas terlihat data sudah stationer karena rataan sudah konstan di satu titik.

Plot ACF dan PACF setelah Differencing pertama

acf(dif1, lag.max = 20, main="Plot ACF Daily Minimum Temperatures Setelah Differencing Pertama")

Pacf(dif1, lag.max = 20, main="Plot PACF Daily Minimum Temperatures Setelah Differencing Pertama")

Plot ACF terlihat stationer dengan cuts off setelah lag ke-3. Sedangkan Plot PACF terlihat tails off dengan model tentatif MA(3).

Uji Augmented Fuller setelah differencing pertama

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

Berdasarkan Uji Augmented Fuller di atas kita mendapatkan p-value = 0.01 H1 data stationer sehingga tolak H0. Artinya cukup bukti menyatakan bahwa data stationer pada taraf nyata 5%.

Electric Production

setwd("c:/Users/Ilham Kurnia/Documents/SEMESTER 6/UTS/MPDW")
dt2<-read.csv("Electric_Production.csv")
head(dt2)
##       DATE IPG2211A2N
## 1 1/1/1998    94.7920
## 2 2/1/1998    87.8200
## 3 3/1/1998    86.5549
## 4 4/1/1998    76.7521
## 5 5/1/1998    78.0303
## 6 6/1/1998    86.4579

Menjadikan data time series dan membuat plot

dt2.ts2<-ts(dt2$IPG2211A2N)

ts.plot(dt2.ts2, xlab="Time Period", ylab ="Electric Production", main="Plot Data Time Series Electric Producton", col ="red")

Berdasarkan plot di atas terlihat bahwa data relatif konstan sehingga dapat diasmusikan stationer.

Plot ACF dan PACF

acf(dt2.ts2, lag.max = 20, main = "Plot ACF Electric Production")

pacf(dt2.ts2, lag.max = 20, main = "Plot ACF Electric Production")

Plot ACF terlihat cuts off setelah lag ke-1 menunjukan data stationer. Sedangkan plot PACF terlihat tail off setelah lag ke-1 menunjukan stationer.

Uji Augmented Fuller

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

Berdasarkan Uji Augmented Fuller di atas kita mendapatkan p-value = 0.01 H1 data stationer sehingga tolak H0. Artinya cukup bukti menyatakan bahwa data stationer pada taraf nyata 5%.

Monthly Beer Production In Austr

setwd("c:/Users/Ilham Kurnia/Documents/SEMESTER 6/UTS/MPDW")
dt3<-read.csv("monthly-beer-production-in-austr.csv")
head(dt3)
##     Month Monthly.beer.production
## 1 1986-01                   161.2
## 2 1986-02                   155.5
## 3 1986-03                   141.9
## 4 1986-04                   164.6
## 5 1986-05                   136.2
## 6 1986-06                   126.8

Menjadikan data time series dan membuat plot

dt3.ts3<-ts(dt3$Monthly.beer.production)

ts.plot(dt3.ts3, xlab="Time Period", ylab ="Beer Production", main="Plot Data Time Series Electric Producton in Austr", col ="red")

Berdasarkan plot di atas terlihat bahwa data relatif konstan sehingga dapat diasmusikan stationer.

Plot ACF dan PACF

acf(dt3.ts3, lag.max = 20, main = "Plot ACF Electric Production")

pacf(dt3.ts3, lag.max = 20, main = "Plot ACF Electric Production")

Plot ACF terlihat cuts off setelah lag ke-1 menunjukan data stationer. Sedangkan plot PACF terlihat tail off setelah lag ke-1 menunjukan stationer.

Uji Augmented Fuller

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

Berdasarkan Uji Augmented Fuller di atas kita mendapatkan p-value = 0.01 H1 data stationer sehingga tolak H0. Artinya cukup bukti menyatakan bahwa data stationer pada taraf nyata 5%

Kesimpulan

Berdasarkan eksploratif dengan plot CF dan PACF atau Uji Augmented Dickey Fuller. Data Daily Minimum temperature tidak stationer. Sehingga dilakukan differencing satu kali sampai stationer. Data Electric Production dan Beer Production in Austr.