43
Chapter 4 Volatility model Asst.Prof.Dr. Woraphon Yamaka https://wyamaka.wordpress.com

Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

Chapter 4Volatility model

Asst.Prof.Dr. Woraphon Yamakahttps://wyamaka.wordpress.com

Page 2: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

Volatility คอ VARIANCE นนเอง• ตอนเราท า linear regression กเพอศกษาวา x สงผลตอ y อยางไร หรออกเปาหมายหนงกคอ เราตองการพยากรณ y นนเอง โดยมสมการดงน

หรอ

• Mean ของแบบจ าลอง คอ 𝑋𝛽• Variance ของแบบจ าลอง คอ 𝜎2 ซงเรามกสมมตใหมนนง และคาคงท เรยกวา

homoscedastic

• แตในความเปนจรงแลว ขอมลอนกรมเวลาตางๆ มกไมนง ดงนนการทเราสมมตให 𝜎2 คงทอาจจะผด นกเศรษฐมตหลายคน จงเชอวา 𝜎2 ไมนง หรอมลกษณะ heteroscedastic 2

2( , )y N X =

y X u= +

Page 3: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

VARIANCE หรอ Volatility

• การท σ2 ไมนง หรอมลกษณะ heteroscedastic นนมกเกดจากความผนผวนของขอมลตวแปร Y นนเอง

• ดงนนในบทนเราจะไมสนใจ Mean หรอ Xβ แตเราจะสนใจการประมานความผนผวนมากกวา

• Volatility นจะชวยใหเราสามารถดความผนผวนของขอมลทางเศรษฐกจได วามมากหรอนอยเพยงใด เชน ความผนผวนของ GDP, ราคาหน และคาเงน เปนตน

• ทผานมาเราประมาณความผนผวนของ Y โดย

Var(Y) =E(Y−E(Y))2

3

2 2

1

/ ( ) / ( )T

t

t

u T k u u T k=

= − = − วธทางเศรษฐมตเบองตน ทสมมตให Variance คงท

วธทางสถต

วธทางเศรษฐมตเบองตน ทสมมตให Variance ไมคงทแบบจ าลอง Volatility ในบทท 42

t =

Page 4: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

VARIANCE หรอ VolatilityConditional Variance หรอกคอ Variance ทเปลยนแปลง

ไปตามเวลานนเอง

mean

variance

Conditional variance

4

2

t =

2

t

2

Page 5: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

5

ม.ค. 03 2000 เม.ย. 02 2001 ก.ค. 01 2002 ก.ย. 02 2003 ธ.ค. 01 2004 ม.ค. 01 2006 ม.ย. 01 2007 ส.ค. 01 2008 ต.ค. 01 2009 ธ.ค. 01 2010 ม.ค. 01 2012 ม.ย. 03 2013 ก.ย. 02 2014 ธ.ค. 01 2015 ม.ค. 01 2017 ม.ย. 01 2018

S&P 500 2000-01-03 / 2019-03-08

-0.05

0.00

0.05

0.10

-0.05

0.00

0.05

0.10

2000 2005 2010

0.00

0.05

0.10

0.15

Forecast Rolling Sigma vs |Series|

Time/Horizon

Sig

ma

GA

RC

H m

odel

: s

GA

RC

H

Horizon: 3520

Actual

Forecast

|Series|

Page 6: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

ประเภทของ Volatility Model

1. ARCH

2. GARCH

3. INTEGRATED GARCH (IGARCH)

4. Exponential GARCH (EGARCH)

5. Threshold GARCH (TGARCH)

6. Glosten Jaganathan Runkle-Generalized AutoregresiveHeteroskedascticity (GJR-GARCH)

7. GARCH in Mean (GARCH-M)

8. Markov Switching GARCH (MSGARCH)

Page 7: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

ขอมลแบบใดทมลกษณะทเรยกไดวา Volatility?

Stylized Facts of asset returns

i. Leptokurtic: ขอมลมลกษณะการแจกแจกงทหางหนา

ii. Volatility clustering: สามารถสงเกตเหนความผนผวนเปนกลมๆ ชดเจน

iii. Leverage Effects: ความผนผวนจะมความสมพนธตรงขามกบ Y

iv. Non-trading period effects: ความผนผวนของตลาดหนในวนจนทร มกสงกวาวนองคาร เพราะวนเสาร-อาทตย ตลาดหนปด ท าใหหนไมสามารถตอบสนองตอขาวตางๆ ได จงท าใหเมอตลาดเปดในวนจนทร ราคาหนจงปรบเปลยนสงมาก

v. Forecastable events:ความผนผวนจะสงเมอมเหตการณ ส าคญเกดขน แตจะนงถาไมมขาวสารอะไรใหมๆ เขามาเลย

7ม.ค. 03 2000 เม.ย. 02 2001 ก.ค. 01 2002 ก.ย. 02 2003 ธ.ค. 01 2004 ม.ค. 01 2006 ม.ย. 01 2007 ส.ค. 01 2008 ต.ค. 01 2009 ธ.ค. 01 2010 ม.ค. 01 2012 ม.ย. 03 2013 ก.ย. 02 2014 ธ.ค. 01 2015 ม.ค. 01 2017 ม.ย. 01 2018

S&P 500 2000-01-03 / 2019-03-08

-0.05

0.00

0.05

0.10

-0.05

0.00

0.05

0.10

normal distribution with time varying volatility

Y

Fre

qu

en

cy

-0.4 -0.2 0.0 0.2 0.4

05

01

00

15

02

00

25

03

00

normal distribution with constant volatility

rnorm(1000)

Fre

qu

en

cy

-3 -2 -1 0 1 2 3

05

01

00

15

02

00

Page 8: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

1.) ARCH(q) MODEL

• ARCH (autoregressive conditionally heteroscedastic) Engle(1982)

8

( )

( )1

2 2

1 0 1 1

0

1

~ 0,

0, 0, 0 1, 1,

t t t

t t t

t t t

t t t t q t q

q

i i

i

Y X

Y X

N h

Var h

i q

− − −

=

= +

= −

= = + + +

=This model is called a “ Linear ARCH(q) Regression “ model.

2*** t th =

Mean Equation

Variance Equation

Page 9: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

การทดสอบการมอยของ ARCH effect

• Method 1. ท าการทดสอบ residual วามปญหา autocorrelation หรอไม

9

1t tu u −= 0 =2 2

1t tu u −= 0 ARCH effects

Page 10: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

• Method 2. Lagrange Multiplier ( LM ) Test

Step 1: Hyphothesis

H0 : no ARCH

H1: ARCH effects

Step 2 test for first-order ARCH

Step 3: LM-test

10

การทดสอบการมอยของ ARCH

2 2

0 1 1

t t t

t t t

Y X u

u u v

= +

= + +

1 2

2 2

0.05,stat ( ) ,

k kLM T q R

−− = −

1 0 =

1 0

1 2

2 2

00.05,if ( ) , Reject

k kT q R H

−−

𝑘1 คอจ านวน parameter ของ restricted model ซงในกรณนคอ 1 ตว

𝑘2 คอจ านวน parameter ของ unrestricted model ซงในกรณน คอ ARCH model ( 2 ตว)

Page 11: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

ESTIMATION ARCH(q) : Maximum likelihood Estimator (MLE)

• Let the log likelihood function for the model is

2 2

0 1 1

2

1

1 1log ln

2 2

t t t

t t q t q

nt

t

t t

Y X

h

l hh

− −

=

= −

= + + +

= − −

11

2

2

arg max(log )

log; 0

log; 0

l

lFOC

lSOC

=

=

Page 12: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

ปญหาของแบบจ าลอง ARCH

• ในการประมาณแบบจ าลอง ARCH ถาเราม lag q ทสงเกนไป มกจะท าใหการประมาณℎ𝑡 < 0 =⇒ negative variance และ non-stationarity.

• เวลาเราแกปญหา เราสามารถท าไดโดยการ จ ากด lag q ไมใหสงกนไป แตปญหากคอ เราอาจไดแบบจ าลอง ARCH ทไมสามารถวดความผนผวนไดด เนองจากไมสามารถ แกปญหา ขอมลทม Long memory ไดนนเอง• ดงนน Bollerslev,1986 เสนอใหท า Generalized ARCH (GARCH)

12

Page 13: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

2

0

1 1

p q

t i t i j t j

i j

h h − −

= =

= + +

0

1 1

0, 0, 0, 1, , , 1,

1

i j

q p

i j

i j

i q j p

= =

= =

+

จากโครงสรางจะเหนวาสมการ GARCH มลกษณะโครงสรางแบบ ARMA(p,q)

2) GARCH (Bollerslev,1986)

• แบบจ าลอง GARCH (q, p) มลกษณะดงน

13

MA(q) AR(p)

Page 14: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

GARCH MODEL

•ตวอยาง GARCH(1,1)

14

( )1

2

0 1 1 1 1

~ 0,t t t

t t t

N h

h h

− −= + +

Page 15: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

TESTING FOR GARCH DISTURBANCES• METHOD 1: ใชวธการเดยวกบ LM test ของ ARCH เลย

• METHOD 2: ใช LR test

Step 1: Hypothesis

H0 : ARCH effects

H1: GARCH effects

Step 2 test for first-order GARCH(1,1)

Step 3: LR-test

15

2

0 0 1 1

2

1 0 1 1 1 1

:

:

t t

t t t

H h

H h h

− −

= +

= + +

1 2

2

00.05,if stat , Reject

k kLR H

−−

1 2

2

0.05,stat 2ln log ( ) / log ( ) ,

k kLR l GARCH l ARCH

−− =

𝑘1 คอจ านวน parameter ของ restricted model ซงในกรณน คอ ARCH model

𝑘2 คอจ านวน parameter ของ unrestricted model ซงในกรณน คอ GARCH model

Page 16: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

3) INTEGRATED GARCH(p,q)

• อยางไรกตาม ถาเราพบวา

เราจะพบปญหา unit root ใน ℎ𝑡

เราควรใช Integrated GARCH

โดยท เทานน16

1 1

1,q p

i j

i j

= =

+ =

2

0

1 1

.q p

t i i j t j

i j

h h −

= =

= + +

1 1

1q p

i j

i j

= =

+ =

Page 17: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

SYMMETRYCITY OF GARCH MODELS

• ในแบบจ าลองขางตนทกลาวมา ARCH, GARCH และ IGARCH เราจะสมมตใหผลกระทบของ𝜀𝑡−𝑖2 ตอ ℎ𝑡 มลกษณะสมมาตร (Symmetry) กลาวคอ error ทเปน บวก หรอ ลบ มผลกระทบ

ตอ conditional variance (ℎ𝑡) เทากน

• อยางไรกตามในความเปนจรงขาวดกบขาวราย นาจะสงผลใหเกดความผนผวนทตางกน

• โดยปกตแลว Positive shock < negative shock

17

“leverage” effect.

Page 18: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

4) EGARCH(p,q) Nelson (1991)

• เปน GARCH รปแบบหนงทเปนลกษณะ asymmetric กลาว positive shock ൯𝜀𝑖2(+ และ

Negative shock ൯𝜀𝑖2(− สงผลตอ Volatility ℎ𝑡 ตางกน

18

0

1 1

ln ln .q p

t i t i j t j

i j

h h − −

= =

= + +

Page 19: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

5) AGARCH

• An asymmetric GARCH → AGARCH(p,q)

2

0

1 1

.q p

t i t i j t j

i j

h b h − −

= =

= + − +

Page 20: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

5) GJR-GARCH

• The GJR GARCH model สามารถเขยนไดดงน

2 2

0

1 1 1

,q p q

t i t i j t j i t i t i

i j i

h h I − − − −

= = =

= + + +

1 0

0 0

t i

t i

t i

ifI

if

=

.

ขาวราย

ขาวด

Page 21: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

THRESHOLD GARCH (TGARCH)

• Glosten, Jaganathan and Runkle (1994) เสนอ TGARCH ซงเปนแบบจ าลองทมลกษณะ asymmetric เชนกน

21

0

1 1

( )q p

t i t i i t i j t j

i j

h h − − −

= =

= + − +

Page 22: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

GARCH in MEAN (GARCH-M)

0 1t t ty h = + +

2

0

1 1

q p

t i t i j t j

i j

h h − −

= =

= + +

22

Mean Equation

Variance Equation

Engle Lilien and Robins(1987) กลาววาความผนผวน สามารถทจะสงผลตอตวแปร Y ทอยใน สมการ Mean ได ดงนนจงเสนอแบบจ าลอง GARCH in Mean ขนมา

Page 23: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

Special GARCH

23

ปกตแลว GARCH มกสมมตวาขอมลความผนผวนมการแจกแจงแบบปกต(Normal distribution) ซงในความเปนจรงแลว ขอมลในปจจบนมกจะไมมการแจงแจงแบบปกต โดยเฉพาะขอมลทางการเงน

ดงนนในปจจบนจงมการเสนอให GARCH ประมาณภายใตขอสมมต ของการแจกแจงอยางอน เชน

𝜀|𝜓𝑡−1~𝑆𝑁 0, ℎ𝑡

𝜀|𝜓𝑡−1~𝑇 0, ℎ𝑡

𝜀|𝜓𝑡−1~𝑆𝑇 0, ℎ𝑡

Skewed Normal

Student-t

Skewed student-t

Page 24: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

Programming• Rcode

• Eviews

Page 25: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

R-code ARCH test (SET.xlsx)library(rugarch)

library(dynlm)

#====== Step 1 Import data ===============#

data=read.csv(file.choose(),header=TRUE)

attach(data)

dailyreturn<-diff(log((set)))

plot(ts(dailyreturn, start=c(2008,1,2), freq=252), ylab="return",main="SET index return" )

hist(dailyreturn, main="SET index return" )

#====== Step 2 ARCH (1) Mean Model===============#

meanEq <- dynlm(dailyreturn ~1)

summary(meanEq)

#====== Step 3 ARCH(1) Variance Model ===============#

ehatsq <- ts(resid(meanEq)^2)

ARCH <- dynlm(ehatsq~L(ehatsq,1))

summary(ARCH)

Page 26: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

ผลการรน ARCH(1)Call:

dynlm(formula = ehatsq ~ L(ehatsq, 1))

Residuals:

Min 1Q Median 3Q Max

-0.0028743 -0.0001192 -0.0000982 -0.0000084 0.0107715

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 1.143e-04 1.055e-05 10.83 <2e-16 ***

L(ehatsq, 1) 2.812e-01 1.994e-02 14.10 <2e-16 ***

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.0004847 on 2316 degrees of freedom

Multiple R-squared: 0.07907, Adjusted R-squared: 0.07867

F-statistic: 198.9 on 1 and 2316 DF, p-value: < 2.2e-16

Page 27: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

R-code ARCH test (SET.xlsx)#====== Step 4 LM test ===============#

T=length(dailyreturn)

k1 <- 1

k2 <- 2 #ARCH ม 2 พารามเตอรRsq <- 0.07907

LM <- (T-k)*Rsq

alpha <- 0.05

Chicr <- qchisq(1-alpha, abs(k1-k2))

pvalue =1-pchisq(Chicr, T-k, lower.tail = FALSE)

pvalue[1] 0> Chicr[1] 3.841459> LM [1] 183.1261

# ค าตอบคอ p-value = 0 และ LM>Chicrเราจงปฎเสธ H0 ดงนนขอมล SET ม ARCH

effect

Page 28: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

R-code ARCH and GARCH model (SET.xlsx)

library(rugarch)

library(dynlm)

#====== Step 1 download data ===============#

data=read.csv(file.choose(),header=TRUE)

attach(data)

dailyreturn<-diff(log((set)))

plot(ts(dailyreturn, start=c(2008,1,2), freq=252), ylab="return",main="SET index return" )

hist(dailyreturn, main="SET index return" )

Page 29: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

ARCH(q) MODEL

• ARCH (autoregressive conditionally heteroscedastic) Engle(1982)

( )

( )1

2 2

1 0 1 1

~ 0,

t t

t t

t t t

t t t t q t q

Y

Y

N h

Var h

− − −

= +

= −

= = + + +

Mean Equation มแค intercept term (𝜇) ตวเดยว

Variance Equation

Page 30: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

GARCH(q) MODEL

• GARCH (autoregressive conditionally heteroscedastic)

( )

( )1

2 2

1 0 1 1 1 1 1

~ 0,

...

t t

t t

t t t

t t t t q t q t t p

Y

Y

N h

Var h h h

− − − − −

= +

= −

= = + + + + + +

Mean Equation มแค intercept term (𝜇) ตวเดยว

Variance Equation

Page 31: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

R-code ARCH and GARCH model (SET.xlsx)#====== Step 2 Select GARCH TYPE ===============#

# ARCH(1) == GARCH(1,0) model

arch<-ugarchspec(mean.model = list(armaOrder = c(0, 0)), variance.model = list(model = "fGARCH", garchOrder = c(1, 0), submodel="GARCH"), distribution.model = "norm")

# GARCH(1,1) model

garch<-ugarchspec(mean.model = list(armaOrder = c(0, 0)), variance.model = list(model = "fGARCH", garchOrder = c(1, 1), submodel="GARCH"), distribution.model = "norm")

# IGARCH(1,1) model

Igarch<-ugarchspec(mean.model = list(armaOrder = c(0, 0)),variance.model = list(model = "iGARCH", garchOrder = c(1, 1)), distribution.model = "norm")

# TGARCH(1,1) model

Tgarch<-ugarchspec(mean.model = list(armaOrder = c(0, 0)), variance.model = list(model = "fGARCH", garchOrder = c(1, 1), submodel="TGARCH"), distribution.model = "norm")

# AGARCH(1,1) model

Agarch<-ugarchspec(mean.model = list(armaOrder = c(0, 0)), variance.model = list(model = "fGARCH", garchOrder = c(1, 1), submodel="AVGARCH"), distribution.model = "norm")

Page 32: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

R-code ARCH and GARCH model (SET.xlsx)#====== Step 2 Select GARCH TYPE ===============#

# GJRGARCH(1,1) model

GJRgarch<-ugarchspec(mean.model = list(armaOrder = c(0, 0)), variance.model = list(model = "fGARCH", garchOrder = c(1, 1), submodel="GJRGARCH"), distribution.model = "norm")

# GARCH(1,1) in Mean model

garchM<-ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1)),

mean.model = list(armaOrder = c(0, 0),include.mean = TRUE,archm = TRUE, archpow =2), distribution.model = "norm")

Page 33: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

R-code ARCH and GARCH model (SET.xlsx)

#====== Step 3 Maximum Likelihood Estimator EX: GARCH-M

modelfit<-ugarchfit(spec=garchM,data=dailyreturn)

modelfit

Page 34: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

#====== Step 4 Plot Volatility EX: GARCH-M ===============#

hhat <- ts(modelfit@fit$sigma^2)

plot(ts(hhat, start=c(2008,1,2), freq=252), ylab="volatility",main="SET index volatility")

SET index volatility

Time

vo

latility

2008 2010 2012 2014 2016

0.0

00

00

.00

10

0.0

02

00

.00

30

Page 35: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

Eviews GARCH model

• Step 1 ขอมลเขา EVIEW โดยใชขอมล จาก SET.xlsx

Page 36: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

Eviews GARCH model

• Step 1 ขอมลเขา EVIEW โดยใชขอมล จาก SET.xlsx

Page 37: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

Eviews GARCH model• Step 2 เรมรน GARCH

(1) กด quick

(2) Click

(3) พมพ set c

Page 38: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

Eviews GARCH model• Step 2 เรมรน GARCH

(1) กด quick

(2) เลอก ARCH

(3) เลอกชนดของ GARCH (4) เลอกชนดของ order GARCH(p,q) ตวอยาง คอ GARCH(1,1)

(5) เลอก distribution ของ GARCH

(6) กด OK

Page 39: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

Eviews GARCH model

• Step 4 Plot Volatility

Page 40: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

Eviews GARCH model• Step 4 Plot Volatility

(1) กด view

(2)

(3)

Page 41: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

Eviews GARCH model• ผลการ plot volatility

หมายเหต โปรแกรม Eview ท าไดแคบางประเภทของ GARCH และ distribution นน เชน ARCH, GARCH,TGARCH, EGARCH และ IGARCH (normal, student-t, GED) ไปด STEP 2

Page 42: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

แบบฝกหดทายบทท 4 (ทฤษฎ)

1) สมการ Mean และสมการ Variance เหมอนหรอตางกนอยางไร และเมอใดเราจะเลอกใช Mean และเมอใด เราจะเลอกใชสมการ Variance จงยกตวอยางใหพอเขาใจ

2) สมมตวาเรามขอมล Y จ านวน T=100 เราท าการประมาณสมการ GARCH(1,2) แลวพบวาคา likelihood = 150 และเมอประมาณสมการ ARCH(2) พบวามคา likelihood = 120 จงแสดงวธการทดสอบวาแบบจ าลองขอมล Y นม GARCH effect และ ARCH effect หรอไม

3) สมการ GJR-GARCH คอ

ถา 𝜑1 มคาเทากบ 0 และ 𝜀𝑡−1 = −2 เราจะเขยนสมการ GJR-GARCH ใหมไดอยางไร และถาเทยบกบแบบจ าลอง GARCH ความผนผวนทค านวณไดจะเทากนหรอไม จงอธบาย

2 2

0 1 1 1 1 1 1,t t t j t th h I − − − −= + + +

1 0

0 0

t i

t i

t i

ifI

if

=

Page 43: Chapter 4 · . 03 2013 .¥. 02 2014 . ... 0.05, kk 0 𝑘1 คือจ านวน parameter ของ restricted model ซึ่งในกรณีนี้คือ 1 ตัว

แบบฝกหดทายบทท 4 (Practice) ใชขอมลราคาจาก singapore.xlsx1) จงทดสอบวา ผลตอบแทนของ SET index ม ARCH effect หรอไม โดยใช R หรอ EViews ก

ได จงแสดงผลและแปลผลการศกษา

2) สมมตวา order GARCH(2,2) เปนรปแบบท order ดทสด จงท าการทดสอบดวาแบบจ าลองประเภทใดของ GARCH ทสอนในบทท 4 เปนแบบจ าลองทดทสด จงเขยน Code และแสดงวธการเลอกแบบจ าลองของนกศกษา และสดทาย จงแปลผลการศกษาและ plot ความผนผวนดวย (ขอใหสง code แนบทายค าตอบดวย)