50
Dr. Kusman Sadik, M.Si Sekolah Pascasarjana Departemen Statistika IPB Semester Ganjil 2019/2020 Analisis Deret Waktu (STK 651) IPB University ─ Bogor Indonesia ─ Inspiring Innovation with Integrity Pemodelan Data Deret Waktu (AR dan MA)

Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

  • Upload
    others

  • View
    12

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

Dr. Kusman Sadik, M.Si

Sekolah Pascasarjana Departemen Statistika IPB

Semester Ganjil 2019/2020

Analisis Deret Waktu (STK 651)

IPB University─ Bogor Indonesia ─ Inspiring Innovation with Integrity

Pemodelan Data Deret Waktu

(AR dan MA)

Page 2: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

2

The forecasting methods based on the smoothing

may be inefficient and sometimes inappropriate

because they do not take advantage of the serial

dependence in the observations in the most effective

way.

To formally incorporate this dependent structure, in

this course we will explore a general class of models

called autoregressive integrated moving average

models or ARIMA models (also known as Box-Jenkinsmodels).

Page 3: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

3

AR(p) : Autoregressive ber-ordo p

I(d) : Integrated ber-ordo d

MA(q) : Moving Average ber-ordo q

Page 4: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

4

Model Stasioner:

AR(p), MA(q), dan ARMA(p, q)

Model Tidak-Stasioner:

ARI(p, d), IMA(d, q), dan ARIMA(p, d, q)

Page 5: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

5

E(Yt) = E(Yt-1 ) = … = E(Yt-k ) Konstan

V(Yt) = V(Yt-1 ) = … = V(Yt-k ) Konstan

Page 6: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

6

Peristilahan

Autocovariance : Koragam Diri

Autocorrelation : Korelasi Diri

Page 7: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

7

Page 8: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

8

Page 9: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

9

Page 10: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

10

Page 11: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

11

Misalkan diketahui data deret waktu sebagai berikut: 2, 3, 2, 5.

Hitung secara manual penduga fungsi autokorelasi (ACF) untuk k = 1

dan 2:

r1 = {(3-3)(2-3)+(2-3)(3-3)+(5-3)(2-3)}/{(-1)2+(0)2+(-1)2+(2)2} = - 0.333

r2 = {(2-3)(2-3)+(5-3)(3-3)}/{(-1)2+(0)2+(-1)2+(2)2} = 0.167

= 3

> data <- c(2, 3, 2, 5)

> acf(data, lag.max = 3, plot = FALSE)

Autocorrelations of series ‘data’, by lag

0 1 2 3

1.000 -0.333 0.167 -0.333

Program R

Page 12: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

12

(Langkah Acak)

Page 13: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

13

Page 14: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

14

et ~ Normal(0, σe2)

(4.1.4)

Page 15: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

15

Pada beberapa software, termasuk R, untuk pertimbangan

komputasi penulisan model MA(q) menggunakan tanda plus

pada parameter θ, yaitu:

Hal ini harus diperhatikan pada saat pendugaan parameter,

karena Program R akan menghasilkan penduga θ yang

berlawanan tanda (plus / minus) dengan model MA(q)

pada persamaan (4.1.4) di atas.

Untuk pembangkitan data MA di R bisa menggunakan

persamaan (4.1.4), yang berbeda hanya saat pendugaan.

Page 16: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

16

Karena et ~ Normal(0, σe2) maka:

E(et) = E(et-1 ) = … = E(et-k ) = 0

V(et) = V(et-1 ) = … = V(et-k ) = (σe)2

E(et.ek) = 0 untuk semua t ≠ k

Page 17: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

17

V(Yt) = V(et - θet-1)

= V(et) + θ2V(et-1)

= σe2 + θ2σe

2

Cov(-θet-1 , et-1)

= -θCov(et-1 , et-1)

= -θVar(et-1)

= -θσe2

Page 18: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

18

Page 19: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

19

ACF / Autocorrelation Function : ρk = (γk/γ0)

Page 20: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

20

t = k Cov(αet , θek) = (αθ)σe2

t ≠ k Cov(αet , θek) = 0

Page 21: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

21

Page 22: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

22

Page 23: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

23

Page 24: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

24

Var(Yt) = Var(ϕYt-1 + et) = ϕ2Var(Yt-1) + Var(et)

Page 25: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

25

Page 26: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

26

Page 27: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

27

Page 28: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

28

Page 29: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

29

Page 30: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

30

Ordo (nilai q) pada model MA(q) dapat diidentifikasi

dari plot ACF-nya.

Ordo (nilai p) pada model AR(p) TIDAK dapat

diidentifikasi dari plot ACF-nya karena polanya

berbentuk eksponensial.

Ordo pada model AR(p) dapat diidentifikasi dari plot yt

dengan yt-k, untuk k = 1, 2, 3, …

Page 31: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

31

Page 32: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

32

Page 33: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

33

Page 34: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

34

Page 35: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

35

Page 36: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

36

# Simulasi Data MA(1) dan AR(1)

# Install packages : "forecast", "TTR", "TSA", "graphics"

library("forecast")

library("TTR")

library("TSA")

library("graphics")

set.seed(1001)

e <- rnorm(175,0,1)

n <- length(e)

# Membangkitkan X, MA(1) dengan tetha = 0.95

tetha <- 0.95

x <- c(1:n)

for (i in 2:n) { x[i] <- e[i] - tetha*e[i-1] } # Model MA Cryer 4.1.4

x.ma1 <- x[-c(1:50)] # membuang 50 data pertama

plot.ts(x.ma1, lty=1)

points(x.ma1)

acf(x.ma1, lag.max=20) # menampilkan plot acf

acf(x.ma1, lag.max=20, plot=FALSE) # menampilkan nilai acf

Page 37: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

37

# Membangkitkan y, AR(1) dengan Phi = 0.85

y <- c(1:n)

for (i in 2:n) { y[i] <- 0.85*y[i-1] + e[i] }

y.ar1 <- y[-c(1:50)] # membuang 50 data pertama

plot.ts(y.ar1, lty=1)

points(y.ar1)

plot(x=zlag(y.ar1,1),y=y.ar1,xlab=expression(Y[t-1]),

ylab=expression(Y[t]),type='p')

plot(x=zlag(y.ar1,2),y=y.ar1,xlab=expression(Y[t-2]),

ylab=expression(Y[t]),type='p')

acf(y.ar1, lag.max=20) # menampilkan plot acf

acf(y.ar1, lag.max=20, plot=FALSE) # menampilkan nilai acf

Page 38: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

38

Page 39: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

39

Page 40: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

40

> acf(x.ma1, lag.max=20, plot=FALSE) # menampilkan nilai acf

Autocorrelations of series ‘x.ma1’, by lag

1 2 3 4 5 6 7 8 9 10 11

-0.390 -0.055 -0.029 0.009 -0.001 0.026 -0.113 0.105 -0.113 0.195 -0.045

12 13 14 15 16 17 18 19 20

-0.149 0.137 -0.051 -0.029 -0.060 0.058 -0.007 0.116 -0.157

Page 41: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

41

Page 42: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

42

Page 43: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

43

Page 44: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

44

Page 45: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

45

Page 46: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

46

1. Misalkan diketahui data deret waktu sebagai berikut: 3, 8, 5, 9, 12, 20.

Hitung secara manual penduga fungsi autokorelasi (ACF) untuk k = 1, 2,

dan 3, kemudian bandingkan hasilnya dengan keluaran Program R.

2. Melalui Program R, bangkitkan data yt, (n = 165), berupa MA(2) dengan

θ1 = 0.65 dan θ2 = - 0.85 serta et ~ Normal(0,1). Gunakan 150 data terakhir,

kemudian buat correlogramnya. Apa yang dapat disimpulkan dari

correlogram tersebut?

3. Melalui Program R, bangkitkan data yt, (n = 165), berupa AR(2) dengan

Φ1 = 0.75 dan Φ2 = - 0.65 dan et ~ Normal(0,1). Gunakan 150 data terakhir:

a. Buatlah correlogramnya. Apa yang dapat disimpulkan dari correlogram

tersebut?

b. Buatlah plot antara yt dengan yt-1. Apa kesimpulan Anda?

c. Buatlah plot antara yt dengan yt-2. Apa kesimpulan Anda?

d. Buatlah plot antara yt dengan yt-3. Apa kesimpulan Anda?

Page 47: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

47

Page 48: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

48

Montgomery, D.C., et.al. 2008. Forecasting Time Series Analysis

2nd. John Wiley.

Cryer, J.D. and Chan, K.S. 2008. Time Series Analysis with

Application in R. Springer.

Cowpertwait, P.S.P. and Metcalfe, A.V. 2009. Introductory Time

Series with R. Springer New York.

Wei, William, W.S. 1990. Time Series Analysis, Univariate and

Multivariate Methods. Adison-Wesley Publishing Company Inc,

Canada.

Page 49: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

49

Bisa di-download di

kusmansadik.wordpress.com

Page 50: Pemodelan Data Deret Waktu - WordPress.com · 2019-09-02 · Pemodelan Data Deret Waktu (AR dan MA) 2 The forecasting methods based on the smoothing may be inefficient and sometimes

50