Estimating GARCH Modeling Using Metropolis-Hastings Method in R ()

Min Wang^{1,2}, Yunshun Wu^{1*}

^{1}School of Mathematical Sciences, Guizhou Normal University, Guiyang, China.

^{2}School of Mathematical Sciences, Xiamen University, Xiamen, China.

**DOI: **10.4236/ojs.2018.86062
PDF
HTML XML
1,021
Downloads
2,356
Views
Citations

This paper mainly talks about a popular approach of volatility of a GARCH-type model in R, while the disturbances are independent and have identical Student-t distribution. It uses the Metropolis-Hastings method to perform the computations and gives the programs in details in R.

Share and Cite:

Wang, M. and Wu, Y. (2018) Estimating GARCH Modeling Using Metropolis-Hastings Method in R. *Open Journal of Statistics*, **8**, 931-938. doi: 10.4236/ojs.2018.86062.

1. Introduction

The R-project is an open statistics programming software. Modelling and forecasting volatility or, in other word, the covariance structure of asset returns, is important. A central property of economic time series, being common to many financial time series, is that their volatility varies over time. Describing the volatility of an asset is a key issue in financial economics. Returns were modelled as independent and identically distributed over time. The most popular class of models for time-varying volatility is represented by GARCH type models [1] . GARCH models are commonly used for describing, estimating and predicting the dynamics of financial returns. Recent surveys of the existing GARCH models literature can be found in Davidson [2] and Rombouts et al. [3] . In contrast to Engle’s [4] ARCH model, a double autoregressive (DAR) model, which is a special case of the ARMA-ARCH models in Weiss [5] and an example of weak ARMA models in Francq and Zakoïan [6] [7] , is also increasingly concerned about researchers. Under the assumption of the disturbance following a normal distribution, Ling [8] considered the structure and the maximum likelihood estimation. In addition, stochastic volatility (SV) models have enjoyed great popularity in analyzing financial data in the last couple of decades [9] .

In this paper, an R package named bayesGARCH [10] was mentioned to contrast with our procedure. This package makes use of the priors based on the work of Nakatsuma [11] , consists of Metropolis-Hastings (MH) algorithm [12] a proper algorithm to sample the posterior distribution.

The remainder of this paper is organized as follows. In Section 2 we describe the GARCH (1, 1)-t process and introduce how to estimate the parameters by using the Metropolis-Hastings method. Through an example, we contrast our model with the bayesGARCH package in Section 3. Section 4 provides the R procedure to execute our model in details. An empirical example is reported in Section 5, and Section 6 concludes this paper.

2. Univariate GARCH-t Model

Let ${Y}_{t}$ denote a asset return. The general structure of an asset return series modeled by a GARCH-type models can be written as Audronė Virbickaitė et al. 2014 [13] :

${Y}_{t}={\mu}_{t}+{a}_{t}={\mu}_{t}+{h}_{t}{\u03f5}_{t}.$

In general $\u03f5$ is a Normal variable. Without loss information, we set ${\mu}_{t}=0$ . To capture the fat tail so prominent a Student-t distribution is used for conditional density. The model is, GARCH-t, is

${Y}_{t}\mathrm{|}{F}_{t-1}\sim {S}_{{t}_{\psi}}\left(\mathrm{0,}{h}_{t}^{2}\right)\mathrm{,}{h}_{t}^{2}={\alpha}_{0}+{\alpha}_{1}{Y}_{t-1}^{2}+\beta {h}_{t-1}^{2}\mathrm{.}$ (1)

where ${S}_{{t}_{\psi}}\left(\mathrm{0,}{h}_{t}^{2}\right)$ is a Student-t distribution with mean 0 and $\psi $ is the degree of freedom parameter. ${h}_{t}$ is the conditional variance given ${F}_{t-1}$ in the GARCH (1, 1) model. ${\alpha}_{0}>0$ , ${\alpha}_{1}\mathrm{,}\beta \ge 0$ are restrictions for positive variance, and $\alpha +\beta <1$ for the covariance stationarity. Then the posterior density function could be:

$f\left({y}_{t}\mathrm{|}{F}_{t-1}\right)=\frac{\Gamma \left[\frac{1}{2}\left(\psi +1\right)\right]}{{\pi}^{\frac{1}{2}}\Gamma \left[\frac{1}{2}\psi \right]}\cdot {\left[\left(\psi -2\right){h}_{t}^{2}\right]}^{-\frac{1}{2}}\cdot {\left[1+\frac{{y}_{t}^{2}}{\left(\psi -2\right){h}_{t}^{2}}\right]}^{-\frac{1}{2}\left(\psi +1\right)}\mathrm{.}$ (2)

It is indicated that the $\u03f5$ obey the Student-t distribution in (1). The following, we will show how we get (2), the density distribution of $\u03f5$ is

$p\left(\u03f5\right)=\frac{\Gamma \left(\frac{\psi +1}{2}\right)}{\sqrt{\psi \cdot \pi}\cdot \Gamma \left(\frac{\psi}{2}\right){\left(1+\frac{{\u03f5}_{t}^{2}}{\psi}\right)}^{\frac{\psi +1}{2}}}$

Through the equation ${Y}_{t}={h}_{t}\cdot {\u03f5}_{t}$ , the distribution of ${Y}_{t}$ is

$P\left({Y}_{t}\le {y}_{t}\right)=P\left({h}_{t}\cdot {\u03f5}_{t}\le {y}_{t}\right)=P\left({\u03f5}_{t}\le {h}_{t}^{-1}{y}_{t}\right)={F}_{{\u03f5}_{t}}\left({h}_{t}^{-1}{y}_{t}\right)$

So the density is

$\begin{array}{c}{p}_{{Y}_{t}}\left({y}_{t}\right)={p}_{{\u03f5}_{t}}\left({h}_{t}^{-1}{y}_{t}\right)\cdot {h}_{t}^{-1}=\frac{\Gamma \left(\frac{\psi +1}{2}\right)}{\sqrt{\psi \cdot \pi}\cdot \Gamma \left(\frac{\psi}{2}\right){\left(1+\frac{{\left({h}_{t}^{-1}{y}_{t}\right)}^{2}}{\psi}\right)}^{\frac{\psi +1}{2}}}\cdot {h}_{t}^{-1}\\ =\frac{\Gamma \left(\frac{\psi +1}{2}\right)}{\sqrt{\pi}\cdot \Gamma \left(\frac{\psi}{2}\right)}\cdot {\psi}^{-\frac{1}{2}}{\left(1+\frac{{h}_{t}^{-2}{y}_{t}^{2}}{\psi}\right)}^{-\frac{\psi +1}{2}}\cdot {h}_{t}^{-1}\end{array}$ (3)

Because, $Var\left({\u03f5}_{t}\right)=\frac{\psi}{\psi -2}$ , to ensure the conditional variance of ${Y}_{t}$ to be ${h}_{t}^{2}$ , we replace “ ${h}_{t}$ ” with “ $\frac{\psi -2}{\psi}\cdot {h}_{t}$ ”, then the (3) changed into (2).

Given a dataset ${Y}_{t}=\left({y}_{1}\mathrm{,}{y}_{2}\mathrm{,}\cdots \mathrm{,}{y}_{T}\right)$ , model parameter $\Gamma =\Gamma \left({\alpha}_{0}\mathrm{,}{\alpha}_{1}\mathrm{,}\beta \mathrm{,}\psi \right)$ and the posterior density is

$p\left(\Gamma \mathrm{|}{Y}_{T}\right)\propto p\left(\Gamma \right)\cdot {\displaystyle \underset{t=1}{\overset{T}{\prod}}}f\left({y}_{t}\mathrm{|}{F}_{t-1}\right)$

According to Jensen [14] , the priors are independent and identically distributed (IID) as N (0, 100) with the following restrictions ${\alpha}_{0}>0$ , ${\alpha}_{1}\ge 0$ , $\beta \ge 0$ to impose identification and $\psi >2$ . Since the variance is non-negative, the positive constraints on coefficients are reasonable. The restriction on the degrees of freedom parameter $\psi $ ensures the conditional variance to be finite and the restrictions on the GARCH parameters ${\alpha}_{0}$ , ${\alpha}_{1}$ and $\beta $ guarantee its positivity. One of the most popular MCMC algorithm used in estimating GARCH model parameters, is the Metropolis-Hastings (MH) method. We emphasize the fact that only positivity constraints are implemented in the MH algorithm; no stationarity conditions are imposed in the simulation procedure. We employ a MH sampler. Given the current value $\Gamma $ of the chain, the proposal ${\Gamma}^{\prime}$ is sampled from

$h\left({\Gamma}^{\prime}\right)\sim (\begin{array}{ll}N\left(\Gamma \mathrm{,}V\right)\hfill & \text{with}\text{\hspace{0.17em}}\text{probability}\text{\hspace{0.17em}}p\hfill \\ N\left(\Gamma \mathrm{,100}V\right)\hfill & \text{with}\text{\hspace{0.17em}}\text{probability}\text{\hspace{0.17em}}1-p\hfill \end{array}$

where V is the inverse Hessian matrix of $\mathrm{log}\left(p\left(\Gamma |{Y}_{T}\right)\right)$ . The accepted probability equal to $\mathrm{min}\left\{\frac{p\left(\text{\hspace{0.17em}}\mathrm{|}{Y}_{T}\right)}{p\left(\text{\hspace{0.17em}}\mathrm{|}{Y}_{T}\right)}\mathrm{,1}\right\}$ , and $p=0.9$ empirically. After the test sample collecting the new ${\left\{{\Gamma}^{\left(i\right)}\right\}}_{i=1}^{N}$ , the predictive density is

$p\left({y}_{t+1}|{Y}_{t}\right)\approx \frac{1}{N}{\displaystyle \underset{i=1}{\overset{N}{\sum}}}\text{\hspace{0.05em}}\text{\hspace{0.05em}}f\left({y}_{t+1}|0,{h}_{t+1}^{\left(i\right)},{\psi}^{\left(i\right)}\right).$

3. The Priors and bayesGARCH Package

In this section, an R package named bayesGARCH was applied to deal with the GRACH model, then we’ll describe the difference of the priors between our model and the package. The package bayesGARCH provides functions for the Bayesian estimation of the parsimonious and effective GARCH (1, 1) model with Student-t innovations. The priors in the bayesGARCH package distributions on ${\alpha}_{0}$ is a bivariate truncated Normal distribution; ${\alpha}_{1}$ is a univariate truncated Normal distribution; $\beta $ is a translated Exponential distribution. The estimation procedure is fully automatic and thus avoids the tedious task of tuning an MCMC sampling algorithm. It is obviously there are some differences set of priors between our model and the package, so we couldn’t cite the package directly. Next, we will show the estimation results to demonstration that the different priors could inference the estimation result.

3.1. Example

We set the initial value of $\Gamma $ is (1, 0.2, 0.4, 5). 800 simulation values are obtained by simulation in R.

$R>T=800$

$R>y=c(rep(0,T))$

$R>y[1]=0.5;h[1]=0.5$

$R>alpha0=1;alpha1=0.2;beta=0.4;psi=5$

$R>for(iin2:T)$

$+\mathrm{\{}$

$+h[i]=alpha0+alpha1\ast y{[i-1]}^{2}+beta\ast h[i-1]$

$+y[i]=rt(1,psi)$

$+y[i]=sqrt(h[i])\ast y[i]$

$+\mathrm{\}}$

Then we use bayesGARCH package to estimate $\Gamma $ , we remain the number of MCMC chains and the length of each MCMC chain to be the default value.

$MCMC<-bayesGARCH(y)$

$smpl<-formSmpl(MCMC,l.bi=50)$

$summary(smpl)$

We receive the estimation of $\Gamma $ is (1.2630, 0.2367, 0.4829, 11.3285). Obviously, there’s a big difference estimation of $\psi $ and the estimation of other parameters is equally unsatisfactory.

3.2. The Priors

The difference sets of the priors see Table 1. The GARCH (1, 1) model with Student-t innovations in package bayesGARCH is written in Geweke [15] .

Table 1. The difference sets of priors.

Note. This table shows the priors set in our model are all independent each other and more typical.

4. Conducting GARCH-t in R

The estimate results in our model

In this section, we design and developed the R program. We will show the whole procedure of how we conduct GARCH-t in R. Our results is (1.0103, 0.1838, 0.4694, 9.2587) is closer to the true value, and we can see the procedure in Figure 1.

The R program

We set the all necessary initial values to be zero, the number of MCMC chain to be 10,000, meanwhile $\Gamma $ is a 10,000 times 4 matrix. We leave out the R programs for these simple settings, giving only the necessary parts of the program.

$R>for(i\mathrm{}in2:N)$

$R>\{$

$R>u=runif(1,0,1)$

$R>gammaA=rnorm(1,gamma[i-1,1],0.1\ast v)\ast (u<=0.9)$

$+rnorm(1,gamma[i-1,1],5\ast v)\ast (u>0.9)$

$R>for(j\mathrm{}in2:T)$

$R>\{$

$R>hh[j]=gamma{A}^{2}+gamma{[i-1,2]}^{2}\ast y{[j-1]}^{2}+gamma{[i-1,3]}^{2}\ast hh[j-1]$

$\begin{array}{l}R>oldhh[j]=gamma{[}^{i}+gamma{[}^{i}\ast y{[}^{j}\\ \text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}+gamma{[}^{i}\ast oldhh[j-1]\end{array}$ $R>prop=dt(y/sqrt(hh),gamma[i-1,4])/sqrt(hh)$

$where\mathrm{}y\mathrm{/}sqrt\mathrm{(}hh\mathrm{)}\sim t\mathrm{(}\psi \mathrm{),}and\mathrm{}dt\mathrm{()}\mathrm{returns\; the\; density\; value\; of\; the\; t\; distribution}\mathrm{.}$

$R>old=dt(y/sqrt(oldhh),gamma[i-1,4])/sqrt(oldhh)$

$R>ratio=sum\mathrm{(}log\mathrm{(}prop\mathrm{)}-log\mathrm{(}old\mathrm{))}$

$R>ratio=exp\mathrm{(}ratio\mathrm{)}$

$R>gamma[i,1]=gamma[i-1,1]+(gammaA-gamma[i-1,1])*(runif(1)<ratio)$

The above procedure could give the estimate value of ${\alpha}_{0}$ , and the estimation of the other rest of the parameters is very like it, we won’t go back to that.

5. Empirical Application

This section will use Metropolis-Hastings method by the actual financial data to fit the model. The using data is the DAX(Ibis) index of German in European stock market, a total of 1860 data. In order to make the data smooth, we need to do some processing to the original data. Let ${x}_{t}$ denote the logarithm and ${y}_{t}$ denote the order difference of ${x}_{t}$ , i.e. ${y}_{t}={x}_{t}-{x}_{t-1}$ , see Figure 2.

Figure 1. MCMC results of GARCH (1, 1)-t.

Figure 2. We can see the data in figures (a) and (b) shows a growing trend, while data in figure (c) is stable through the numeric transform.

We apply the R program in the section 5 to estimate the DAX data, achieve the result of $\Gamma $ is (0.0028, 0.0600, 0.0676, 7.7485). That is, the equation of variance is ${h}_{t}^{2}=0.0028+0.0600\ast {Y}_{t-1}^{2}+0.676\ast {h}_{t-1}^{2}$ . Through compute the Ljung-Box test statistic for examining the null hypothesis of independence in ARCH model, we get the $\chi $ squared 0.0023 with p-value 0.9621. It obvious to show our GARCH (1, 1)-t model is sufficient.

6. Conclusion

In this article, the R program to estimate GARCH-t model has been developed. The parameters’ distribution has been modeled using Gaussian model with the most common setting. The results we achieved in each of our experiments with either simulation study or real data application, are quite encouraging.

Foundation

This research was partially supported by the PhD research startup foundation of Guizhou Normal University (Grant No. GZNUD[2017]27) & Science and Technology Foundation of Guizhou Province (LKS[2013]5 & LKS[2012]11), China. & Teaching Project of Guizhou Normal University in 2016: Contract No. [2016] XJ No. 09.

Conflicts of Interest

The authors declare no conflicts of interest.

[1] |
Bollerslev, T. (1986) Generalized Autoregressive Conditional Heteroscedasticity. Journal of Econometrics, 31, 307-327.
https://doi.org/10.1016/0304-4076(86)90063-1 |

[2] |
Davidson, J. (2012) Moment and Memory Properties of Linear Conditional Heteroscedasticity Models, and a New Model. Journal of Business & Economic Statistics, 22, 16-29. https://doi.org/10.1198/073500103288619359 |

[3] |
Rombouts, J., Stentoft, L. and Violante, F. (2014) The Value of Multivariate Model Sophistication: An Application to Pricing Dow Jones Industrial Average Options. International Journal of Forecasting, 30, 78-98.
https://doi.org/10.1016/j.ijforecast.2013.07.006 |

[4] |
Engle, R.F. (1982) Autoregressive Conditional Heteroscedasticity with Estimates of the Variance of U.K. Inflation. Econometrica, 50, 987-1007.
https://doi.org/10.2307/1912773 |

[5] |
Weiss, A.A. (1986) Asymptotic Theory for ARCH Models: Estimation and Testing. Econometric Theory, 2, 107-131. https://doi.org/10.1017/S0266466600011397 |

[6] |
Francq, C. and Zakoian, J.M. (1998) Estimating Linear Representations of Nonlinear Processes. Journal of Statistical Planning & Inference, 68, 145-165.
https://doi.org/10.1016/S0378-3758(97)00139-0 |

[7] |
Francq, C. and Zakoian, J.M. (2000) Covariance Matrix Estimation for Estimators of Mixing Weak ARMA Models. Comptes Rendus de I Académie des Sciences-Series I—Mathematics, 83, 369-394. https://doi.org/10.1016/S0378-3758(99)00109-3 |

[8] | Ling, S. (2007) A Double AR(p) Model: Structure and Estimation. Statistica Sinica, 17, 161-175. |

[9] |
Jacquier, E., Polson, N.G. and Rossi, P. (2004) Bayesian Analysis of Stochastic Volatility Models with Fat-Tails and Correlated Errors. Journal of Econometrics, 122, 185-212. https://doi.org/10.1016/j.jeconom.2003.09.001 |

[10] |
Ardia, D. (2007) bayesGARCH: Bayesian Estimation of the GARCH(1,1) Model with Student-t Innovations in R.
http://CRAN.R-project.org/package=bayesGARCH |

[11] |
Nakatsuma, T. (1998) A Markov-Chain Sampling Algorithm for GARCH Models. Studies in Nonlinear Dynamics & Econometrics, 3, 107-117.
https://doi.org/10.2202/1558-3708.1043 |

[12] | Chin, S. and Greenberg, E. (1995) Markov Chain Monte Carlo Simulation Methods in Econometrics. Econometrics, 12, 409-431. |

[13] |
Virbickaite, A., Ausín, M.C. and Galeano, P. (2015) A Bayesian Non-Parametric Approach to Asymmetric Dynamic Conditional Correlation Model with Application to Portfolio Selection. Computational Statistics and Data Analysis, 100, 814-829. https://doi.org/10.1016/j.csda.2014.12.005 |

[14] |
Jensen, M.J. and Maheub, J.M. (2013) Bayesian Semiparametric Multivariate GARCH Modeling. Journal of Econometrics, 176, 3-17.
https://doi.org/10.1016/j.jeconom.2013.03.009 |

[15] |
Geweke, J. (1993) Bayesian Treatment of the Independent Student-t Linear Model. Journal of Applied Econometrics, 8, S19-S40.
https://doi.org/10.1002/jae.3950080504 |

Journals Menu

Contact us

+1 323-425-8868 | |

customer@scirp.org | |

+86 18163351462(WhatsApp) | |

1655362766 | |

Paper Publishing WeChat |

Copyright © 2024 by authors and Scientific Research Publishing Inc.

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.