Proses MA

Proses MA dapat dituliskan sebagai berikut:

\[ y_{t} = c + e_t + \theta_{1}e_{t-1} + \theta_{2}e_{t-2} + \dots + \theta_{q}e_{t-q} = c+{e_t+\sum_{i=1}^p \theta_ie_{t-i}} \] Terlihat bahwa \(e_t\), atau white noise, berperan penting dalam pembangkitan proses MA.

Membangkitkan white noise

set.seed(008)
wn <- rnorm(300)
ma2 = wn[c(1,2)]

MA(2) dengan \(\theta_1 = 0.4\) dan \(\theta_2 = 0.6\)

$ Y_t = e_t+0.4e_{t-1}+0.6e_{t-2}$

for(i in 3:300){
   ma2[i] <- wn[i] + 0.4 * wn[i - 1] +  0.6 * wn[i - 2]
}
ma2
##   [1] -0.084586071  0.840400126 -0.178074365 -0.231988038  0.237616767
##   [6] -0.143966231  0.228182549 -1.221176213 -3.548557850 -2.450594030
##  [11] -2.803694535 -0.367772255  0.082342262 -0.950699725 -0.195671387
##  [16] -1.562017890  1.227208735 -0.155090737  2.356122220  0.222986373
##  [21]  2.123135291  0.361349595  0.365995093 -0.143741270  1.511511962
##  [26] -0.396875833 -0.457698717  0.862661031  0.746877581 -0.608829992
##  [31]  1.060055796  0.354015618 -0.264401651 -0.816972290  0.018986157
##  [36]  0.468581534  1.772432622 -0.104243670  0.162227625  0.025548404
##  [41]  0.512976714 -0.186565473  0.201227300 -0.539210663  0.645102831
##  [46] -1.869824197 -1.079018874 -1.156182969 -0.015871513 -0.362345046
##  [51]  0.985140148 -0.317228679  1.091277613 -0.079437596  1.286688610
##  [56]  0.909414479  0.037118728 -0.564630150 -2.205960357 -0.206069608
##  [61] -0.040631951  0.770292931 -1.409113963 -1.764442693 -1.779829598
##  [66] -1.848907645 -1.082281618  0.796745452  0.757765179 -0.455843795
##  [71] -1.868853325 -0.505782218  0.318272041  0.460118708  0.372884666
##  [76]  0.350331359 -2.601291443 -0.215834882  0.871183264  0.654389302
##  [81]  1.410214175 -1.080022855 -1.263655329  1.133431666 -1.519710384
##  [86]  1.769514082 -0.618410466 -0.260513994  0.163273595 -3.344857721
##  [91] -0.075566997  0.068019497  0.586550786  0.122390269 -1.900217334
##  [96] -0.142217816 -0.173754907  0.549094735 -0.457214073 -0.350665045
## [101] -0.113204186 -1.823402723 -2.229484305 -3.577695837 -1.664838148
## [106] -1.547612335  0.430692394 -0.418074740  0.386715360  0.415177496
## [111]  0.171729099 -0.560282716  0.118412491 -1.372023321  1.344800377
## [116]  1.314875206  1.685962526  2.379846471 -0.457738095  0.091289696
## [121] -1.978509953 -2.358332709 -1.744945319  0.641280109  0.984608692
## [126]  1.424829753 -1.383251161 -0.329549009 -2.287761687  0.456238930
## [131]  1.742136947  1.563770538 -0.096312061 -1.843494294 -3.840084901
## [136] -0.974882924 -0.679349879  1.157494872  1.895949891 -0.958557420
## [141]  1.466798819  1.876805294  2.458183529 -0.234839579 -0.301049161
## [146] -1.854005037  0.363573481  0.611819023 -0.354172827 -0.354393478
## [151] -0.626221241 -0.752159974  0.097769091  0.009393303 -0.098365321
## [156]  0.323739473  0.643645592 -0.212654992  0.822078834  1.578909999
## [161]  1.408405093  1.740105944 -0.986658398 -1.213709402  0.316102814
## [166]  0.230412336  0.629982171  0.886717313 -0.244473870  1.144118580
## [171] -1.113327354  0.249693376 -0.955559354  1.011088215 -0.085874736
## [176]  0.965768149  0.799093468  1.534427557 -0.216982111  1.155997990
## [181] -1.480653680 -0.274082262 -0.695648565 -0.269470825  2.261928758
## [186]  0.881720704  3.456738100  1.928397464  1.482825102 -0.497893239
## [191] -0.668259856 -1.259039578 -1.216024163 -1.512257953  0.458281238
## [196]  1.086408870  1.766275300 -0.481934942 -2.121165026 -1.544339596
## [201] -1.727144323 -0.443129747  0.759880491 -1.013696013  0.155557640
## [206]  0.066957652  0.316151638 -0.356402156  0.396871238 -1.199062926
## [211]  0.598462753  0.560474825  1.038333642 -0.034161946  0.624723838
## [216] -0.478679269 -0.063455833 -0.182726947 -1.545227950  0.909923531
## [221] -1.150415768 -0.824652315 -0.146672590 -1.304513666 -0.232717654
## [226] -0.735502935 -0.122633677  0.130569750  0.291588034  1.601389809
## [231] -0.855627280  1.638309884 -0.686111864  0.521655800  0.585479524
## [236] -0.474398225 -0.157371068 -1.187299665 -1.320958200  0.744504963
## [241] -0.968501884  0.479238088  0.247800694  1.067962420  0.164066824
## [246]  1.079096842 -0.601172510  0.393255966 -0.360845861  0.306586594
## [251]  1.118733922  0.135125034 -0.899134686 -0.966743410 -1.119984199
## [256]  0.464763477  0.759439832 -0.196857214 -0.679114101 -0.939062483
## [261] -0.835748755  0.186789572 -0.586655248 -2.206204618  0.098597867
## [266] -0.391456185  0.216806663  0.202671150 -0.881657925 -1.441521256
## [271] -1.281860948  0.082469447  1.126566890  0.360348083  0.765503330
## [276] -1.044564064 -1.711572584 -1.405488876 -1.825673420 -0.151649868
## [281] -2.845542763 -0.275875322 -1.658997952 -0.059116247 -1.389538901
## [286] -0.386364176 -1.265677339 -0.221596517 -0.437285307  0.482710795
## [291] -0.023750642 -0.288389926  0.590375996  0.936859668 -0.709715297
## [296] -0.540875688 -0.839108473 -0.631974996  0.145358455 -1.717994900

Selain menggunakan cara di atas, pembangkitan proses MA(2) dapat dilakukan dengan fungsi arima.sim() sebagai berikut.

set.seed(008)
ma2. <- arima.sim(list(order=c(0,0,2), ma=c(0.4,0.6)), n=300)
ma2.
## Time Series:
## Start = 1 
## End = 300 
## Frequency = 1 
##   [1] -0.178074365 -0.231988038  0.237616767 -0.143966231  0.228182549
##   [6] -1.221176213 -3.548557850 -2.450594030 -2.803694535 -0.367772255
##  [11]  0.082342262 -0.950699725 -0.195671387 -1.562017890  1.227208735
##  [16] -0.155090737  2.356122220  0.222986373  2.123135291  0.361349595
##  [21]  0.365995093 -0.143741270  1.511511962 -0.396875833 -0.457698717
##  [26]  0.862661031  0.746877581 -0.608829992  1.060055796  0.354015618
##  [31] -0.264401651 -0.816972290  0.018986157  0.468581534  1.772432622
##  [36] -0.104243670  0.162227625  0.025548404  0.512976714 -0.186565473
##  [41]  0.201227300 -0.539210663  0.645102831 -1.869824197 -1.079018874
##  [46] -1.156182969 -0.015871513 -0.362345046  0.985140148 -0.317228679
##  [51]  1.091277613 -0.079437596  1.286688610  0.909414479  0.037118728
##  [56] -0.564630150 -2.205960357 -0.206069608 -0.040631951  0.770292931
##  [61] -1.409113963 -1.764442693 -1.779829598 -1.848907645 -1.082281618
##  [66]  0.796745452  0.757765179 -0.455843795 -1.868853325 -0.505782218
##  [71]  0.318272041  0.460118708  0.372884666  0.350331359 -2.601291443
##  [76] -0.215834882  0.871183264  0.654389302  1.410214175 -1.080022855
##  [81] -1.263655329  1.133431666 -1.519710384  1.769514082 -0.618410466
##  [86] -0.260513994  0.163273595 -3.344857721 -0.075566997  0.068019497
##  [91]  0.586550786  0.122390269 -1.900217334 -0.142217816 -0.173754907
##  [96]  0.549094735 -0.457214073 -0.350665045 -0.113204186 -1.823402723
## [101] -2.229484305 -3.577695837 -1.664838148 -1.547612335  0.430692394
## [106] -0.418074740  0.386715360  0.415177496  0.171729099 -0.560282716
## [111]  0.118412491 -1.372023321  1.344800377  1.314875206  1.685962526
## [116]  2.379846471 -0.457738095  0.091289696 -1.978509953 -2.358332709
## [121] -1.744945319  0.641280109  0.984608692  1.424829753 -1.383251161
## [126] -0.329549009 -2.287761687  0.456238930  1.742136947  1.563770538
## [131] -0.096312061 -1.843494294 -3.840084901 -0.974882924 -0.679349879
## [136]  1.157494872  1.895949891 -0.958557420  1.466798819  1.876805294
## [141]  2.458183529 -0.234839579 -0.301049161 -1.854005037  0.363573481
## [146]  0.611819023 -0.354172827 -0.354393478 -0.626221241 -0.752159974
## [151]  0.097769091  0.009393303 -0.098365321  0.323739473  0.643645592
## [156] -0.212654992  0.822078834  1.578909999  1.408405093  1.740105944
## [161] -0.986658398 -1.213709402  0.316102814  0.230412336  0.629982171
## [166]  0.886717313 -0.244473870  1.144118580 -1.113327354  0.249693376
## [171] -0.955559354  1.011088215 -0.085874736  0.965768149  0.799093468
## [176]  1.534427557 -0.216982111  1.155997990 -1.480653680 -0.274082262
## [181] -0.695648565 -0.269470825  2.261928758  0.881720704  3.456738100
## [186]  1.928397464  1.482825102 -0.497893239 -0.668259856 -1.259039578
## [191] -1.216024163 -1.512257953  0.458281238  1.086408870  1.766275300
## [196] -0.481934942 -2.121165026 -1.544339596 -1.727144323 -0.443129747
## [201]  0.759880491 -1.013696013  0.155557640  0.066957652  0.316151638
## [206] -0.356402156  0.396871238 -1.199062926  0.598462753  0.560474825
## [211]  1.038333642 -0.034161946  0.624723838 -0.478679269 -0.063455833
## [216] -0.182726947 -1.545227950  0.909923531 -1.150415768 -0.824652315
## [221] -0.146672590 -1.304513666 -0.232717654 -0.735502935 -0.122633677
## [226]  0.130569750  0.291588034  1.601389809 -0.855627280  1.638309884
## [231] -0.686111864  0.521655800  0.585479524 -0.474398225 -0.157371068
## [236] -1.187299665 -1.320958200  0.744504963 -0.968501884  0.479238088
## [241]  0.247800694  1.067962420  0.164066824  1.079096842 -0.601172510
## [246]  0.393255966 -0.360845861  0.306586594  1.118733922  0.135125034
## [251] -0.899134686 -0.966743410 -1.119984199  0.464763477  0.759439832
## [256] -0.196857214 -0.679114101 -0.939062483 -0.835748755  0.186789572
## [261] -0.586655248 -2.206204618  0.098597867 -0.391456185  0.216806663
## [266]  0.202671150 -0.881657925 -1.441521256 -1.281860948  0.082469447
## [271]  1.126566890  0.360348083  0.765503330 -1.044564064 -1.711572584
## [276] -1.405488876 -1.825673420 -0.151649868 -2.845542763 -0.275875322
## [281] -1.658997952 -0.059116247 -1.389538901 -0.386364176 -1.265677339
## [286] -0.221596517 -0.437285307  0.482710795 -0.023750642 -0.288389926
## [291]  0.590375996  0.936859668 -0.709715297 -0.540875688 -0.839108473
## [296] -0.631974996  0.145358455 -1.717994900 -1.427928956 -2.583092217

Karakteristik MA(2)

Plot Time Series

par(mfrow = c(1, 2))
ts.plot(ma2)
ts.plot(ma2.)

Berdasarkan plot time series, terlihat bahwa data MA(2) yang dibangkitkan stasioner dalam rataan

Plot ACF

par(mfrow = c(1, 2))
acf(ma2,lag.max = 20)
acf(ma2.,lag.max = 20)

Berdasarkan kedua plot AFC tersebut, terlihat bahwa plot ACF cuts off di lag kedua

Plot PACF

par(mfrow = c(1, 2))
pacf(ma2)
pacf(ma2.)

Berdasarkan plot PACF tersebut, terlihat bahwa plot PACF cenderung tails off dan membentuk gelombang sinus

Plot EACF

TSA::eacf(ma2)
## AR/MA
##   0 1 2 3 4 5 6 7 8 9 10 11 12 13
## 0 x x x x o o o o o o o  o  o  o 
## 1 x x x x o o o o o o o  o  o  o 
## 2 x x o o o x o o x o o  o  o  o 
## 3 x x o o o o o o x o o  o  o  o 
## 4 x x x o o o o o o o o  o  o  o 
## 5 x x o o o o 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 o x o o x o o x o o  o  o  o
TSA::eacf(ma2.)
## AR/MA
##   0 1 2 3 4 5 6 7 8 9 10 11 12 13
## 0 x x x x o o o o o o o  o  o  o 
## 1 x x x x o o o o o o o  o  o  o 
## 2 x x o o o x o o x o o  o  o  o 
## 3 x x x o o o o o x o o  o  o  o 
## 4 x x x o o o o o o o o  o  o  o 
## 5 x x o o o o 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 o x o o x o o x o o  o  o  o

Berdasarkan kedua pola segitiga nol pada plot EACF, terlihat bahwa segitiga nol berada pada ordo AR(0) dan ordo MA(2)

Scatterplot Antar Lag

Korelasi antara \(Y_t\) dengan \(Y_{t-1}\)

#Yt
yt_ma <- ma2[-1]
yt_ma. <- ma2.[-1]

#Yt-1
yt_1_ma <- ma2[-300]
yt_1_ma. <- ma2.[-300]
par(mfrow = c(1, 2))
plot(y=yt_ma,x=yt_1_ma)
plot(y=yt_ma.,x=yt_1_ma.)

Berdasarkan scatterplot tersebut, terlihat bahwa terdapat hubungan positif antara \(Y_t\) dengan \(Y_{t-1}\). Hal ini sesuai dengan teori yang ada

cor(yt_ma,yt_1_ma)
## [1] 0.3018363
cor(yt_ma.,yt_1_ma.)
## [1] 0.3111507

Korelasi antara \(Y_t\) dengan \(Y_{t-2}\)

#Yt
yt_ma2 <- ma2[-c(1,2)]
yt_ma2. <- ma2.[-c(1,2)]

#Yt-2
yt_2_ma <- ma2[-c(199,200)]
yt_2_ma. <- ma2.[-c(199,200)]
par(mfrow = c(1, 2))
plot(y=yt_ma2,x=yt_2_ma)
plot(y=yt_ma2.,x=yt_2_ma.)

Berdasarkan scatterplot tersebut, terlihat bahwa k terdapat hubungan linier positif yang kuat antara \(Y_t\) dengan \(Y_{t-2}\).

cor(yt_ma2,yt_2_ma)
## [1] 0.3739548
cor(yt_ma2.,yt_2_ma.)
## [1] 0.3876107

Korelasi antara \(Y_t\) dengan \(Y_{t-3}\)

#Yt
yt_ma3<- ma2[-c(1,2,3)]
yt_ma3.<- ma2.[-c(1,2,3)]

#Yt-3
yt_3_ma <- ma2[-c(288,299,300)]
yt_3_ma. <- ma2.[-c(288,299,300)]
par(mfrow=c(1,2))
plot(y=yt_ma3,x=yt_3_ma)
plot(y=yt_ma3.,x=yt_3_ma.)

Berdasarkan scatterplot tersebut, terlihat bahwa cenderung tidak terdapat hubungan antara \(Y_t\) dengan \(Y_{t-3}\).

par(mfrow=c(1,2))
cor(yt_ma3,yt_3_ma)
## [1] -0.1449357
cor(yt_ma3.,yt_3_ma.)
## [1] -0.1350934

Korelasi antara \(Y_t\) dengan \(Y_{t-3}\) hasil simulasi mendekati teori yang ada yaitu 0.

Proses AR

Pembangkitan Proses AR(2) dengan $_1=0.5 dan \(\phi_2=0.2\)

\[ Y_t = e_t+0.5Y_{t-1}+0.2Y_{t-2} \]

set.seed(008)
wn = rnorm(300)

n<-length(wn)
n
## [1] 300
ar2 <- c(1:n) 
for (i in 3:n) {ar2[i]<-wn[i]+0.5*ar2[i-1]+0.2*ar2[i-2]}
ar2
##   [1]  1.000000000  2.000000000  0.736517228  0.217423609  0.992055682
##   [6]  0.431631162  0.243937567 -0.880036696 -3.402282510 -2.470322927
##  [11] -2.675411762 -1.539720603 -0.883544059 -2.044205231 -1.129526339
##  [16] -1.786642693  0.391626458 -0.433124189  1.420017126  0.386033855
##  [21]  1.760143235  0.947788753  0.425840242  0.424463495  2.040167177
##  [26] -0.002197872 -0.653554983  1.623944254  1.283967873 -1.053836694
##  [31]  1.236550771  1.371219136 -0.620971690 -0.809884397  0.731641419
##  [36]  0.632299609  1.307061625  0.080840182  0.236970140  0.605636752
##  [41]  0.713713025 -0.136572046  0.303405872 -0.137668307  0.604403012
##  [46] -1.682944648 -1.384099193 -0.744851011 -0.380527381 -0.979338633
##  [51]  0.514176474 -0.303925830  0.540237769  0.113237771  1.136174195
##  [56]  1.169203596  0.034663134 -0.349669829 -1.667221697 -0.149381390
##  [61]  0.149159291  0.139580513 -1.681819302 -1.921785962 -1.564704623
##  [66] -2.243362588 -1.925773934  0.227638504  0.125441478 -1.489824953
##  [71] -2.187514356 -0.351584281  0.169535979 -0.462645287 -0.103390808
##  [76]  0.454754894 -2.690598684 -0.670651671  1.502637796 -0.029073497
##  [81]  0.529059790 -0.530778014 -1.253276481  1.311813522 -1.276082206
##  [86]  0.839604733  0.068862408 -0.749042315  0.240516816 -3.044077293
##  [91] -0.704450680  0.607901200 -0.339656312 -0.666136136 -1.752431311
##  [96] -0.240354974 -0.141194632 -0.162813968 -0.746883191 -0.475287128
## [101] -0.090168924 -2.040715479 -2.685757159 -3.529427104 -2.266921579
## [106] -2.333892650 -1.012785714 -1.337536234 -0.703390917 -0.052580039
## [111] -0.322648776 -1.009824483 -0.022427527 -1.301217317  0.796712994
## [116]  1.525088570  1.181974900  2.339631107  0.214969251  0.277021491
## [121] -0.962904846 -2.147583443 -1.636058218  0.574529713  0.437643017
## [126]  0.474275976 -1.401357862 -0.329292079 -1.807677289 -0.134273254
## [131]  1.796951146  1.043887884 -0.619258613 -1.447469087 -3.248668554
## [136] -1.120307688 -0.765996224 -0.103233554  1.223268632 -1.241099334
## [141]  0.966886862  2.674167901  2.207397435 -0.330448328  0.356636745
## [146] -0.592540524  0.372309407  0.863426232 -0.524661075 -0.509172121
## [151] -0.199427141 -0.766028325 -0.195393048  0.006176695 -0.373691062
## [156]  0.118962271  0.709180010 -0.306790845  0.649926483  1.989024692
## [161]  1.445843345  1.697042503 -0.272302256 -0.792244694  1.109716148
## [166]  0.600003132  0.134310000  1.106770460  0.200508304  1.065853495
## [171] -0.610153690  0.184512919 -0.385991999  0.831630448  0.071383175
## [176]  0.682044967  1.122721860  1.637212010 -0.010062214  1.336029069
## [181] -0.588171144 -0.407463390 -0.112277094 -0.262387402  2.032728811
## [186]  1.045910163  3.041602890  2.764326181  1.792310462  0.409790888
## [191]  0.429693436 -0.285231295 -0.959688186 -1.338722100  0.459521986
## [196]  1.001196222  1.150613544 -0.553141129 -1.971004645 -1.073435141
## [201] -1.512406912 -1.195042111  0.298431752 -1.448371259 -0.684570668
## [206]  0.258173849 -0.035686112 -0.845546942  0.335411349 -0.978992263
## [211]  0.107891085  0.793053066  0.764293034 -0.192823715  0.766889955
## [216]  0.022172190 -0.196174453  0.061500507 -1.399390782  0.685798722
## [221] -0.802128481 -1.566413344 -0.050211608 -1.218765134 -1.036044335
## [226] -0.802404353 -0.464821389 -0.295380181 -0.074224681  1.380122727
## [231] -0.870793106  1.211555028  0.124741935  0.126532334  0.929080108
## [236] -0.214008142 -0.301536584 -0.806417374 -1.311126102  0.634410948
## [241] -0.985458561 -0.341187961  0.494514638  0.887306537 -0.094011902
## [246]  1.039207352 -0.081931154  0.247973642  0.063955100  0.356958420
## [251]  1.226036990  0.240396824 -0.976983590 -0.603792068 -0.746491456
## [256]  0.168466600  0.578905767 -0.528781758 -0.873335097 -0.680439458
## [261] -0.860594058 -0.158503090 -0.793753951 -2.662557871 -0.172409591
## [266] -0.196832442 -0.875417128 -0.230526664 -0.825112645 -1.834205589
## [271] -1.492909165 -0.041186356  0.625018446 -0.356322955  0.410067430
## [276] -0.699728083 -1.923959388 -1.344872329 -1.792057356 -0.876953076
## [281] -3.316753211 -1.274526503 -1.671389011 -1.336950437 -2.071286599
## [286] -1.114173753 -1.671445242 -1.113429250 -0.886279601 -0.152081357
## [291] -0.485379402 -0.776909353  0.445616473  0.934109250 -1.058898749
## [296] -0.757482276 -0.294641459 -0.800231102 -0.290647478 -1.789875055

Selain menggunakan cara di atas, pembangkitan proses AR dapat dilakukan dengan fungsi arima.sim() sebagai berikut.

set.seed(008)
ar2. <- arima.sim(list(order=c(2,0,0), ar=c(0.5,0.2)), n=300)
ar2.
## Time Series:
## Start = 1 
## End = 300 
## Frequency = 1 
##   [1] -0.003839880 -0.654806764  1.622989962  1.283240371 -1.054391303
##   [6]  1.236127965  1.370896811 -0.621217414 -0.810071723  0.731498611
##  [11]  0.632190740  1.306978629  0.080776910  0.236921904  0.605599980
##  [16]  0.713684992 -0.136593417  0.303389580 -0.137680727  0.604393543
##  [21] -1.682951866 -1.384104696 -0.744855206 -0.380530579 -0.979341071
##  [26]  0.514174615 -0.303927247  0.540236689  0.113236948  1.136173567
##  [31]  1.169203118  0.034662769 -0.349670108 -1.667221909 -0.149381552
##  [36]  0.149159168  0.139580419 -1.681819374 -1.921786016 -1.564704665
##  [41] -2.243362620 -1.925773958  0.227638486  0.125441464 -1.489824964
##  [46] -2.187514364 -0.351584287  0.169535975 -0.462645291 -0.103390811
##  [51]  0.454754891 -2.690598685 -0.670651672  1.502637795 -0.029073498
##  [56]  0.529059789 -0.530778015 -1.253276482  1.311813521 -1.276082206
##  [61]  0.839604733  0.068862408 -0.749042315  0.240516816 -3.044077293
##  [66] -0.704450680  0.607901200 -0.339656312 -0.666136136 -1.752431311
##  [71] -0.240354974 -0.141194632 -0.162813968 -0.746883191 -0.475287128
##  [76] -0.090168924 -2.040715479 -2.685757159 -3.529427104 -2.266921579
##  [81] -2.333892650 -1.012785714 -1.337536234 -0.703390917 -0.052580039
##  [86] -0.322648776 -1.009824483 -0.022427527 -1.301217317  0.796712994
##  [91]  1.525088570  1.181974900  2.339631107  0.214969251  0.277021491
##  [96] -0.962904846 -2.147583443 -1.636058218  0.574529713  0.437643017
## [101]  0.474275976 -1.401357862 -0.329292079 -1.807677289 -0.134273254
## [106]  1.796951146  1.043887884 -0.619258613 -1.447469087 -3.248668554
## [111] -1.120307688 -0.765996224 -0.103233554  1.223268632 -1.241099334
## [116]  0.966886862  2.674167901  2.207397435 -0.330448328  0.356636745
## [121] -0.592540524  0.372309407  0.863426232 -0.524661075 -0.509172121
## [126] -0.199427141 -0.766028325 -0.195393048  0.006176695 -0.373691062
## [131]  0.118962271  0.709180010 -0.306790845  0.649926483  1.989024692
## [136]  1.445843345  1.697042503 -0.272302256 -0.792244694  1.109716148
## [141]  0.600003132  0.134310000  1.106770460  0.200508304  1.065853495
## [146] -0.610153690  0.184512919 -0.385991999  0.831630448  0.071383175
## [151]  0.682044967  1.122721860  1.637212010 -0.010062214  1.336029069
## [156] -0.588171144 -0.407463390 -0.112277094 -0.262387402  2.032728811
## [161]  1.045910163  3.041602890  2.764326181  1.792310462  0.409790888
## [166]  0.429693436 -0.285231295 -0.959688186 -1.338722100  0.459521986
## [171]  1.001196222  1.150613544 -0.553141129 -1.971004645 -1.073435141
## [176] -1.512406912 -1.195042111  0.298431752 -1.448371259 -0.684570668
## [181]  0.258173849 -0.035686112 -0.845546942  0.335411349 -0.978992263
## [186]  0.107891085  0.793053066  0.764293034 -0.192823715  0.766889955
## [191]  0.022172190 -0.196174453  0.061500507 -1.399390782  0.685798722
## [196] -0.802128481 -1.566413344 -0.050211608 -1.218765134 -1.036044335
## [201] -0.802404353 -0.464821389 -0.295380181 -0.074224681  1.380122727
## [206] -0.870793106  1.211555028  0.124741935  0.126532334  0.929080108
## [211] -0.214008142 -0.301536584 -0.806417374 -1.311126102  0.634410948
## [216] -0.985458561 -0.341187961  0.494514638  0.887306537 -0.094011902
## [221]  1.039207352 -0.081931154  0.247973642  0.063955100  0.356958420
## [226]  1.226036990  0.240396824 -0.976983590 -0.603792068 -0.746491456
## [231]  0.168466600  0.578905767 -0.528781758 -0.873335097 -0.680439458
## [236] -0.860594058 -0.158503090 -0.793753951 -2.662557871 -0.172409591
## [241] -0.196832442 -0.875417128 -0.230526664 -0.825112645 -1.834205589
## [246] -1.492909165 -0.041186356  0.625018446 -0.356322955  0.410067430
## [251] -0.699728083 -1.923959388 -1.344872329 -1.792057356 -0.876953076
## [256] -3.316753211 -1.274526503 -1.671389011 -1.336950437 -2.071286599
## [261] -1.114173753 -1.671445242 -1.113429250 -0.886279601 -0.152081357
## [266] -0.485379402 -0.776909353  0.445616473  0.934109250 -1.058898749
## [271] -0.757482276 -0.294641459 -0.800231102 -0.290647478 -1.789875055
## [276] -1.888231759 -2.620414156 -2.531376075 -1.970007933 -2.964796375
## [281] -1.579544664 -0.899125282 -0.697005114 -0.239495467  1.055632619
## [286]  0.184344529  0.238720352  0.932511272 -0.565610914  0.495846005
## [291]  0.461563484 -1.965905164 -1.293568604  0.085938114  0.847348074
## [296] -0.715531689 -1.142967235 -1.356946838 -1.036758375 -0.493939385

Karakteristik AR(2)

Plot Time Series

par(mfrow=c(1,2))
ts.plot(ar2)
ts.plot(ar2.)

Plot ACF

par(mfrow=c(1,2))
acf(ar2)
acf(ar2.)

Berdasarkan plot ACF tersebut terlihat bahwa plot ACF cenderung tails off dan cenderung membentuk pola grafik sinus

Plot PACF

par(mfrow=c(1,2))
pacf(ar2)
pacf(ar2.)

Berdasarkan plot PACF tersebut, terlihat bahwa plot PACF cuts off pada lag kedua, sejalan dengan teori yang ada

Plot EACF

par(mfrow=c(1,2))
TSA::eacf(ar2)
## AR/MA
##   0 1 2 3 4 5 6 7 8 9 10 11 12 13
## 0 x x x x x o o o o o o  o  o  o 
## 1 x o o o o o o o o o o  o  o  o 
## 2 x o o x o o o o o o o  o  o  o 
## 3 x o o o o o o o o o o  o  o  o 
## 4 x x x o o o o o o o o  o  o  o 
## 5 x x x o x o o o o o o  o  o  o 
## 6 x x o x o o o o o o o  o  o  o 
## 7 o x x x x o o o o o o  o  o  o
TSA::eacf(ar2.)
## AR/MA
##   0 1 2 3 4 5 6 7 8 9 10 11 12 13
## 0 x x x o x x o o o o o  o  o  o 
## 1 x o o x o o o o o o o  o  o  o 
## 2 x x o x o o o o o o o  o  o  o 
## 3 x x o x o o o o o o o  o  o  o 
## 4 x x x x o o o o o o o  o  o  o 
## 5 x x x x x o o o o o o  o  o  o 
## 6 x o o x o o o o o o o  o  o  o 
## 7 x o o x o o o o o o o  o  o  o

Berdasarkan pola segitiga nol pada plot EACF, terlihat bahwa segitiga nol berada pada ordo AR(2) dan ordo MA(0)

Scatterplot Antar Lag

Korelasi antara \(Y_t\) dengan \(Y_{t-1}\)

#Yt
yt_ar <- ar2[-1]
yt_ar. <- ar2.[-1]

#Yt-1
yt_1_ar <- ar2[-300]
yt_1_ar. <- ar2.[-300]
par(mfrow=c(1,2))
plot(y=yt_ar,x=yt_1_ar)
plot(y=yt_ar.,x=yt_1_ar.)

Berdasarkan scatterplot tersebut, terlihat bahwa terdapat hubungan positif antara \(Y_t\) dengan \(Y_{t-1}\). Hal ini sesuai dengan teori yang ada

cor(yt_ar,yt_1_ar)
## [1] 0.46873
cor(yt_ar.,yt_1_ar.)
## [1] 0.4669156

Korelasi antara \(Y_t\) dengan \(Y_{t-2}\)

#Yt
yt_ar2 <- ar2[-c(1,2)]
yt_ar2. <- ar2.[-c(1,2)]

#Yt-2
yt_2_ar <- ar2[-c(199,200)]
yt_2_ar. <- ar2.[-c(199,200)]
par(mfrow=c(1,2))
plot(y=yt_ar2,x=yt_2_ar)
plot(y=yt_ar2.,x=yt_2_ar.)

Berdasarkan scatterplot tersebut, terlihat bahwa terdapat hubungan positif antara \(Y_t\) dengan \(Y_{t-2}\). Hal ini sesuai dengan teori yang ada

cor(yt_ar2,yt_2_ar)
## [1] 0.4547448
cor(yt_ar2.,yt_2_ar.)
## [1] 0.466182

Korelasi antara \(Y_t\) dengan \(Y_{t-3}\)

#Yt
yt_ar3 <- ar2[-c(1,2,3)]
yt_ar3. <- ar2.[-c(1,2,3)]

#Yt-3
yt_3_ar <- ar2[-c(198,199,200)]
yt_3_ar. <- ar2.[-c(198,199,200)]
par(mfrow=c(1,2))
plot(y=yt_ar3,x=yt_3_ar)
plot(y=yt_ar3.,x=yt_3_ar.)

Berdasarkan scatterplot tersebut, terlihat bahwa terdapat hubungan positif antara \(Y_t\) dengan \(Y_{t-3}\). Hal ini sesuai dengan teori yang ada

cor(yt_ar3,yt_3_ar)
## [1] 0.3587565
cor(yt_ar3.,yt_3_ar.)
## [1] 0.401311

Proses ARMA

Fungsi pembangkitan ARMA

arma.sim <- function(n, macoef, arcoef){
  manum <- length(macoef)
  arnum <- length(arcoef)
  stopifnot(manum < n & arnum < n)
  
  wn <- rnorm(n, sd = 0.5)
  init <- max(manum, arnum)

  arma <- wn[1:init]
  for(i in {init+1}:n){
   mastart <- i - manum
   maend <- i-1
   arstart <- i - arnum
   arend <- i-1
   arma[i] <- sum(arcoef * arma[arstart:arend]) + sum(macoef * wn[mastart:maend])  + wn[i]
   }
  return(arma)
}

Terlihat bahwa komponen \(\sum_{i=1}^q y_{t-1}\) disimulasikan melalui sum(arcoef * arma[arstart:arend]). Jadi, koefisien dikalikan dengan data \(y\) dari \(t-q\) di mana q adalah jumlah koefisien AR, sampai data \(t-1\). Lalu komponen \(\sum_{j=1}^q e_{t-j}\) disimulasikan melalui sum(macoef * wn[mastart:maend]). Koefisien dikalikan dengan white noise \(e\) dari \(t-p\), p jumlah koefisien MA, sampai \(t-1\).

Membangkitkan Model ARMA(2,2)

set.seed(008)
arma22 <- arma.sim(n=300, arcoef = c(0.5, 0.2), macoef = c(0.4,0.6))

Membangkitkan Data Secara Manual

set.seed(008)
wn = rnorm(300)
n = length(wn)
phi1 = 0.5
phi2 = 0.2
theta1 = 0.4
theta2 = 0.6

arma22=c(1:n)
for (i in 3:n){arma22[i] = phi1*arma22[i-1] + phi2*arma22[i-2]  + theta1*wn[i-1] + theta2*wn[i-2] +wn[i]}

Pembangkitan ARMA(p,q) juga dapat dilakukan dengan fungsi arima.sim sebagai berikut.

set.seed(008)
arma22. <- arima.sim(list(order=c(2,0,2), ar = c(0.5,0.2), ma = c(0.4,0.6)), n=300)
arma22.
## Time Series:
## Start = 1 
## End = 300 
## Frequency = 1 
##   [1]  1.35828691  1.53918910  0.43242194  1.58410459  1.23255230  0.66869542
##   [7] -0.23611412  0.03466818  0.43869280  1.99871266  0.98285122  1.05339577
##  [13]  0.74881653  1.09806413  0.51222990  0.67695508 -0.09828715  0.73135027
##  [19] -1.52380649 -1.69465206 -2.30827030 -1.50893708 -1.57846764 -0.10588109
##  [25] -0.68586275  0.72717002  0.14697486  1.50561005  1.69161447  1.18404797
##  [31]  0.36571673 -1.78629240 -1.02607246 -0.91092666  0.10961511 -1.53649174
##  [37] -2.51076554 -3.34251072 -4.02231611 -3.76194182 -1.88868868 -0.93896752
##  [43] -1.30306529 -2.70817948 -2.12048501 -1.28360636 -0.60578148 -0.18672734
##  [49]  0.13581139 -2.57073122 -1.47403821 -0.37998209  0.16959062  1.41901307
##  [55] -0.33659820 -1.14815181  0.49203612 -1.50332269  1.11625996 -0.36094502
##  [61] -0.21773451 -0.01778267 -3.39729596 -1.77777151 -1.50032545 -0.51916624
##  [67] -0.43725794 -2.22267955 -1.34100918 -1.28879541 -0.36350481 -0.89672556
##  [73] -0.87172878 -0.72841369 -2.36195532 -3.55614471 -5.82815925 -5.29014672
##  [79] -5.35831754 -3.30649572 -3.14298611 -1.84607684 -1.13645815 -0.76571534
##  [85] -1.17043202 -0.61994659 -1.91608302  0.26276955  1.06304338  2.27003813
##  [91]  3.72747421  1.86000663  1.76678786 -0.72311470 -2.36653249 -3.07283450
##  [97] -1.36844364 -0.31418003  0.99405101 -0.94906166 -0.60526964 -2.78020884
## [103] -1.05491942  0.65863547  1.68210439  0.87646723 -1.06883980 -4.19921136
## [109] -3.28825656 -3.16332043 -1.08181666  0.72237748 -0.81373201  1.20440831
## [115]  2.31626305  3.85719671  2.15701139  1.54889588 -0.64815482  0.34927524
## [121]  0.65682568  0.04409506 -0.20098081 -0.71789263 -1.15130245 -0.62146066
## [127] -0.53159752 -0.48845621 -0.02680814  0.53255028  0.04825852  0.95271815
## [133]  2.06492078  2.63140911  3.46879466  1.27402075  0.11705991  0.62943692
## [139]  0.56854278  1.04014094  1.52049634  0.72380249  1.81011909 -0.06350731
## [145]  0.57996354 -0.67827905  0.78794140  0.17244015  1.20957651  1.43836975
## [151]  2.49552773  1.31845571  2.31433139 -0.05979684  0.15888559 -0.62816514
## [157] -0.55177627  1.86040759  1.70156925  4.67960424  4.60851343  4.72300267
## [163]  2.78531078  1.66899607  0.13252061 -0.81596464 -1.89373615 -0.65177977
## [169]  0.38177176  1.82680522  0.50782202 -1.50189297 -2.19372168 -3.12438375
## [175] -2.44406596 -1.08702924 -2.04602382 -1.08486012 -0.88467717 -0.34315897
## [181] -0.70491708 -0.02421910 -1.35215589 -0.08245901  0.24881414  1.14624891
## [187]  0.58872534  1.14833629  0.21323394  0.27282840 -0.00366596 -1.49249525
## [193]  0.16294271 -1.36744346 -1.47578550 -1.15805403 -2.17869778 -1.55367735
## [199] -1.94808117 -1.40740973 -0.96275135 -0.47126959  1.17320475 -0.36327882
## [205]  1.69131142  0.08688808  0.90336212  1.05453820  0.23354330  0.17030822
## [211] -1.05543689 -1.81461500 -0.37388992 -1.51836984 -0.35472482 -0.23323568
## [217]  0.88039962  0.55761950  1.53398651  0.27734465  0.83872559  0.11398586
## [223]  0.53132464  1.40719342  0.94498667 -0.14520267 -0.85034741 -1.57419844
## [229] -0.49240522  0.19839753 -0.19613949 -0.73750434 -1.34704255 -1.65677090
## [235] -0.91100439 -1.37351162 -3.07516131 -1.71368511 -1.86333100 -1.05759586
## [241] -0.69879298 -1.44257359 -2.30256665 -2.72165899 -1.73887338 -0.28720160
## [247] -0.13102739  0.64254932 -0.74949488 -1.95781016 -2.53429293 -3.48438192
## [253] -2.40069942 -4.74276885 -3.12739963 -4.17125154 -2.77022194 -3.60890018
## [259] -2.74485865 -3.35988670 -2.45051160 -2.33451845 -1.17465075 -1.07797971
## [265] -1.06230993 -0.15637491  0.64621023 -0.41788517 -0.62057623 -1.23297362
## [271] -1.37257705 -0.78752479 -2.38627271 -2.77857027 -4.44963189 -4.71248079
## [277] -4.55480686 -5.27162519 -3.94746797 -3.30982097 -2.00438203 -1.05777268
## [283]  0.54163136  0.46290030  0.94583774  1.13860613 -0.04937419  0.82910840
## [289]  0.32053534 -1.48377217 -1.80299258 -1.61103243  0.10558216 -0.32502959
## [295] -0.92077107 -2.24345275 -2.26531745 -1.72281084 -0.44905263 -1.21046242

Karakteristik ARMA(2,2)

Plot Time Series

par(mfrow = c(1, 2))
ts.plot(arma22)
ts.plot(arma22.)

Berdasarkan plot time series tersebut, terlihat bahwa model ARMA(2,2) cenderung stasioner dalam rataan

Plot ACF

par(mfrow = c(1, 2))
acf(arma22)
acf(arma22.)

Berdasarkan plot ACF tersebut, terlihat bahwa model ARMA(2,2) hasil simulasi memiliki plot ACF yang tails off, sesuai dengan teori yang ada

Plot PACF

par(mfrow = c(1, 2))
pacf(arma22)
pacf(arma22.)

Berdasarkan plot PACF tersebut, terlihat bahwa model ARMA(2,2) hasil simulasi memiliki plot PACF yang tails off, sesuai dengan teori

Plot EACF

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

Berdasarkan pola segitiga nol pada plot EACF, terlihat bahwa segitiga nol berada pada ordo AR(2) dan ordo MA(2)

Scatterplot Antar Lag

Korelasi antara \(Y_t\) dengan \(Y_{t-1}\)

#Yt
yt_arma <- arma22[-1]
yt_arma. <- arma22.[-1]

#Yt-1
yt_1_arma <- arma22[-300]
yt_1_arma. <- arma22.[-300]
par(mfrow=c(1,2))
plot(y=yt_arma,x=yt_1_arma)
plot(y=yt_arma.,x=yt_1_arma.)

Berdasarkan scatterplot tersebut, terlihat bahwa terdapat hubungan positif antara \(Y_t\) dengan \(Y_{t-1}\). Hal ini sesuai dengan teori yang ada

cor(yt_arma,yt_1_arma)
## [1] 0.7873047
cor(yt_arma.,yt_1_arma.)
## [1] 0.7906126

Korelasi antara \(Y_t\) dengan \(Y_{t-2}\)

#Yt
yt_arma2 <- arma22[-c(1,2)]
yt_arma2. <- arma22.[-c(1,2)]

#Yt-2
yt_2_arma <- arma22[-c(299,300)]
yt_2_arma. <- arma22.[-c(299,300)]
par(mfrow=c(1,2))
plot(y=yt_arma2,x=yt_2_arma)
plot(y=yt_arma2.,x=yt_2_arma.)

Berdasarkan scatterplot tersebut, terlihat bahwa terdapat hubungan positif antara \(Y_t\) dengan \(Y_{t-2}\). Hal ini sesuai dengan teori yang ada

cor(yt_arma2,yt_2_arma)
## [1] 0.6408944
cor(yt_arma2.,yt_2_arma.)
## [1] 0.6348718

Korelasi antara \(Y_t\) dengan \(Y_{t-3}\)

#Yt
yt_arma3 <- arma22[-c(1,2,3)]
yt_arma3. <- arma22.[-c(1,2,3)]

#Yt-3
yt_3_arma <- arma22[-c(298,299,300)]
yt_3_arma. <- arma22.[-c(298,299,300)]
par(mfrow=c(1,2))
plot(y=yt_arma3,x=yt_3_arma)
plot(y=yt_arma3.,x=yt_3_arma.)

Berdasarkan scatterplot tersebut, terlihat bahwa terdapat hubungan positif antara \(Y_t\) dengan \(Y_{t-2}\). Hal ini sesuai dengan teori yang ada

cor(yt_arma3,yt_3_arma)
## [1] 0.3962797
cor(yt_arma3.,yt_3_arma.)
## [1] 0.3947975