Lec4 17
Lec4 17
i=1 i=1
2
VIXCLS [1990−01−02/2017−04−06]
Last 12.39
80
70
60
50
40
30
20
10
Jan 02 1990 Jan 02 1996 Jan 02 2002 Jan 02 2008 Jan 02 2014
Figure 1: Time plot of the daily VIX index from January 2, 1990 to April 6,2017.
Consider the daily closing index of the S&P500 index from January
03, 2007 to April 06, 2017. The log returns follow approximately an
MA(2) model
rt = 0.0002 + at − 0.109at−1 − 0.053at−2, σ 2 = 0.00017.
The residuals show no strong serial correlations. [plot not shown.]
R Demonstration
> require(quantmod)
> getSymbols("^GSPC",from="2007-01-03",to="2017-04-06")
[1] "GSPC"
> dim(GSPC)
[1] 2584 6
> head(GSPC)
GSPC.Open GSPC.High GSPC.Low GSPC.Close GSPC.Volume GSPC.Adjusted
2007-01-03 1418.03 1429.42 1407.86 1416.60 3429160000 1416.60
..
2007-01-10 1408.70 1415.99 1405.32 1414.85 2764660000 1414.85
> spc <- log(as.numeric(GSPC[,6]))
> rtn <- diff(spc)
> acf(rtn)
3
0.10
0.05
residuals−sprtn
0.00
−0.05
Time
Figure 2: Time plot of residuals of an MA(2) model fitted to daily log returns of the S&P
500 index from January 3, 2007 to April 06, 2017.
Series m1$residuals^2
1.0
0.8
0.6
ACF
0.4
0.2
0.0
0 5 10 15 20 25 30 35
Lag
Figure 3: Sample ACF of the squared residuals of an MA(2) model fitted to daily log returns
of the S&P 500 index from January 3, 2007 to April 06, 2017.
4
> m1 <- arima(rtn,order=c(0,0,2))
> m1
Call: arima(x = rtn, order = c(0, 0, 2))
Coefficients:
ma1 ma2 intercept
-0.1088 -0.0530 2e-04
s.e. 0.0198 0.0205 2e-04
ARCH model
at = σtt, σt2 = α0 + α1a2t−1 + · · · + αma2t−m,
where {t} is a sequence of iid r.v. with mean 0 and variance 1,
α0 > 0 and αi ≥ 0 for i > 0.
Distribution of t: Standard normal, standardized Student-t, gener-
alized error dist (ged), or their skewed counterparts.
Properties of ARCH models
Consider an ARCH(1) model
at = σtt, σt2 = α0 + α1a2t−1,
where α0 > 0 and α1 ≥ 0.
1. E(at) = 0
2. Var(at) = α0/(1 − α1) if 0 < α1 < 1
3. Under normality,
3α02(1 + α1)
m4 = ,
(1 − α1)(1 − 3α12)
provided 0 < α12 < 1/3.
6
The 3rd property implies heavy tails.
Advantages
• Simplicity
• Generates volatility clustering
• Heavy tails (high kurtosis)
Weaknesses
• Symmetric between positive & negative prior returns
• Restrictive
• Provides no explanation
• Not sufficiently adaptive in prediction
Building an ARCH Model
1. Modeling the mean effect and testing for ARCH effects
Ho: no ARCH effects versus Ha : ARCH effects
Use Q-statistics of squared residuals; McLeod and Li (1983) &
Engle (1982)
2. Order determination
Use PACF of the squared residuals. (In practice, simply try some
reasonable order).
3. Estimation: Conditional MLE
4. Model checking: Q-stat of standardized residuals and squared
standardized residuals. Skewness & Kurtosis of standardized
residuals.
7
R provides many plots for model checking and for presenting the
results.
5. Software: We use R with the package fGarch. (Other software
available).
Estimation: Conditional MLE or Quasi MLE
Special Note: In this course, we estimate volatility models using
the R package fGarch with garchFit command. The program is
easy to use and allows for several types of innovational distributions:
The default is Gaussian (norm), standardized Student-t distribution
(std), generalized error distribution (ged), skew normal distribution
(snorm), skew Student-t (sstd), skew generalized error distribution
(sged), and standardized inverse normal distribution (snig). Except
for the inverse normal distribution, other distribution functions are
discussed in the textbook. Readers should check the book for details
about the density functions and their parameters.
Example: Monthly log returns of Intel stock
R demonstration: The fGarch package. Output edited.
> library(fGarch)
> da=read.table("m-intc7303.txt",header=T)
> head(da)
date rtn
1 19730131 0.01005
.....
6 19730629 0.13333
> intc=log(da$rtn+1) <== log returns
> acf(intc)
> acf(intc^2)
> pacf(intc^2)
> Box.test(intc^2,lag=10,type=’Ljung’)
Box-Ljung test
data: intc^2
X-squared = 59.7216, df = 10, p-value = 4.091e-09
8
> m1=garchFit(~garch(3,0),data=intc,trace=F) <== trace=F reduces the amount of output.
> summary(m1)
Title: GARCH Modelling
Call: garchFit(formula = ~garch(3, 0), data = intc, trace = F)
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
---
Standardised Residuals Tests:
Statistic p-Value
Jarque-Bera Test R Chi^2 169.7731 0
Shapiro-Wilk Test R W 0.9606957 1.970413e-08
Ljung-Box Test R Q(10) 10.97025 0.3598405
Ljung-Box Test R Q(15) 19.59024 0.1882211
Ljung-Box Test R Q(20) 20.82192 0.40768
Ljung-Box Test R^2 Q(10) 5.376602 0.864644
Ljung-Box Test R^2 Q(15) 22.73460 0.08993976
Ljung-Box Test R^2 Q(20) 23.70577 0.255481
LM Arch Test R TR^2 20.48506 0.05844884
> m1=garchFit(~garch(1,0),data=intc,trace=F)
> summary(m1)
Title: GARCH Modelling
9
Call: garchFit(formula = ~garch(1, 0), data = intc, trace = F)
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)
Make a plot selection (or 0 to exit):
1: Time Series
2: Conditional SD
3: Series with 2 Conditional SD Superimposed
10
4: ACF of Observations
5: ACF of Squared Observations
6: Cross Correlation
7: Residuals
8: Conditional SDs
9: Standardized Residuals
10: ACF of Standardized Residuals
11: ACF of Squared Standardized Residuals
12: Cross Correlation between r^2 and r
13: QQ-Plot of Standardized Residuals
Selection: 13
1: Time Series
2: Conditional SD
3: Series with 2 Conditional SD Superimposed
4: ACF of Observations
5: ACF of Squared Observations
6: Cross Correlation
7: Residuals
8: Conditional SDs
9: Standardized Residuals
10: ACF of Standardized Residuals
11: ACF of Squared Standardized Residuals
12: Cross Correlation between r^2 and r
13: QQ-Plot of Standardized Residuals
Selection: 0
2
Sample Quantiles
0
−2
−4
−3 −2 −1 0 1 2 3
Theoretical Quantiles
Figure 4: QQ-plot for standardized residuals of an ARCH(1) model with Gaussian innova-
tions for monthly log returns of INTC stock: 1973 to 2003.
> m2=garchFit(~garch(1,0),data=intc,cond.dist="std",trace=F)
> summary(m2)
Title: GARCH Modelling
Coefficient(s):
mu omega alpha1 shape
0.021571 0.013424 0.259867 5.985979
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 *
12
shape 5.985979 1.660030 3.606 0.000311 *** <== Estimate of degrees of freedom
---
Log Likelihood:
242.9678 normalized: 0.6531391
> plot(m2)
Make a plot selection (or 0 to exit):
1: Time Series
2: Conditional SD
3: Series with 2 Conditional SD Superimposed
4: ACF of Observations
5: ACF of Squared Observations
6: Cross Correlation
7: Residuals
8: Conditional SDs
9: Standardized Residuals
10: ACF of Standardized Residuals
11: ACF of Squared Standardized Residuals
12: Cross Correlation between r^2 and r
13: QQ-Plot of Standardized Residuals
Selection: 13 <== The plot shows that the model needs further improvements.
13
5 0.02157100 0.1346130 0.1346130
GARCH Model
at = σtt,
m s
σt2 = α0 + αia2t−i + 2
βj σt−j
X X
i=1 j=1
where {t} is defined as before, α0 > 0, αi ≥ 0, βj ≥ 0, and
Pmax(m,s)
i=1 (αi + βi) < 1.
Re-parameterization:
Let ηt = a2t − σt2. {ηt} un-correlated series.
The GARCH model becomes
max(m,s) s
a2t = α0 + (αi + βi)a2t−i + ηt − βj ηt−j .
X X
i=1 j=1
15
The fitted of a Gaussian AR(3) model
r̃t = rt − 0.0062
r̃t = .089r̃t−1 − .024r̃t−2 − .123r̃t−3 + .007 + at,
σ̂a2 = 0.00333.
For the GARCH effects, use a GARCH(1,1) model, we have
A joint estimation:
rt = 0.032rt−1 − 0.030rt−2 − 0.011rt−3 + 0.0077 + at
σt2 = 7.98 × 10−5 + .853σt−1
2
+ 0.124a2t−1.
Implied unconditional variance of at is
0.0000798
= 0.00352
1 − 0.853 − 0.1243
close to the expected value. All AR coefficients are statistically in-
significant.
A simplified model:
rt = 0.00745 + at, σt2 = 8.06 × 10−5 + .854σt−1
2
+ .122a2t−1.
Model checking:
For ãt: Q(10) = 11.22(0.34) and Q(20) = 24.30(0.23).
For ã2t : Q(10) = 9.92(0.45) and Q(20) = 16.75(0.67).
Forecast: 1-step ahead forecast:
σh2 (1) = 0.00008 + 0.854σh2 + 0.122a2h
Horizon 1 2 3 4 5 ∞
Return .0074 .0074 .0074 .0074 .0074 .0074
Volatility .054 .054 .054 .054 .054 .059
R demonstration:
16
> sp5=scan("sp500.txt")
Read 792 items
> pacf(sp5)
> m1=arima(sp5,order=c(3,0,0))
> m1
Call: arima(x = sp5, order = c(3, 0, 0))
Coefficients:
ar1 ar2 ar3 intercept
0.0890 -0.0238 -0.1229 0.0062
s.e. 0.0353 0.0355 0.0353 0.0019
Error Analysis:
Estimate Std. Error t value Pr(>|t|)
mu 7.708e-03 1.607e-03 4.798 1.61e-06 ***
ar1 3.197e-02 3.837e-02 0.833 0.40473
ar2 -3.026e-02 3.841e-02 -0.788 0.43076
ar3 -1.065e-02 3.756e-02 -0.284 0.77677
omega 7.975e-05 2.810e-05 2.838 0.00454 **
alpha1 1.242e-01 2.247e-02 5.529 3.22e-08 ***
beta1 8.530e-01 2.183e-02 39.075 < 2e-16 ***
---
Log Likelihood:
1272.179 normalized: 1.606287
17
Ljung-Box Test R^2 Q(15) 14.22819 0.5082978
Ljung-Box Test R^2 Q(20) 16.79404 0.6663038
LM Arch Test R TR^2 13.34305 0.3446075
> m2=garchFit(~garch(1,1),data=sp5,trace=F)
> summary(m2)
Title: GARCH Modelling
Call: garchFit(formula = ~garch(1, 1), data = sp5, trace = F)
Error Analysis:
Estimate Std. Error t value Pr(>|t|)
mu 7.450e-03 1.538e-03 4.845 1.27e-06 ***
omega 8.061e-05 2.833e-05 2.845 0.00444 **
alpha1 1.220e-01 2.202e-02 5.540 3.02e-08 ***
beta1 8.544e-01 2.175e-02 39.276 < 2e-16 ***
---
Log Likelihood:
1269.455 normalized: 1.602848
> plot(m2)
18
Make a plot selection (or 0 to exit):
1: Time Series
2: Conditional SD
3: Series with 2 Conditional SD Superimposed
4: ACF of Observations
5: ACF of Squared Observations
6: Cross Correlation
7: Residuals
8: Conditional SDs
9: Standardized Residuals
10: ACF of Standardized Residuals
11: ACF of Squared Standardized Residuals
12: Cross Correlation between r^2 and r
13: QQ-Plot of Standardized Residuals
Selection: 3
> predict(m2,6)
meanForecast meanError standardDeviation
1 0.007449721 0.05377242 0.05377242
2 0.007449721 0.05388567 0.05388567
3 0.007449721 0.05399601 0.05399601
4 0.007449721 0.05410353 0.05410353
5 0.007449721 0.05420829 0.05420829
6 0.007449721 0.05431038 0.05431038
IGARCH model
An IGARCH(1,1) model:
at = σtt, σt2 = α0 + β1σt−1
2
+ (1 − β1)a2t−1.
19
Series with 2 Conditional SD Superimposed
0.4
0.2
x
0.0
−0.2
Index
For the monthly excess returns of the S&P 500 index, we have
rt = .007 + at, σt2 = .0001 + .806σt−1
2
+ .194a2t−1
For an IGARCH(1,1) model,
σh2 (`) = σh2 (1) + (` − 1)α0, ` ≥ 1,
where h is the forecast origin.
Effect of σh2 (1) on future volatilities is persistent, and the volatility
forecasts form a straight line with slope α0. See Nelson (1990) for
more info.
Special case: α0 = 0. Volatility forecasts become a constant.
This property is used in RiskMetrics to VaR calculation.
Example: An IGARCH(1,1) model for the monthly excess returns
of S&P500 index from 1926 to 1991 is given below via R.
rt = 0.0069 + at, at = σtt
20
σt2 = 0.099a2t−1 + .901σt−1
2
.
R demonstration: Using R script Igarch.R.
> source("Igarch.R")
> sp5=scan(file="sp500.txt")
> Igarch(sp5,include.mean=T)
Estimates: 0.006874402 0.9007153
Maximized log-likehood: -1258.219
Coefficient(s):
Estimate Std. Error t value Pr(>|t|)
mu 0.0068744 0.0015402 4.46332 8.07e-06 ***
beta 0.9007153 0.0158018 57.00082 < 2e-16 ***
Another R package: rugarch can be used to fit volatility models
too.
> sp5=scan("sp500.txt")
> require(rugarch)
>spec1=ugarchspec(variance.model=list(model="iGARCH",garchOrder=c(1,1)),
mean.model=list(armaOrder=c(0,0)))
> mm=ugarchfit(data=sp5,spec=spec1)
> mm
*---------------------------------*
* GARCH Model Fit *
*---------------------------------*
Conditional Variance Dynamics
-----------------------------------
GARCH Model : iGARCH(1,1)
Mean Model : ARFIMA(0,0,0)
Distribution : norm
Optimal Parameters
------------------------------------
Estimate Std. Error t value Pr(>|t|)
mu 0.007417 0.001525 4.8621 0.000001
omega 0.000051 0.000018 2.9238 0.003458
alpha1 0.142951 0.021443 6.6667 0.000000
beta1 0.857049 NA NA NA
21
LogLikelihood : 1268.238
Information Criteria
------------------------------------
Akaike -3.1950
Bayes -3.1773
Shibata -3.1951
Hannan-Quinn -3.1882
22