Nomor 1

library(TTR)
## Warning: package 'TTR' was built under R version 4.0.3
library(TSA)
## Warning: package 'TSA' was built under R version 4.0.3
## 
## Attaching package: 'TSA'
## The following objects are masked from 'package:stats':
## 
##     acf, arima
## The following object is masked from 'package:utils':
## 
##     tar
library(tseries)
## Warning: package 'tseries' was built under R version 4.0.3
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(graphics)
library(forecast)
## Warning: package 'forecast' was built under R version 4.0.3
## Registered S3 methods overwritten by 'forecast':
##   method       from
##   fitted.Arima TSA 
##   plot.Arima   TSA

1.A Membangkitkan Data

Bangkitkan data \(y_t\), (n=200),berupa model ARIMA(0,2,2) dengan \(μ=0.25\), \(θ_1=0.60\), \(θ_2=−0.75\) dan \(e_t~Normal(0,1)\). Gunakan 175 data terakhir dan lakukan proses berikut :

set.seed(1001) 
e <- rnorm(200,0,1)
n <- length(e)

Model \(Y_t\) diperoleh dari penguraian operator backshift sehingga perlu dilakukan penguraian operator backshift terlebih dahulu untuk ARIMA(0,2,2)

\[\phi_p(1−B)^dY_t=μ+θ_q(B)e_t\] \[(1−B)^2Y_t=μ+θ_2(B)e_t\] \[(1−2B+B^2)Y_t=μ+(1−θ_1(B)−θ_2B^2)e_t\] \[Y_t−2Y_{t−1}+Y_{t−2}=μ+e_t−θ_1e_{t−1}−θ_2e_{t−2}\] \[Y_t=μ+2Y_{t−1}−Y_{t−2}+e_t−θ_1e_{t−1}−θ_2e_{t−2}\]

Karena data yang digunakan adalah 175 data terakhir, maka setelah model \(Y_t\) diperoleh, selanjutnya membangun model dari data yang dibangkitkan dan membuang 25 data pertama.

mu <- 0.25 
tetha1 <- 0.6 
tetha2 <- -0.75

y <- c(1:n) 
for (i in 3:n)
{y[i] <- mu+(2*y[i-1])-y[i-2]+e[i]-tetha1*e[i-1]-tetha2*e[i-2]}  
y <- y[-c(1:25)]

1.B Melihat Kestasioneran

Mengidentifikasi kestasioneran data dengan membuat time-series plot, correlogram, dan uji ADF.

head(y)
## [1]  77.14272  84.90893  93.81295 100.84344 107.07292 114.52199
# Plot time-series
plot.ts(y,lty=1,ylab=expression(Y[t]))
points(y)

Pola dari plot data \(Y_t\) tersebut tidak membentuk pola yang stasioner.

#Plot Correlogram ACF
acf(y,lag.max = 20)

Plot correlogram menunjukkan pola yang menurun secara perlahan, dimana hal tersebut mengindikasikan bahwa data tersebut tidak stasioner.

#Uji ADF
adf.test(y, alternative = c("stationary"),k=trunc((length(y)-1)^(1/3)))
## 
##  Augmented Dickey-Fuller Test
## 
## data:  y
## Dickey-Fuller = -0.30197, Lag order = 5, p-value = 0.9897
## alternative hypothesis: stationary

Terlihat bahwa nilai \(p−value=0.9897>α=0.05\) sehingga terima \(H_0\) yang artinya data tidak stasioner.

Berdasarkan ketiga metode di atas, disimpulkan bahwa data yang digunakan tidak stasioner sehingga diperlukan proses differencing.

1.C Differencing Ordo 1

y.dif1<-diff(y,differences = 1) 
plot.ts(y.dif1,lty=1)
points(y.dif1)

Melihat Kestasioneran Ordo 1

#Plot Correlogram ACF
acf(y.dif1,lag.max = 20) 

Plot correlogram masih menunjukkan pola yang menurun secara perlahan.

#Uji ADF
adf.test(y.dif1, alternative = c("stationary"),k=trunc((length(y)-1)^(1/3)))
## 
##  Augmented Dickey-Fuller Test
## 
## data:  y.dif1
## Dickey-Fuller = -3.3436, Lag order = 5, p-value = 0.06611
## alternative hypothesis: stationary

Hasil differencing ordo 1 diperoleh bahwa data yang digunakan belum stasioner karena nilai \(p−value=0.066>α=0.05\) sehingga perlu dilakukan differencing ordo 2.

1.D Differencing Ordo 2

y.dif2 <- diff(y,differences = 2)
acf(y.dif2,lag.max = 20) 

head(y.dif2)
## [1]  1.1378045 -1.8735359 -0.8009995  1.2195886 -0.9668539  0.3335778
plot.ts(y.dif2,lty=1)
points(y.dif2)

Melihat Kestasioneran Differencing Ordo 2

adf.test(y.dif2, alternative = c("stationary"),k=trunc((length(y)-1)^(1/3)))
## Warning in adf.test(y.dif2, alternative = c("stationary"), k = trunc((length(y)
## - : p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  y.dif2
## Dickey-Fuller = -5.594, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary

Hasil differencing ordo 2 menunjukkan bahwa data sudah stasioner dikarenakan nilai \(p−value=0.01<α=0.05\) dan didukung oleh plot time-series yang fluktuatif dan plot ACF yang tidak lagi menunjukkan trend.

Kemudian proses selanjutnya adalah mengidentifikasi kandidat model.

1.E Identifikasi Kandidat Model

Menentukan nilai d dan q pada model ARIMA(p,d,q).

acf(y.dif2,lag.max = 100)

Plot ACF menunjukkan cuts off setelah lag kedua.

pacf(y.dif2,lag.max = 100)

plot PACF menunjukkan tails off.

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

Dan untuk plot EACF tanda silang mulai berhenti pada pertemuan angka 2 dengen 0. Karena telah dilakukan differencing sebanyak dua kali, maka dapat disimpulkan model yang tepat adalah ARIMA(0,2,2) dengan \(p=0,d=2,q=2\).

Nomor 2

2.A Membangkitkan Data

set.seed(1234) 
e2 <- rnorm(200,0,1) 
n2 <- length(e2)

Seperti nomor 1 sebelumnya, model \(Y_t\) akan diperoleh dari penguraian operator backshift untuk ARIMA(2,2,2)

\[\phi_p(1−B)^dY_t=μ+θ_q(B)e_t\] \[\phi_2(B)(1−B)^2Y_t=μ+θ_2(B)e_t\] \[(1−\phi_1B−\phi_2B^2)(1−2B+B^2)Y_t=μ+(1−θ_1(B)−θ_2B^2)e_t\] \[(1−2B+B^2−\phi_1B+2\phi_1B^2−\phi_1B^3−\phi_2B^2+2\phi_2B^3−\phi_2B^4)Y_t=μ+(1−θ_1B−θ_2B^2)+e_t\] \[Y_t−2Y_{t−1}+Y_{t−2}−\phi_1Y_{t−1}+2\phi_1Y_{t−2}−\phi_1Y_{t−3}−\phi_2Y_{t−2}+2\phi_2Y_{t−3}−\phi_2Y_{t−4}=μ+e_t−θ_1e_{t−1}−θ_2e_{t−2}\] \[Y_t−(2+\phi_1)Y_{t−1}−(\phi_2−2\phi_1−1)Y_{t−2}−(\phi_1−2\phi_2)Y_{t−3}−\phi_2Y_{t−4}=μ+e_t−\phi_1e_{t−1}−θ_2e_{t−2}\] \[Y_t=μ+(2+\phi_1)Y_{t−1}+(\phi_2−2\phi_1−1)Y_{t−2}+(\phi_1−2\phi_2)Y_t−3+\phi_2Y_{t−4}+e_t−\phi_1e_{t−1}−θ_2e_{t−2}\]

Karena data yang digunakan adalah 175 data terakhir, maka setelah model \(Y_t\) diperoleh, selanjutnya membangun model dari data yang dibangkitkan dan membuang 25 data pertama.

mu2 <- 0.15
phi1 <- 0.55
phi2 <- -0.80 
tetha12 <- -0.35
tetha22 <- 0.70

x <- c(1:n2) 
for (i in 5:n2)
{x[i] <- mu+((2+phi1)*x[i-1])+((phi2-2*phi1-1)* x[i-2])+(phi1-2*phi2)*x[i-3]+
  phi2*x[i-4]+e[i]-tetha12*e[i-1]-tetha22*e[i-2]} 
x <- x[-c(1:25)]

2.B Melihat Kestasioneran

Mengidentifikasi kestasioneran data dengan membuat time-series plot, correlogram, dan uji ADF.

head(y)
## [1]  77.14272  84.90893  93.81295 100.84344 107.07292 114.52199
# Plot time-series
plot.ts(y,lty=1,ylab=expression(x[t]))
points(y)

Pola dari plot data \(Y_t\) tersebut tidak membentuk pola yang stasioner.

#Plot Correlogram ACF
acf(x,lag.max = 20)

Plot correlogram masih menunjukkan pola yang menurun secara perlahan.

#Uji ADF
adf.test(x, alternative = c("stationary"),k=trunc((length(y)-1)^(1/3)))
## Warning in adf.test(x, alternative = c("stationary"), k = trunc((length(y) - :
## p-value greater than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  x
## Dickey-Fuller = 0.12151, Lag order = 5, p-value = 0.99
## alternative hypothesis: stationary

Terlihat bahwa nilai \(p−value=0.99>α=0.05\) sehingga terima \(H_0\) yang artinya data tidak stasioner.

Berdasarkan ketiga metode di atas, disimpulkan bahwa data yang digunakan tidak stasioner sehingga diperlukan proses differencing.

2.C Differencing Ordo 1

x.dif1<-diff(x,differences = 1) 
plot.ts(x.dif1,lty=1)
points(x.dif1)

Melihat Kestasioneran Differencing Ordo 1

#Plot Correglogram ACF
acf(x.dif1,lag.max = 20)

Plot correlogram masih menunjukkan pola yang menurun secara perlahan.

#Uji ADF
adf.test(x.dif1, alternative = c("stationary"),k=trunc((length(y)-1)^(1/3)))
## Warning in adf.test(x.dif1, alternative = c("stationary"), k = trunc((length(y)
## - : p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  x.dif1
## Dickey-Fuller = -4.1655, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary

Hasil differencing ordo 1 diperoleh nilai \(p−value=0.01<α=0.05\) yang berarti tolak \(H_0\) artinya data stasioner. Namun pada plot ACF masih menunjukkan adanya trend, maka perlu dilakukan differencing ordo 2 untuk lebih meyakinkan kesimpulan.

2.D Differencing Ordo 2

x.dif2 <- diff(x,differences = 2)
head(x.dif2)
## [1] -0.3989602  1.6244108 -0.4217026 -0.9362163  1.5510166  1.4592066
plot.ts(x.dif2,lty=1)
points(x.dif2)

Melihat Kestasioneran Differencing Ordo 2

acf(x.dif2,lag.max = 20) 

adf.test(x.dif2, alternative = c("stationary"), k=trunc((length(y)-1)^(1/3)))
## Warning in adf.test(x.dif2, alternative = c("stationary"), k = trunc((length(y)
## - : p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  x.dif2
## Dickey-Fuller = -9.7538, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary

Hasil differencing ordo 2 menunjukkan bahwa data sudah stasioner dikarenakan nilai \(p−value=0.01<α=0.05\) dan didukung oleh plot time-series yang fluktuatif dan plot ACF yang tidak lagi menunjukkan trend.

Kemudian proses selanjutnya adalah mengidentifikasi kandidat model.

2.E Identifikasi Kandidat Model

Menentukan nilai d dan q pada model ARIMA(p,d,q).

acf(x.dif2,lag.max = 20)

Plot ACF menunjukkan cuts off pada lag kedua.

pacf(x.dif2,lag.max = 20)

plot PACF menunjukkan tails off.

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

Kemudian plot EACF tanda silang mulai berhenti pada pertemuan angka 2 dengan 2. Karena telah dilakukan differencing sebanyak dua kali, maka dapat disimpulkan model yang tepat adalah ARIMA(2,2,2) dengan \(p=2,d=2,q=2\).