Empirical application of volatility models

Một phần của tài liệu Financial risk modelling and portfolio optimization with r second edition (Trang 141 - 146)

In this section a back-test of the expected shortfall at a 99% confidence level for New York Stock Exchange (NYSE) daily returns is conducted. TheRcode is shown in Listing 8.1. This data set is a supplement to the monograph of Stock and Wat- son (2007) and is contained in the AERpackage (see Kleiber and Zeileis 2008).

Rcode 8.1Expected shortfall derived from GARCH(1, 1) models l i b r a r y (AER) 1

l i b r a r y ( f G a r c h ) 2

d a t a (NYSESW) 3

NYSELOSS <− t i m e S e r i e s (−1 . 0 d i f f ( l o g (NYSESW) ) 1 0 0 , 4

c h a r . v e c = t i m e (NYSESW) ) 5

# # F u n c t i o n f o r ES o f tGARCH 6

E S g a r c h <− f u n c t i o n ( y , p = 0 . 9 9 ) { 7

g f i t <− g a r c h F i t ( f o r m u l a = ∼g a r c h ( 1 , 1 ) , d a t a = y , 8

cond . d i s t = " s t d " , t r a c e = FALSE ) 9

s i g m a <− p r e d i c t ( g f i t , n . a h e a d = 1 ) [ 3 ] 10

d f <− c o e f ( g f i t ) [ " s h a p e " ] 11

ES <− s i g m a ( d t ( q t ( p , d f ) , d f ) / ( 1 − p ) ) 12

( ( d f + ( q t ( p , d f ) ) ^ 2 ) / ( d f − 1 ) ) 13

r e t u r n ( ES ) 14

} 15

# # D a t e v e c t o r s f o r b a c k t e s t 16

f r o m <− t i m e ( NYSELOSS ) [−c ( ( nrow ( NYSELOSS ) − 9 9 9 ) : 17

nrow ( NYSELOSS ) ) ] 18

t o <− t i m e ( NYSELOSS ) [−c ( 1 : 1 0 0 0 ) ] 19

NYSEES <− f a p p l y ( NYSELOSS , f r om = from , t o = t o , FUN = E S g a r c h ) 20

NYSEESL1 <− l a g ( NYSEES , k = 1 ) 21

r e s <− na . o m i t ( c b i n d ( NYSELOSS , NYSEESL1 ) ) 22

c o l n a m e s ( r e s ) <− c ( "NYSELOSS" , " ES99 " ) 23

p l o t ( r e s [ , 2 ] , c o l = " r e d " , y l i m = r a n g e ( r e s ) , 24

main = "NYSE : t−GARCH( 1 , 1 ) ES 99%" , 25

y l a b = " p e r c e n t a g e s " , x l a b = " " ) 26

p o i n t s ( r e s [ , 1 ] , t y p e = " p " , c e x = 0 . 2 , pch = 1 9 , c o l = " b l u e " ) 27

l e g e n d ( " t o p l e f t " , l e g e n d = c ( " L o s s " , " ES " ) , 28

c o l = c ( " b l u e " , " r e d " ) , l t y = c (NA, 1 ) , pch = c ( 1 9 , NA) ) 29

k k

percentages

1992−01−01 1996−01−01 2000−01−01 2004−01−01

−4−20246

Figure 8.2 Time series plot for daily losses of NYSE.

The sample runs from 2 January 1990 to 11 November 2005 and contains 4003 observations. The necessary packages and the data set are loaded into the workspace with the first three commands in theRcode listing. Next, the daily compound losses are computed as percentages and expressed as positive numbers. The stylized facts of this series are pretty evident from Figure 8.2.

In order to conduct the back-test, the function ESgarch()is defined in lines 6–14. Within this function a GARCH(1, 1) model with a Student’st-distributed in- novation process is estimated first. The one-step-ahead forecast of the conditional standard deviation is computed next, and the fitted value of the degrees-of-freedom

NYSE: t−GARCH(1,1) ES 99%

percentages

0 500 1000 1500 2000 2500 3000

−50510 Loss

ES

Figure 8.3 Comparison of daily losses of NYSE and ES.

k k parameter is assigned to the objectdf. The expected shortfall is then computed for

the default confidence level ofp = 0.99. Incidentally, the mean equation of this GARCH model consists of a constant only and is omitted in the calculation of the ES.

Given that its estimate represents the mean of the series which is empirically close to zero, it can safely be discarded from the computation of the ES. The back-test itself is then conducted by utilizing a sliding window with 1000 observations. The function fapply()comes in handy for conducting back-tests of this kind. Two date vectors are created in which the start and end dates of this moving window through time are stored. In the next line the functionfapply()will callESgarch()with the subsamples of the losses according to the date values contained in the objectsfrom andto. It should be noted that the ES numbers are now associated with the date values offrom. But these conditional risk measures pertain to the next trading day and hence the series must be lagged by one period (objectNYSEESL1) for comparison with the actual losses. The size of the back-test therefore consists of 3001 risk measure–loss pairs. A graphical comparison of the actual losses and the conditional ES for a 99%

confidence level is produced in the final lines. The outcome is shown in Figure 8.3.

Not only are the spikes of the daily losses captured pretty well by this conditional risk measure, but also the level of the risk measure decreases rapidly during the more tranquil periods. During this back-test simulation only five violations occurred. This is a little too conservative, given that roughly 15 exceedances can be expected.

References

Ardia D. 2008Financial Risk Management with Bayesian Estimation of GARCH Models: The- ory and Applicationsvol. 612 ofLecture Notes in Economics and Mathematical Systems.

Springer-Verlag, Berlin, Germany.

Ardia D. 2009 Bayesian estimation of a Markov-switching threshold asymmetric GARCH model with Student-t innovations.Econometrics Journal12(1), 105–126.

Ardia D. 2015bayesGARCH: Bayesian Estimation of the GARCH(1,1) Model with Student-t Innovations in R. Version 2.0.2.

Ardia D. and Hoogerheide L. 2010 Bayesian estimation of the GARCH(1,1) model with Student-t innovations.The R Journal2(2), 41–47. URL http://journal.r-project.org/.

Bera A. and Higgins H. 1993 ARCH models: Properties, estimation and testing.Journal of Economic Surveys7(4), 305–362.

Black F. 1976 Studies of stock price volatility changesProceedings of the 1976 Meeting of Business and Economics Statistics Section, pp. 177–181 American Statistical Association.

Bollerslev T. 1986 Generalised autoregressive conditional heteroscedasticity. Journal of Econometrics31, 307–327.

Bollerslev T., Chou R., and Kramer K. 1992 Arch modeling in finance.Journal of Econometrics 52, 5–59.

Boswijk H. P. and van der Weide R. 2006 Wake me up before you GO-GARCH. Discussion Paper TI 2006-079/4, University of Amsterdam and Tinbergen Institute, Amsterdam.

Boswijk H. P. and van der Weide R. 2009 Method of moments estimation of GO-GARCH models. Working paper, University of Amsterdam and Tinbergen Institute and World Bank, Amsterdam.

k k Burger M., Jỹnemann K., and Kửnig T. 2015RUnit: R Unit Test Framework. R package version

0.4.31.

Ding Z., Granger C., and Engle R. 1993 A long memory property of stock market returns and a new model.Journal of Empirical Finance1, 83–106.

do Rego Sousa T., Otiniano C., and Lopes S. 2015GEVStableGarch. R package version 1.1.

Eddelbỹttel D. and Franỗois R. 2011 Rcpp: Seamless R and C++integration.Journal of Sta- tistical Software40(8), 1–18.

Eddelbüttel D. and Sanderson C. 2014 RcppArmadillo: Accelerating R with high-performance C++linear algebra.Computational Statistics and Data Analysis71, 1054–1063.

Engle R. 1982 Autoregressive conditional heteroscedasticity with estimates of the variance of United Kingdom inflation.Econometrica50(4), 987–1007.

Engle R. 2002 Dynamic conditional correlation.Journal of Business & Economic Statistics 20(3), 339–350.

Engle R. and Bollerslev T. 1986 Modelling the persistence of conditional variances.Econo- metric Reviews5, 1–50.

Francq C. and Sucarrat G. 2013 An exponential chi-squared QMLE for log-GARCH models via the ARMA representation. Working Paper 51783, University of Munich, Munich.

Geweke J. 1986 Modelling the persistence of conditional variances: A comment.Econometric Reviews5, 57–61.

Ghalanos A. 2015armgarch: Multivariate GARCH models.R package version 1.3-0.

Ghalanos A. 2015brugarch: Univariate GARCH models.R package version 1.3-6.

Ghalanos A. and Theussl S. 2015Rsolnp: General Non-linear Optimization Using Augmented Lagrange Multiplier Method. R package version 1.16.

Glosten L., Jagannathan R., and Runkle D. 1993 On the relation between expected value and the volatility of the nominal excess return on stocks.Journal of Finance48, 1779–1801.

Hafner C. and Herwatz H. 2006 A Lagrange multiplier test for causality in variance.Economics Letters93(1), 137–141.

Hansen P., Huang R., and Shek H. 2012 Realized GARCH: a joint model for returns and real- ized measures of volatility.Journal of Applied Econometrics27(6), 877–906.

Higgins M. and Bera A. 1992 A class of nonlinear ARCH models.International Economic Review33, 137–158.

Kleiber C. and Zeileis A. 2008Applied Econometrics with R. Springer-Verlag, New York.

Nakatani T. 2010Four Essays on Building Conditional Correlation GARCH ModelsPhD thesis Stockholm School of Economics.

Nakatani T. 2014ccgarch: An R Package for Modelling Multivariate GARCH Models with Conditional Correlations. R package version 0.2.3.

Nakatani T. and Terọsvirta T. 2009 Testing for volatility interactions in the constant conditional correlation GARCH model.Econometrics Journal12(1), 147–163.

Nakatsuma T. 2000 Bayesian analysis of ARMA-GARCH models: A markov chain sampling approach.Journal of Econometrics95(1), 57–69.

Nelson D. 1991 Conditional heteroscedasticity in asset returns: A new approach.Econometrica 59(2), 347–370.

Pentula S. 1986 Modelling the persistence of conditional variances: A comment.Econometric Reviews5, 71–74.

k k Pfaff B. 2012gogarch: Generalized Orthogonal GARCH (GO-GARCH) models. R package

version 0.7-2.

Schwert G. 1990 Stock volatility and the crash of ’87. Review of Financial Studies 3(1), 77–102.

Stock J. and Watson M. 2007Introduction to Econometrics. Addison Wesley, Boston.

Sucarrat G., Gronneberg S., and Escribano A. 2013 Estimation and inference in univariate and multivariate log-GARCH models when the conditional density is unknown. Working Paper 49344, University of Munich, Munich.

Taylor S. 1986Modeling Financial Time Series. John Wiley, New York.

Trapletti A. and Hornik K. 2016tseries: Time Series Analysis and Computational Finance. R package version 0.10-35.

van der Weide R. 2002 GO-GARCH: A multivariate generalized orthogonal GARCH model.

Journal of Applied Econometrics17(5), 549–564.

Würtz D. and Chalabi Y. 2013fGarch: Rmetrics—Autoregressive Conditional Heteroskedastic Modelling. R package version 3010.82.

Ye Y. 1987Interior Algorithms for Linear, Quadratic, and Linearly Constrained Non-Linear ProgrammingPhD thesis Department of ESS, Stanford University.

Zakoian J. 1994 Threshold heteroscedasticity models. Journal of Economic Dynamics and Control15, 931–955.

k k

9

Modelling dependence

Một phần của tài liệu Financial risk modelling and portfolio optimization with r second edition (Trang 141 - 146)

Tải bản đầy đủ (PDF)

(436 trang)