This note presents the R package bayesGARCH which provides functions for the Bayesian estimation of the parsimonious and effective GARCH(1,1) model with Student-
Research on changing volatility using time series models has been active since the pioneer paper by (Engle 1982). From there, ARCH (AutoRegressive Conditional Heteroscedasticity) and GARCH (Generalized ARCH) type models grew rapidly into a rich family of empirical models for volatility forecasting during the 80’s. These models are widespread and essential tools in financial econometrics.
In the
Until recently, GARCH models have mainly been estimated using the classical Maximum Likelihood technique. Several R packages provide functions for their estimation; see, e.g. fGarch (Wuertz and Y. Chalabi 2009), rgarch (Ghalanos 2010) and tseries (Trapletti and K. Hornik 2009). The Bayesian approach offers an attractive alternative which enables small sample results, robust estimation, model discrimination, model combination, and probabilistic statements on (possibly nonlinear) functions of the model parameters.
The package
bayesGARCH
(Ardia 2007) implements the Bayesian estimation procedure described
in Ardia (2008 5) for the GARCH(1,1) model with Student-
A GARCH(1,1) model with Student-
where
In order to write the likelihood function, we define the vectors
The Bayesian approach considers
This posterior is a quantitative, probabilistic description of the knowledge about the model parameters after observing the data. For an excellent introduction on Bayesian econometrics we refer the reader to Koop (2003).
We use truncated normal priors on the GARCH parameters
The prior distribution of vector
The joint prior distribution is then formed by assuming prior
independence between the parameters, i.e.
The recursive nature of the GARCH(1,1) variance equation implies that
the joint posterior and the full conditional densities cannot be
expressed in closed form. There exists no (conjugate) prior that can
remedy this property. Therefore, we cannot use the simple Gibbs sampler
and need to rely on a more elaborated Markov Chain Monte Carlo (MCMC)
simulation strategy to approximate the posterior density. The idea of
MCMC sampling was first introduced by
Metropolis, A. W. Rosenbluth, M. N. Rosenbluth, A. H. Teller, and E. Teller (1953) and was subsequently
generalized by Hastings (1970). The sampling strategy relies on the
construction of a Markov chain with realizations
The MCMC sampler implemented in the package
bayesGARCH is based
on the approach of Ardia (2008 5), inspired from the previous work
by Nakatsuma (1998). The algorithm consists of a MH algorithm where the
GARCH parameters are updated by blocks (one block for
We apply our Bayesian estimation methods to daily observations of the
Deutschmark vs British Pound (DEM/GBP) foreign exchange log-returns. The
sample period is from January 3, 1985, to December 31, 1991, for a total
of
We fit the GARCH(1,1) model with Student-bayesGARCH
function
> args(bayesGARCH)
function (y, mu.alpha = c(0, 0),
Sigma.alpha = 1000 * diag(1,2),
mu.beta = 0, Sigma.beta = 1000,
lambda = 0.01, delta = 2,
control = list())
The input arguments of the function are the vector of data, the
hyperparameters and the list control
which can supply any of the
following elements:
n.chain
: number of MCMC chain(s) to be generated; default 1
.
l.chain
: length of each MCMC chain; default 10000
.
start.val
: vector of starting values of the chain(s); default
c(0.01,0.1,0.7,20)
. Alternatively, the starting values could be
set to the maximum likelihood estimates using the function fGarch
available in the package
fGarch, for instance.
addPriorConditions
: function which allows the user to add any
constraint on the model parameters; default NULL
, i.e. not
additional constraints are imposed.
refresh
: frequency of reports; default 10
.
digits
: number of printed digits in the reports; default 4
.
As a prior distribution for the Bayesian estimation we take the default
values in bayesGARCH
, which are diffuse priors. We generate two chains
for control
parameter values
n.chain = 2
and l.chain = 5000
.
> data(dem2gbp)
> y <- dem2gbp[1:750]
> set.seed(1234)
> MCMC <- bayesGARCH(y, control = list(
l.chain = 5000, n.chain = 2))
chain: 1 iteration: 10
parameters: 0.0441 0.212 0.656 115
chain: 1 iteration: 20
parameters: 0.0346 0.136 0.747 136
...
chain: 2 iteration: 5000
parameters: 0.0288 0.190 0.754 4.67
The function outputs the MCMC chains as an object of the class "mcmc"
from the package coda
(Plummer, N. Best, K. Cowles, and K. Vines 2010). This package contains functions for post-processing the MCMC
output; see Plummer, N. Best, K. Cowles, and K. Vines (2006) for an introduction. Note that
coda is loaded
automatically with
bayesGARCH.
A trace plot of the MCMC chains (i.e. a plot of iterations vs. sampled
values) can be generated using the function traceplot
; the output is
displayed in Figure 2.
Convergence of the sampler (using the diagnostic test of Gelman and D. B. Rubin (1992)), acceptance rates and autocorrelations in the chains can be computed as follows:
> gelman.diag(MCMC)
Point est. 97.5% quantile
alpha0 1.02 1.07
alpha1 1.01 1.05
beta 1.02 1.07
nu 1.02 1.06
Multivariate psrf
1.02
> 1 - rejectionRate(MCMC)
alpha0 alpha1 beta nu
0.890 0.890 0.953 1.000
> autocorr.diag(MCMC)
alpha0 alpha1 beta nu
Lag 0 1.000 1.000 1.000 1.000
Lag 1 0.914 0.872 0.975 0.984
Lag 5 0.786 0.719 0.901 0.925
Lag 10 0.708 0.644 0.816 0.863
Lag 50 0.304 0.299 0.333 0.558
The convergence diagnostic shows no evidence against convergence for the
last gelman.diag
) since the scale reduction factor is smaller
than 1.2; see Gelman and D. B. Rubin (1992) for details. The MCMC sampling algorithm
reaches very high acceptance rates ranging from 89% for vector
The one-lag autocorrelations in the chains range from 0.87 for parameter
formSmpl
,
we discard the first
> smpl <- formSmpl(MCMC, l.bi = 2500,
batch.size = 2)
n.chain : 2
l.chain : 5000
l.bi : 2500
batch.size: 2
smpl size : 2500
Basic posterior statistics can be easily obtained with the summary
method available for mcmc
objects.
> summary(smpl)
Iterations = 1:2500
Thinning interval = 1
Number of chains = 1
Sample size per chain = 2500
1. Empirical mean and standard deviation
for each variable, plus standard error
of the mean:
Mean SD Naive SE Time-series SE
alpha0 0.0345 0.0138 0.000277 0.00173
alpha1 0.2360 0.0647 0.001293 0.00760
beta 0.6832 0.0835 0.001671 0.01156
nu 6.4019 1.5166 0.030333 0.19833
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
alpha0 0.0126 0.024 0.0328 0.0435 0.0646
alpha1 0.1257 0.189 0.2306 0.2764 0.3826
beta 0.5203 0.624 0.6866 0.7459 0.8343
nu 4.2403 5.297 6.1014 7.2282 10.1204
The marginal distributions of the model parameters can be obtained by
first transforming the output into a matrix and then using the function
hist
. Marginal posterior densities are displayed in
Figure 3. We clearly notice the asymmetric shape of the
histograms; this is especially true for parameter
Probabilistic statements on nonlinear functions of the model parameters
can be straightforwardly obtained by simulation from the joint posterior
sample. In particular, we can test the covariance stationarity condition
and estimate the density of the unconditional variance when this
condition is satisfied. Under the GARCH(1,1) specification, the process
is covariance stationary if
To make inference on the persistence of the squared process, we simply
use the posterior sample and generate
Other probabilistic statements on interesting functions of the model
parameters can be obtained using the joint posterior sample. Under
specification (1), the conditional kurtosis is
The control parameter addPriorConditions
can be used to impose any
type of constraints on the model parameters
> addPriorConditions <- function(psi)
+ psi[2] + psi[3] < 1
Finally, we can impose normality of the innovations in a straightforward
manner by setting the hyperparameters bayesGARCH
function.
The estimation strategy implemented in bayesGARCH is fully automatic and does not require any tuning of the MCMC sampler. This is certainly an appealing feature for practitioners. The generation of the Markov chains is however time consuming and estimating the model over several datasets on a daily basis can therefore take a significant amount of time. In this case, the algorithm can be easily parallelized, by running a single chain on several processors. This can be easily achieved with the package foreach (REvolution Computing 2009), for instance. Also, when the estimation is repeated over updated time series (i.e. time series with more recent observations), it is wise to start the algorithm using the posterior mean or median of the parameters obtained at the previous estimation step. The impact of the starting values (burn-in phase) is likely to be smaller and thus the convergence faster.
Finally, note that as any MH algorithm, the sampler can get stuck at a
given value, so that the chain does not move anymore. However, the
sampler uses Taylor-made candidate densities that are especially
constructed at each step, so it is almost impossible for this MCMC
sampler to get stuck at a given value for many subsequent draws. For
example, for our data set we still obtain posterior results that are
almost equal to the results that we obtained for the reasonable default
initial values c(0.01,0.1,0.7,20)
, even if we take the very poor
initial values c(0.1,0.01,0.4,50)
. In the unlikely case that such ill
behaviour does occur, one could scale the data (to have standard
deviation 1), or run the algorithm with different initial values or a
different random seed.
This note presented the Bayesian estimation of the GARCH(1,1) model with
Student-
The authors acknowledge two anonymous reviewers and the associate editor, Martyn Plummer, for helpful comments that have led to improvements of this note. David Ardia is grateful to the Swiss National Science Foundation (under grant #FN PB FR1-121441) for financial support. Any remaining errors or shortcomings are the authors’ responsibility.
bayesGARCH, fGarch, rgarch, tseries, coda, foreach
Bayesian, Econometrics, Environmetrics, Finance, GraphicalModels, HighPerformanceComputing, TimeSeries
This article is converted from a Legacy LaTeX article using the texor package. The pdf version is the official version. To report a problem with the html, refer to CONTRIBUTE on the R Journal homepage.
Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".
For attribution, please cite this work as
Ardia & Hoogerheide, "Bayesian Estimation of the GARCH(1,1) Model with Student-t Innovations", The R Journal, 2010
BibTeX citation
@article{RJ-2010-014, author = {Ardia, David and Hoogerheide, Lennart F.}, title = {Bayesian Estimation of the GARCH(1,1) Model with Student-t Innovations}, journal = {The R Journal}, year = {2010}, note = {https://rjournal.github.io/}, volume = {2}, issue = {2}, issn = {2073-4859}, pages = {41-47} }