--- title: "Modeling heteroskedasticity: GARCH modeling" author: "Hedibert Freitas Lopes" date: "5/28/2018" output: pdf_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` # Glossary of ARCH models Bollerslev wrote the article *Glossary to ARCH* (2010) which lists several families of ARCH models. You can find a technical report version of the paper here: https://pdfs.semanticscholar.org/ea8e/a53721fbc28efec73e509259b00a9193ba12.pdf. I reproduce here the first paragraph of his paper: > Rob Engle's seminal Nobel Prize winning 1982 Econometrica article on the AutoRegressive > Conditional Heteroskedastic (ARCH) class of models spurred a virtual "arms race" > into the development of new and better procedures for modeling and forecasting timevarying > financial market volatility. Some of the most influential of these early papers > were collected in Engle (1995). Numerous surveys of the burgeoning ARCH literature > also exist; e.g., Andersen and Bollerslev (1998), Andersen, Bollerslev, Christoffersen and > Diebold (2006a), Bauwens, Laurent and Rombouts (2006), Bera and Higgins (1993), > Bollerslev, Chou and Kroner (1992), Bollerslev, Engle and Nelson (1994), Degiannakis > and Xekalaki (2004), Diebold (2004), Diebold and Lopez (1995), Engle (2001, 2004), > Engle and Patton (2001), Pagan (1996), Palm (1996), and Shephard (1996). Moreover, > ARCH models have now become standard textbook material in econometrics and > finance as exemplified by, e.g., Alexander (2001, 2008), Brooks (2002), Campbell, Lo and > MacKinlay (1997), Chan (2002), Christoffersen (2003), Enders (2004), Franses and van > Dijk (2000), Gourieroux and Jasiak (2001), Hamilton (1994), Mills (1993), Poon (2005), > Singleton (2006), Stock and Watson (2007), Tsay (2002), and Taylor (2004). So, why > another survey type chapter? # Installing packages and creating functions ```{r} #install.packages("fGarch") #install.packages("rugarch") library("fGarch") library("rugarch") plot.sigt = function(y,sigt,model){ limy = range(abs(y),-abs(y)) par(mfrow=c(1,1)) plot(abs(y),xlab="Days",ylab="Log-returns (-/+)",main="",type="h",axes=FALSE,ylim=limy) lines(-abs(y),type="h") axis(2);box();axis(1,at=ind,lab=date) lines(sigt,col=2) lines(-sigt,col=2) title(model) } ``` # Using Petrobras data as illustration ```{r fig.width=12,fig.height=6} data = read.table("pbr.txt",header=TRUE) n = nrow(data) attach(data) n = nrow(data) y = diff(log(pbr)) ind = trunc(seq(1,n,length=5)) date = c("Jan/3/05","May/08/08","Sep/12/11","Jan/16/15","May/23/18") par(mfrow=c(1,1)) plot(pbr,xlab="Days",ylab="Prices",axes=FALSE,type="l") axis(2);axis(1,at=ind,lab=date);box() par(mfrow=c(1,1)) plot(y,xlab="Days",ylab="Returns",axes=FALSE,type="l") axis(2);axis(1,at=ind,lab=date);box() ``` # AutoRegressive Conditional Heteroskedastic (ARCH) For all models considered in this set of notes, we assume that $$ y_t = \sigma_t \varepsilon_t $$ where $\varepsilon_t$ are iid $D$ (Gaussian, Student's $t$, GED, etc), and the time-varying variances (or standard deviations) are modeled via one of the members of the large GARCH family of volatility models. The ARCH(1), for example, assumes that $$ \sigma_t^2 = \omega + \alpha_1 \varepsilon_{t-1}^2, $$ with $\varepsilon_0^2$ either estimated or fixed. See Engle (1992). ```{r fig.width=12,fig.height=6} fit.arch = garchFit(~garch(1,0),data=y,trace=F,include.mean=FALSE) fit.arch fit.arch@fit$matcoef plot.sigt(y,fit.arch@sigma.t,"ARCH(1)") ``` # Generalized ARCH (GARCH) The GARCH(1,1) model extends the ARCH(1) model: $$ \sigma_t^2 = \omega + \alpha_1 \varepsilon_{t-1}^2 + \beta_1 \sigma_{t-1}^2. $$ See Bollerslev (1986). ```{r fig.width=12,fig.height=6} fit.garch = garchFit(~garch(1,1),data=y,trace=F,include.mean=F) fit.garch fit.garch@fit$matcoef plot.sigt(y,fit.garch@sigma.t,"GARCH(1,1)") ``` # Taylor-Schwert GARCH (TS-GARCH) The TS-GARCH(1,1) models the time-varying standard deviation: $$ \sigma_t = \omega + \alpha_1 |\varepsilon_{t-1}|+\beta_1 \sigma_{t-1}. $$ See Taylor (1986) and Schwert (1989). ```{r fig.width=12,fig.height=6} fit.tsgarch = garchFit(~garch(1,1),delta=1,data=y,trace=F,include.mean=F) fit.tsgarch fit.tsgarch@fit$matcoef plot.sigt(y,fit.tsgarch@sigma.t,"Taylor-Schwert-GARCH(1,1)") ``` # Threshold GARCH (T-GARCH) The T-GARCH(1,1) also models the time-varying standard deviation: $$ \sigma_t = \omega + \alpha_1 |\varepsilon_{t-1}|+\gamma_1|\varepsilon_{t-1}|I(\varepsilon_{t-1}<0)+\beta_1 \sigma_{t-1}. $$ See Zakoian (1993). ```{r fig.width=12,fig.height=6} fit.tgarch = garchFit(~garch(1,1),delta=1,leverage=T,data=y,trace=F,include.mean=F) fit.tgarch fit.tgarch@fit$matcoef plot.sigt(y,fit.tgarch@sigma.t,"Threshold-GARCH(1,1)") ``` # Glosten-Jaganathan-Runkle GARCH (GJR-GARCH) The GJR-GARCH(1,1) model is similar to the T-GARCH(1,1), but it models time-varying variances instead: $$ \sigma_t^2 = \omega + \alpha_1 \varepsilon_{t-1}^2+\gamma_1\varepsilon_{t-1}^2I(\varepsilon_{t-1}<0)+\beta_1 \sigma_{t-1}^2. $$ See Glosten, Jaganathan and Runkle (1993). ```{r fig.width=12,fig.height=6} fit.gjrgarch = garchFit(~garch(1,1),delta=2,leverage=T,data=y,trace=F,include.mean=F) fit.gjrgarch fit.gjrgarch@fit$matcoef plot.sigt(y,fit.gjrgarch@sigma.t,"GJR-GARCH(1,1)") ``` # Asymmetric Power GARCH (AP-GARCH) The AP-GARCH(1,1) (aka APARCH(1,1)) models $$ \sigma_t^{\delta} = \omega + \alpha_1 (|\varepsilon_{t-1}|-\gamma_1 \varepsilon_{t-1})^{\delta} + \beta_1 \sigma_{t-1}^{\delta}, $$ for $\delta>0$ and $\gamma_1 \in (-1,1)$. Th AP-GARCH model includes several models as special cases. * ARCH - $\delta=2$, $\gamma_1=0$ and $\beta_1=0$ * GARCH - $\delta=2$ and $\gamma_1=0$ * TS-GARCH - $\delta=1$ and $\gamma_1=0$ * T-GARCH - $\delta=1$ and $\gamma_1 \in (0,1)$ * GJR-GARCH - $\delta=2$ and $\gamma_1 \in (0,1)$ See Ding, Granger and Engle (1993). ```{r fig.width=12,fig.height=6} fit.aparch = garchFit(~aparch(1,1),data=y,trace=F,include.mean=F) fit.aparch fit.aparch@fit$matcoef plot.sigt(y,fit.aparch@sigma.t,"Asymmetric-Power-GARCH(1,1)") ``` # Exponential GARCH model The EGARCH(1,1) models $$ \log \sigma_t^2 = \omega + \alpha_1 \varepsilon_{t-1} + \gamma_1 |\varepsilon_{t-1}| + \beta_1 \log \sigma_{t-1}^2. $$ See Nelson (1991). ```{r fig.width=12,fig.height=6} fit=ugarchfit(ugarchspec(mean.model=list(armaOrder=c(0,0),include.mean=TRUE,archm=FALSE,archpow=1,arfima=FALSE,external.regressors=NULL,archex=FALSE),variance.model=list(model="eGARCH",garchOrder=c(1,1),submodel=NULL,external.regressors=NULL, variance.targeting = FALSE)),y) fit egarch.sigma.t = as.vector(sigma(fit)[,1]) plot.sigt(y,egarch.sigma.t,"EGARCH(1,1)") ``` # Non-Gaussian GARCH models The R function garchFit has the "cond.dist" option for the specification of conditional distributions. The alternative erro distributions are "dnorm", "dged", "dstd", "dsnorm", "dsged" and "dsstd". Skewed ones: "dsnorm", "dsged", "dsstd". # GARCH(1,1) with Student-t with degrees of freedom (shape) estimated ```{r fig.width=12,fig.height=6} fit.garch.std = garchFit(~garch(1,1),cond.dist="std",data=y,trace=F,include.mean=F) fit.garch.std fit.garch.std@fit$matcoef plot.sigt(y,fit.garch.std@sigma.t,"GARCH(1,1) with Student-t errors") ``` # GARCH(1,1) with skewed Student-t with degrees of freedom (shape) and skewness estimated ```{r fig.width=12,fig.height=6} fit.garch.sstd = garchFit(~garch(1,1),cond.dist="sstd",data=y,trace=F,include.mean=F) fit.garch.sstd fit.garch.sstd@fit$matcoef plot.sigt(y,fit.garch.sstd@sigma.t,"GARCH(1,1) with skewed Student-t errors") ``` # GARCH(1,1) with Student-t with degrees of freedom (shape) fixed at 3 ```{r fig.width=12,fig.height=6} fit.garch.std3 = garchFit(~garch(1,1),cond.dist="std",shape=3,include.shape=F,data=y,trace=F,include.mean=F) fit.garch.std3 fit.garch.std3@fit$matcoef plot.sigt(y,fit.garch.std3@sigma.t,"GARCH(1,1) with Student-t errosr % df=3") ``` # GARCH(1,1) with Laplace (a GED with shape fixed at 1) ```{r fig.width=12,fig.height=6} fit.garch.ged = garchFit(~garch(1,1),cond.dist="ged",shape=1,include.shape=F,data=y,trace=F,include.mean=F) fit.garch.ged fit.garch.ged@fit$matcoef plot.sigt(y,fit.garch.ged@sigma.t,"GARCH(1,1) with GED errors") ``` # Comparing the estimates of $\sigma_t$ ```{r fig.width=12,fig.height=6} sigma.t = cbind(fit.garch@sigma.t, fit.aparch@sigma.t, fit.tsgarch@sigma.t, fit.tgarch@sigma.t, fit.gjrgarch@sigma.t, egarch.sigma.t, fit.garch.std@sigma.t, fit.garch.std3@sigma.t, fit.garch.sstd@sigma.t, fit.garch.ged@sigma.t) limy=range(sigma.t) par(mfrow=c(1,1)) plot(sigma.t[,1],xlab="Days",ylab="Standard deviation",main="",type="l",ylim=limy,axes=FALSE) axis(2);box();axis(1,at=ind,lab=date) for (i in 2:6) lines(sigma.t[,i],col=i) legend("topright",col=1:6,lty=1, legend=c("GARCH","APARCH","TS-GARCH","T-GARCH","GJR-GARCH","EGARCH")) par(mfrow=c(1,1)) plot(sigma.t[,1],xlab="Days",ylab="Standard deviation",main="",type="l",ylim=limy,axes=FALSE) axis(2);box();axis(1,at=ind,lab=date) lines(sigma.t[,7],col=2) lines(sigma.t[,8],col=3) lines(sigma.t[,9],col=4) lines(sigma.t[,10],col=5) legend("topright",legend=c("GARCH","GARCH t","GARCH t(3)","GARCH st","GARCH GED"),col=1:5,lty=1) ``` # Cited references * Bollerslev (1986) Generalized Autoregressive Conditional Heteroskedasticity. *Journal of Econometrics*, 31, 307-327. * Bollerslev (2010) Glossary to ARCH (GARCH) In *Volatility and Time Series Econometrics: Essays in Honor of Robert F. Engle*. Edited by Bollerslev, Russell and Watson. Chapter 8, pages 137-163. * Ding, Granger and Engle (1993) A Long Memory Property of Stock Market Returns and a New Model. *Journal of Empirical Finance*, 1, 83-106. * Engle (1982) Autoregressive Conditional Heteroskedasticity with Estimates of the Variance of U.K. Inflation. *Econometrica*, 50, 987-1008. * Glosten, Jagannathan and Runkle (1993) On the Relation Between the Expected Value and the Volatility of the Nominal Excess Return on Stocks, *Journal of Finance*, 48, 1779-1801. * Nelson (1991) Conditional Heteroskedasticity in Asset Returns: A New Approach. *Econometrica*, 59, 347-370. * Schwert (1989) Why Does Stock Market Volatility Change Over Time? *Journal of Finance*, 44, 1115-1153. * Taylor (1986) *Modeling Financial Time Series*. Chichester, UK: John Wiley and Sons. * Zakoian (1994) Threshold Heteroskedastic Models. *Journal of Economic Dynamics and Control*, 18, 931-955.