^{1}

^{2}

^{*}

This paper mainly talk s 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.

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 [

In this paper, an R package named bayesGARCH [

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.

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 [

Y t = μ t + a t = μ t + h t ϵ t .

In general ϵ is a Normal variable. Without loss information, we set μ 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 | F t − 1 ∼ S t ψ ( 0, h t 2 ) , h t 2 = α 0 + α 1 Y t − 1 2 + β h t − 1 2 . (1)

where S t ψ ( 0, h t 2 ) is a Student-t distribution with mean 0 and ψ is the degree of freedom parameter. h t is the conditional variance given F t − 1 in the GARCH (1, 1) model. α 0 > 0 , α 1 , β ≥ 0 are restrictions for positive variance, and α + β < 1 for the covariance stationarity. Then the posterior density function could be:

f ( y t | F t − 1 ) = Γ [ 1 2 ( ψ + 1 ) ] π 1 2 Γ [ 1 2 ψ ] ⋅ [ ( ψ − 2 ) h t 2 ] − 1 2 ⋅ [ 1 + y t 2 ( ψ − 2 ) h t 2 ] − 1 2 ( ψ + 1 ) . (2)

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

p ( ϵ ) = Γ ( ψ + 1 2 ) ψ ⋅ π ⋅ Γ ( ψ 2 ) ( 1 + ϵ t 2 ψ ) ψ + 1 2

Through the equation Y t = h t ⋅ ϵ t , the distribution of Y t is

P ( Y t ≤ y t ) = P ( h t ⋅ ϵ t ≤ y t ) = P ( ϵ t ≤ h t − 1 y t ) = F ϵ t ( h t − 1 y t )

So the density is

p Y t ( y t ) = p ϵ t ( h t − 1 y t ) ⋅ h t − 1 = Γ ( ψ + 1 2 ) ψ ⋅ π ⋅ Γ ( ψ 2 ) ( 1 + ( h t − 1 y t ) 2 ψ ) ψ + 1 2 ⋅ h t − 1 = Γ ( ψ + 1 2 ) π ⋅ Γ ( ψ 2 ) ⋅ ψ − 1 2 ( 1 + h t − 2 y t 2 ψ ) − ψ + 1 2 ⋅ h t − 1 (3)

Because, V a r ( ϵ t ) = ψ ψ − 2 , to ensure the conditional variance of Y t to be h t 2 , we replace “ h t ” with “ ψ − 2 ψ ⋅ h t ”, then the (3) changed into (2).

Given a dataset Y t = ( y 1 , y 2 , ⋯ , y T ) , model parameter Γ = Γ ( α 0 , α 1 , β , ψ ) and the posterior density is

p ( Γ | Y T ) ∝ p ( Γ ) ⋅ ∏ t = 1 T f ( y t | F t − 1 )

According to Jensen [

h ( Γ ′ ) ∼ ( N ( Γ , V ) with probability p N ( Γ ,100 V ) with probability 1 − p

where V is the inverse Hessian matrix of log ( p ( Γ | Y T ) ) . The accepted probability equal to min { p ( | Y T ) p ( | Y T ) ,1 } , and p = 0.9 empirically. After the test sample collecting the new { Γ ( i ) } i = 1 N , the predictive density is

p ( y t + 1 | Y t ) ≈ 1 N ∑ i = 1 N f ( y t + 1 | 0 , h t + 1 ( i ) , ψ ( i ) ) .

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 α 0 is a bivariate truncated Normal distribution; α 1 is a univariate truncated Normal distribution; β 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.

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

R > T = 800

R > y = c ( r e p ( 0 , T ) )

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

R > a l p h a 0 = 1 ; a l p h a 1 = 0.2 ; b e t a = 0.4 ; p s i = 5

R > f o r ( i i n 2 : T )

+ {

+ h [ i ] = a l p h a 0 + a l p h a 1 ∗ y [ i − 1 ] 2 + b e t a ∗ h [ i − 1 ]

+ y [ i ] = r t ( 1 , p s i )

+ y [ i ] = s q r t ( h [ i ] ) ∗ y [ i ]

+ }

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

M C M C < − b a y e s G A R C H (y)

s m p l < − f o r m S m p l ( M C M C , l . b i = 50 )

s u m m a r y ( s m p l )

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

The difference sets of the priors see

our GARCH-t | bayesGARCH package | |
---|---|---|

α 0 | N (0, 100) | a bivariate truncated Normal distribution |

α 1 | N (0, 100) | a bivariate truncated Normal distribution |

β | N (0, 100) | a univariate truncated Normal distribution |

ψ | U (2, 100) | a translated Exponential distribution |

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

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

The R program

We set the all necessary initial values to be zero, the number of MCMC chain to be 10,000, meanwhile Γ 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 > f o r ( i i n 2 : N )

R > {

R > u = r u n i f ( 1 , 0 , 1 )

R > g a m m a A = r n o r m ( 1 , g a m m a [ i − 1 , 1 ] , 0.1 ∗ v ) ∗ ( u < = 0.9 )

+ r n o r m ( 1 , g a m m a [ i − 1 , 1 ] , 5 ∗ v ) ∗ ( u > 0.9 )

R > f o r ( j i n 2 : T )

R > {

R > h h [ j ] = g a m m a A 2 + g a m m a [ i − 1 , 2 ] 2 ∗ y [ j − 1 ] 2 + g a m m a [ i − 1 , 3 ] 2 ∗ h h [ j − 1 ]

R > o l d h h [ j ] = g a m m a [ i − 1 , 1 ] 2 + g a m m a [ i − 1 , 2 ] 2 ∗ y [ j − 1 ] 2 + g a m m a [ i − 1 , 3 ] 2 ∗ o l d h h [ j − 1 ] R > p r o p = d t ( y / s q r t ( h h ) , g a m m a [ i − 1 , 4 ] ) / s q r t ( h h )

w h e r e y / s q r t ( h h ) ∼ t ( ψ ) , a n d d t ( ) returns the density value of the t distribution .

R > o l d = d t ( y / s q r t ( o l d h h ) , g a m m a [ i − 1 , 4 ] ) / s q r t ( o l d h h )

R > r a t i o = s u m ( l o g ( p r o p ) − l o g ( o l d ) )

R > r a t i o = e x p ( r a t i o )

R > g a m m a [ i , 1 ] = g a m m a [ i − 1 , 1 ] + ( g a m m a A − g a m m a [ i − 1 , 1 ] ) * ( r u n i f ( 1 ) < r a t i o )

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

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

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

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.

This research was partially supported by the PhD research startup foundation of Guizhou Normal University (Grant No. GZNUD[

The authors declare no conflicts of interest regarding the publication of this paper.

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