Chicago Boothf Garch Script

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

6/18/12 5:52 PM

fGarch package
**** For more details, please download a copy of the fGarch document from the R mirror.
**** The document is fGarch.pdf.
****
**** Output edited ***
> setwd("C:/Users/rst/teaching/bs41202/sp2010")
> da=read.table("m-intc7303.txt")
> intc=log(da[,2]+1)
> library(fGarch)

> help(garchFit,package="fGarch")

> m1=garchFit(~garch(3,0),data=intc)

Series Initialization:
ARMA Model: arma
Formula Mean: ~ arma(0, 0)
GARCH Model: garch
Formula Variance: ~ garch(3, 0)
ARMA Order: 0 0
Max ARMA Order: 0
GARCH Order: 3 0
Max GARCH Order: 3
Maximum Order: 3
Conditional Dist: norm
h.start: 4
llh.start: 1
Length of Series: 372
Recursion Init: mci
Series Scale: 0.1337381 <=== Sample standard error

Parameter Initialization:
Initial Parameters: $params
Limits of Transformations: $U, $V
Which Parameters are Fixed? $includes
Parameter Matrix:
U V params includes
mu -1.34515434 1.345154 0.13451543 TRUE
omega 0.00000100 100.000000 0.10000000 TRUE
alpha1 0.00000001 1.000000 0.03333333 TRUE
alpha2 0.00000001 1.000000 0.03333333 TRUE
alpha3 0.00000001 1.000000 0.03333333 TRUE
gamma1 -0.99999999 1.000000 0.10000000 FALSE
gamma2 -0.99999999 1.000000 0.10000000 FALSE
gamma3 -0.99999999 1.000000 0.10000000 FALSE
delta 0.00000000 2.000000 2.00000000 FALSE
skew 0.10000000 10.000000 1.00000000 FALSE
shape 1.00000000 10.000000 4.00000000 FALSE
Index List of Parameters to be Optimized:
mu omega alpha1 alpha2 alpha3
1 2 3 4 5
Persistence: 0.1

--- START OF TRACE ---


Selected Algorithm: nlminb <=== Omptimization method used by R.

http://faculty.chicagobooth.edu/ruey.tsay/teaching/bs41202/sp2010/fGarch.txt Page 1 of 6
6/18/12 5:52 PM

R coded nlminb Solver:

0: 1032.0260: 0.134515 0.100000 0.0333333 0.0333333 0.0333333


1: 548.38921: 0.134307 0.860030 0.459424 0.387068 0.373436
.......
31: 514.98790: 0.123916 0.673341 0.208649 0.0718372 0.0490449

Final Estimate of the Negative LLH:


LLH: -233.4286 norm LLH: -0.6274962
mu omega alpha1 alpha2 alpha3
0.01657227 0.01204329 0.20864875 0.07183715 0.04904486

R-optimhess Difference Approximated Hessian Matrix:


mu omega alpha1 alpha2 alpha3
mu -24544.40441 5432.428 -79.56617 -31.75056 -163.7026
omega 5432.42796 -769914.108 -7009.25413 -6934.08249 -8244.4917
alpha1 -79.56617 -7009.254 -137.50812 -127.67375 -127.2846
alpha2 -31.75056 -6934.082 -127.67375 -543.26368 -118.8571
alpha3 -163.70256 -8244.492 -127.28460 -118.85710 -545.1020
attr(,"time")
Time difference of 0.04999995 secs

--- END OF TRACE ---

Time to Estimate Parameters:


Time difference of 0.2449999 secs

> m1 <== Obtain estimation results [You may use summary(m1) to include model chekcing
statistics]

Title:
GARCH Modelling

Call:
garchFit(formula = ~garch(3, 0), data = intc)

Mean and Variance Equation:


data ~ garch(3, 0)
[data = intc]

Conditional Distribution:
norm

Coefficient(s):
mu omega alpha1 alpha2 alpha3
0.016572 0.012043 0.208649 0.071837 0.049045

Std. Errors:
based on Hessian

Error Analysis:
Estimate Std. Error t value Pr(>|t|)
mu 0.016572 0.006423 2.580 0.00988 **
omega 0.012043 0.001579 7.627 2.4e-14 ***
alpha1 0.208649 0.129177 1.615 0.10626
alpha2 0.071837 0.048551 1.480 0.13897
alpha3 0.049045 0.048847 1.004 0.31536

http://faculty.chicagobooth.edu/ruey.tsay/teaching/bs41202/sp2010/fGarch.txt Page 2 of 6
6/18/12 5:52 PM

---

Log Likelihood:
233.4286 normalized: 0.6274962

> m1=garchFit(~garch(1,0),data=intc,trace=F) <== Without details of estimation

> m1

Title:
GARCH Modelling

Call:
garchFit(formula = ~garch(1, 0), data = intc)

Mean and Variance Equation:


data ~ garch(1, 0)
[data = intc]

Conditional Distribution:
norm

Coefficient(s):
mu omega alpha1
0.016570 0.012490 0.363447

Std. Errors:
based on Hessian

Error Analysis:
Estimate Std. Error t value Pr(>|t|)
mu 0.016570 0.006161 2.689 0.00716 **
omega 0.012490 0.001549 8.061 6.66e-16 ***
alpha1 0.363447 0.131598 2.762 0.00575 **
---

Log Likelihood:
230.2423 normalized: 0.6189309

> plot(m1@residuals,type='l')
> plot([email protected],type='l')
>
> m1=garchFit(~garch(1,0),data=intc,cond.dist=c("std"))

Series Initialization:
ARMA Model: arma
Formula Mean: ~ arma(0, 0)
GARCH Model: garch
Formula Variance: ~ garch(1, 0)
ARMA Order: 0 0
Max ARMA Order: 0
GARCH Order: 1 0
Max GARCH Order: 1
Maximum Order: 1
Conditional Dist: std
h.start: 2
llh.start: 1

http://faculty.chicagobooth.edu/ruey.tsay/teaching/bs41202/sp2010/fGarch.txt Page 3 of 6
6/18/12 5:52 PM

Length of Series: 372


Recursion Init: mci
Series Scale: 0.1337381

Parameter Initialization:
Initial Parameters: $params
Limits of Transformations: $U, $V
Which Parameters are Fixed? $includes
Parameter Matrix:
U V params includes
mu -1.34515434 1.345154 0.1345154 TRUE
omega 0.00000100 100.000000 0.1000000 TRUE
alpha1 0.00000001 1.000000 0.1000000 TRUE
gamma1 -0.99999999 1.000000 0.1000000 FALSE
delta 0.00000000 2.000000 2.0000000 FALSE
skew 0.10000000 10.000000 1.0000000 FALSE
shape 1.00000000 10.000000 4.0000000 TRUE
Index List of Parameters to be Optimized:
mu omega alpha1 shape
1 2 3 7
Persistence: 0.1

--- START OF TRACE ---


Selected Algorithm: nlminb

R coded nlminb Solver:

0: 751.30286: 0.134515 0.100000 0.100000 4.00000


1: 509.26981: 0.134724 1.03838 0.445570 4.00487
.......
15: 505.44871: 0.161293 0.750519 0.259867 5.98598

Final Estimate of the Negative LLH:


LLH: -242.9678 norm LLH: -0.6531391
mu omega alpha1 shape
0.02157100 0.01342368 0.25986664 5.98597870

R-optimhess Difference Approximated Hessian Matrix:


mu omega alpha1 shape
mu -27906.18222 -359.7564 -142.562477 -11.9639582
omega -359.75643 -499571.6752 -4035.320804 -302.7922516
alpha1 -142.56248 -4035.3208 -102.960480 -2.7019238
shape -11.96396 -302.7923 -2.701924 -0.5519108
attr(,"time")
Time difference of 0.03200006 secs

--- END OF TRACE ---

Time to Estimate Parameters:


Time difference of 0.125 secs
> m1

Title:
GARCH Modelling

Call:

http://faculty.chicagobooth.edu/ruey.tsay/teaching/bs41202/sp2010/fGarch.txt Page 4 of 6
6/18/12 5:52 PM

garchFit(formula = ~garch(1, 0), data = intc, cond.dist = c("std"))

Mean and Variance Equation:


data ~ garch(1, 0)
[data = intc]

Conditional Distribution:
std

Coefficient(s):
mu omega alpha1 shape
0.021571 0.013424 0.259867 5.985979

Std. Errors:
based on Hessian

Error Analysis:
Estimate Std. Error t value Pr(>|t|)
mu 0.021571 0.006054 3.563 0.000366 ***
omega 0.013424 0.001968 6.820 9.09e-12 ***
alpha1 0.259867 0.119901 2.167 0.030209 *
shape 5.985979 1.660030 3.606 0.000311 ***
---

Log Likelihood:
242.9678 normalized: 0.6531391

> m1=garchFit(~garch(1,0),data=intc,cond.dist=c("std"),trace=F) <=== Without details of


estimation
> m1

Title:
GARCH Modelling

Call:
garchFit(formula = ~garch(1, 0), data = intc, cond.dist = c("std"),
trace = F)

Mean and Variance Equation:


data ~ garch(1, 0)
[data = intc]

Conditional Distribution:
std

Coefficient(s):
mu omega alpha1 shape
0.021571 0.013424 0.259867 5.985979

Std. Errors:
based on Hessian

Error Analysis:
Estimate Std. Error t value Pr(>|t|)
mu 0.021571 0.006054 3.563 0.000366 ***
omega 0.013424 0.001968 6.820 9.09e-12 ***
alpha1 0.259867 0.119901 2.167 0.030209 *

http://faculty.chicagobooth.edu/ruey.tsay/teaching/bs41202/sp2010/fGarch.txt Page 5 of 6
6/18/12 5:52 PM

shape 5.985979 1.660030 3.606 0.000311 ***


---
Log Likelihood:
242.9678 normalized: 0.6531391

> sresi=m1@residuals/[email protected] <=== Obtain standardized residuals


> Box.test(sresi,lag=10,type='Ljung')

Box-Ljung test

data: sresi
X-squared = 14.3129, df = 10, p-value = 0.1592

> Box.test(sresi^2,lag=10,type='Ljung')

Box-Ljung test

data: sresi^2
X-squared = 15.3592, df = 10, p-value = 0.1195

http://faculty.chicagobooth.edu/ruey.tsay/teaching/bs41202/sp2010/fGarch.txt Page 6 of 6

You might also like