Bayesian GARCH Estimation and Expectile Backtesting

61
Master’s Thesis Bayesian GARCH Estimation and Expectile Backtesting An Investigation of Recent Developments in Financial Risk Management P.I. Zeinstra Student number: 10867848 Date of final version: February 28, 2016 Master’s programme: Econometrics Specialisation: Econometrics Supervisors: dr. S. A. Broda (UvA) P. M. M. H. J. M. Verstappen, MSc CFA (EY) Second reader: prof. dr. H. P. Boswijk (UvA) Faculty of Economics and Business

Transcript of Bayesian GARCH Estimation and Expectile Backtesting

Page 1: Bayesian GARCH Estimation and Expectile Backtesting

Master’s Thesis

Bayesian GARCH Estimation and Expectile

Backtesting

An Investigation of Recent Developments in

Financial Risk Management

P.I. Zeinstra

Student number: 10867848

Date of final version: February 28, 2016

Master’s programme: Econometrics

Specialisation: Econometrics

Supervisors: dr. S. A. Broda (UvA)

P. M. M. H. J. M. Verstappen, MSc CFA (EY)

Second reader: prof. dr. H. P. Boswijk (UvA)

Faculty of Economics and Business

Page 2: Bayesian GARCH Estimation and Expectile Backtesting

i

Declaration of Authorship

I, Paulus Zeinstra, declare that this thesis titled, and the work presented in it are my own. I

confirm that:

- This work was done wholly while in candidature for a master degree of Econometrics at

the University of Amsterdam.

- Where I have quoted from the work of others, the source is always given. With the

exception of such quotations, this thesis is entirely my own work.

- I have acknowledged all main sources of help.

Signed:

Date:

February 28, 2016

Page 3: Bayesian GARCH Estimation and Expectile Backtesting

ii

Abstract

In this research we have investigated recent developments in financial risk modelling: Bayesian

estimation of GARCH(1,1) models and the use of the Expectile. We applied the GARCH(1,1)

model with normal innovations to a Monte Carlo DGP and market data from two stock indices.

We found that Bayesian GARCH(1,1) estimation performs relatively poorly for the Monte

Carlo DGP in comparison with the MLE. Furthermore, we find that there is barely a difference

between both estimation processes and that the choice of innovation process is of sufficiently

higher importance for market data. The second part of our research consists of investigating

the backtestability of the Expectile. We developed two backtests for the Expectile: one based

on the first order condition of its scoring function and one based on the asymptotics of the

asymmetric least squares estimate. By a Monte Carlo study we found that both tests perform

comparable to Kupiec’s [1995] test in terms of rejection frequencies. Also no evidence against

the empirical use of the Expectile and its backtest can be found. Combining the theoretical

properties with its backtestability leads us to conclude that the Expectile might be an attractive

risk measure to be used in practice.

Page 4: Bayesian GARCH Estimation and Expectile Backtesting

Contents

1 Introduction 1

1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2 Risk measures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.3 Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Methodology 6

2.1 GARCH models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.2 Inference methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2.1 Frequentist method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2.2 Bayesian method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.3 Risk measures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.4 Backtests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.4.1 Kupiec’s backtest (VaR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.4.2 ES backtests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.4.3 Expectile backtests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.5 Bootstrapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.5.1 Resampling method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.5.2 Moving Block Bootstrap . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

3 Monte Carlo study 23

3.1 Monte Carlo DGP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

3.2 Inference Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

3.2.1 Point estimates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.2.2 Sample length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3.2.3 Innovations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

3.3 Backtests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

3.3.1 Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

3.3.2 Deviations from the unconditional VaR/Expectile . . . . . . . . . . . . . 30

4 Empirical study 34

4.1 Market data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

4.1.1 S&P 500 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

iii

Page 5: Bayesian GARCH Estimation and Expectile Backtesting

CONTENTS iv

4.1.2 Nikkei 225 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

4.2 Inference methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

4.2.1 S&P 500 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

4.2.2 Nikkei 225 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

4.3 Backtests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

4.3.1 S&P 500 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

4.3.2 Nikkei 225 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

5 Conclusion 40

6 Appendix 44

6.1 A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

6.1.1 Data plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

6.1.2 DGP output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

6.1.3 Empirical Analysis output . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

6.2 B. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

6.2.1 Matlab code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

6.2.2 R code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

Page 6: Bayesian GARCH Estimation and Expectile Backtesting

Chapter 1

Introduction

Since Engle (1982) and Bollerslev (1986) published their articles on volatility models, time series

analysis has changed substantially - only the number of their citations (more than 18,000 each)

reveals their influence. From this point forward, a multitude of adaptions to their (generalized)

autoregressive conditional heteroskedasticity (GARCH) model have been introduced. The main

advantage of these models is that they allow for volatility clustering, i.e. periods of low volatility

alternate with more agitated periods.

Popularity grew as GARCH models were perfectly suitable for applications in finance (e.g.

in risk and asset management) because volatility on financial markets tends to cluster as well.

In fact, J.P. Morgan developed the software RiskMetricsTM which is in essence a modification

to the GARCH model. These models became even more interesting as they were extended to

the multivariate setting (MGARCH models) because they allowed for correlations. This created

enthusiasm among practitioners in finance once more. Namely, considering correlations between

assets is important when diversifying a portfolio or calculating capital charges.

A more recent movement in the field of statistics is Bayesian inference. The rise in popularity

is predominantly due to the increase in machines’ computation power. One of the advantages

of Bayesian inference with respect to frequentist (or classical) inference is that information can

be added a priori, leading to potentially improved estimates. Of course, the appropriateness of

introducing subjectivity to statistical analysis is debatable.

A still ongoing debate between practitioners is the one regarding which risk measure to use.

Even though the theoretical properties of the Value at Risk (VaR) seem to be inferior to those

of the Expected Shortfall (ES), practitioners are dissatisfied with the increase of complexity

that comes with the ES, especially regarding backtestability. Recently, another risk measure

has joined the debate: the Expectile.

The question we ask ourselves here is how these recent movements (Bayesian inference and

1

Page 7: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 1. INTRODUCTION 2

the Expectile) can contribute to market risk modelling? This question may easily be split up

into two parts by answering the question first for Bayesian inference followed by answering it

for the Expectile. Since we consider market risk (risk that arises from movements in market

prices), we will answer our questions using GARCH models.

Using a Monte Carlo DGP and market data, we evaluate both frequentist and Bayesian in-

ference methods. Frequentist inference and more precisely MLE will serve as a benchmark for

Bayesian inference, as it is widely applied in literature. We will compare both methods using a

Monte Carlo simulation and base conclusions on statistical measures such as biases, standard

deviations, and RMSE.

Besides theoretical properties, backtestability of a risk measure is of extreme importance to

determine whether a capital charge for a certain risk is prudent or not. Therefore, in this

research emphasis will lie on the backtestability of the Expectile and we question ourselves

whether we can come up with a backtest for the Expectile. To evaluate the size and power of

the test we use rejection frequencies, obtained by a Monte Carlo simulation as well. We use

the backtest proposed by Kupiec (1995) as a benchmark because of its intuitiveness and wide

application.

In the following sections we will discuss literature regarding risk measures and GARCH models.

It will begin with explaining why these notions are important in practice by providing some

background. The second chapter contains detailed methodology on inference methods and risk

measures. With regard to inference, emphasis lies on the Bayesian method, not only because it

is the inference method that we investigate but also because it is the most difficult method. Sec-

ondly, we will elaborate on the risk measures’ backtests. Chapter 3 introduces the Monte Carlo

DGP and summarizes the results regarding this dataset. Chapter 4 involves the application to

market data. Typical for both Chapter 3 and 4 is the division between GARCH estimation and

backtesting. Chapter 5 provides the conclusions of our research.

1.1 Background

In 1973, the collapse of the Bretton-Woods1 system caused massive currency losses for many

banks. As a response, the central bank governors of the G10 countries established what we

nowadays know as the Basel Committee on Banking Supervision (BCBS). BCBS’s mandate

is ”to strengthen the regulation, supervision and practices of banks worldwide with the pur-

pose of enhancing financial stability”. It does so by publishing a set of minimum regulatory

capital requirements for banks, which will be (partly) enforced by law. Examples of these are

Basel I (published in 1988, enforced by law in 1992) and Basel II (published in 2004, enforced

1The Bretton-Woods system was a monetary policy agreement between 44 countries made in July 1944. Themain feature of the agreement was to keep exchange rates fixed.

Page 8: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 1. INTRODUCTION 3

by law in 2008). The latest regulation on capital requirements for European Union members

is bundled in the Capital Requirements Regulation and Directive (CRR/CRD-IV) and is the

first step in implementing Basel III. Between now and 2019, more provisions will be phased-in

such that Basel III is fully live in 2019. In the meantime BCBS publishes other (consultative)

documents such as the Fundamental Review of the Trading Book (FRTB) and the Review of

the Credit Valuation Adjustment Risk Framework. To some extent, this can be seen as Basel IV.

Basel I primarily focused on credit risk (the risk of an obligor not being able to meet con-

tractual agreements). According to Basel I, risks should be mapped to risk weighted assets

(RWA) - a risk adjusted measure for off-balance exposure. Then, banks should hold a capital

ratio level of at least 8%, that is, the capital held in reserve divided by the RWA. Basel II was

designed to improve regulatory capital requirements, to incorporate not yet included risks (such

as market and operational risk) and to respond to the recent financial modernization. Among

other things, it introduced the notion of VaR, a measure to adequately address risk.

1.2 Risk measures

Mathematically speaking, a risk measure for a random variable X is a functional, mapping

the c.d.f. of X to a real number. In the nineties, VaR was a risk measure widely accepted by

practitioners in financial risk management. However, in 1999, Artzner et al. raised concerns

about the use of VaR. The reason for this was that the measure was not ’coherent’; it lacked

the property of subadditivity. More criticism came from Yamai and Yoshiba (2002), showing

that VaR lacks prudence in case of market stress. Under extreme price fluctuations or extreme

dependence structure between assets, VaR may underestimate risk. At that time, practioners

- mainly risk managers - also raised their concerns. Namely, VaR does not take the largest

risks into account because it does not look beyond the specified quantile. In 2005, Campbell re-

viewed backtests for the VaR. Campbell distinguishes between conditional, independence, joint

and realized loss backtests. Results suggested that gains in statistical power could be achieved

if other quantiles would have been taken into account. This finding is intuitive as the VaR does

not tell us anything about the rest of the distribution.

Because of the growing aversion towards the use of VaR, other - coherent - risk measures were

proposed in literature, of which the ES has received the most attention. Numerous articles on

ES (and its comparison with VaR) were published, all favouring the use ES over VaR (see e.g.

Acerbi et al. (2001), Yamai and Yoshiba (2005), Dardac et al. (2011) and Ardia and Hooger-

heide (2014)). Consequently, BCBS proposed to replace the VaR by the ES in the FRTB: ”A

number of weaknesses have been identified with using VaR for determining regulatory capital

requirements, including its inability to capture ”tail risk”. For this reason, the Committee pro-

posed in May 2012 to replace VaR with ES.”. A disadvantage of ES was recognized by Kondor

et al. (2015). Their central message is that:”nobody should be using Expected Shortfall for the

Page 9: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 1. INTRODUCTION 4

purpose of portfolio optimization”, the reason being that exceedingly large samples are needed

to obtain an acceptable estimation error.

Another risk measure that gained more attention recently is the Expectile. The advantage

of the Expectile over the ES is that it is elicitable, making it more suitable for backtesting.

Literature on Expectiles let alone on backtesting Expectiles, is scarce. Yet, Emmer et al. (2013)

conclude that ES seems to be the best for use in practice. In Section 2.3 we will elaborate on

the theoretical details of the risk measures.

1.3 Models

To calculate risk measures, most banks apply a historical simulation due to its intuitiveness,

simplicity and computational ease. This non-parametric method is simply a simulation in which

a distribution is drawn from k ∈ N+ past observations with replacement. As one may suspect,

it relies on the assumption that the distribution of future values is equal to the historical dis-

tribution. Others use RiskMetricsTM which basically consists of an integrated-GARCH model.

Another option would be to apply Extreme Value Theory (EVT). Even though these models

yield reasonable results, the most applied in empirical research are GARCH models (see e.g.

Marshall et al. (2009) and Zhu and Galbraith (2011)). A brief review of the univariate GARCH

model family is given by Xu et al. (2011). Li et al. (2011) compare nine estimation methods by

applying three different GARCH models under three different innovations to the CSI 300 index.

The three possible innovations are the normal distribution, t-distrution and GED. The models

they investigate are the GARCH, exponential-GARCH (EGARCH) and GJR-GARCH (named

after Glosten et al. (1993)). They find that the VaR rejection frequency of the EGARCH and

GJR-GARCH with GED innovations is closest to the chosen confidence level. From this they

conclude these models are most precise.

Back in 1996, Nakatsuma and Tsurumi compared Bayesian estimates with Maximum Likeli-

hood estimates (MLE) for ARMA-GARCH models. Based on the Mean Squared Error (MSE)

they found that the Bayesian points estimates outperform MLE for small samples. Hoogerheide

et al. (2012) compared frequentist and Bayesian estimation methods with respect to their den-

sity forecasts using GARCH models. They found no significant difference between the quality of

whole density forecasts, however, they did find that the Bayesian method leads to significantly

better left tail-forecast accuracy. Moreover they concluded that Bayesian estimation methods

should be preferred in risk management applications, because of their superior predictive ac-

curacy in the left tail. Aussenegg and Miazhynskaia (2006) find another rationale to prefer

Bayesian approach over traditional techniques for estimating GARCH models. They conclude

mentioning that the Bayesian approach involves less uncertainty in VaR estimates compared to

other methods. However, considering at backtests they do not find any significant difference.

Stegmueller (2013) compared the Bayesian and frequentist approach for multilevel models. He

Page 10: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 1. INTRODUCTION 5

argued that Bayesian estimates show far better properties. For instance, the magnitude in bias

is much smaller for Bayesian estimates than for ML estimates.

Page 11: Bayesian GARCH Estimation and Expectile Backtesting

Chapter 2

Methodology

In this chapter we will setup our framework. In the first section we introduce the GARCH

model, the two inference methods and how to estimate the GARCH model. We then continue

by reviewing risk measures, backtesting and conclude by bootstrap methods. First, we start off

by explaining the very basics of time series analysis and the notion of returns.

2.1 GARCH models

If a price of a stock at time t is defined as Pt, then the one-period simple return is defined as:

Rt =Pt − Pt−1

Pt−1.

The continuous compounded return or log-return equals:

rt = log(1 +Rt) = logPt − logPt−1.

Then, by first order Taylor approximation we have that for small Rt, Rt ≈ rt. Therefore, we

may use the words return and log-return interchangeably. Now, we let {rt}Tt=1 be a return

process and Ft = {rt,Ft−1} be the filtration. A filtration is a set that contains all information

up to time t. At t = 1, the filtration does not contain any information. If we then define

at = rt − E[rt|Ft−1] and ht = Var[rt|Ft−1], the ARCH(m) model is given by:

at =√htεt,

ht = α0 +m∑i=1

αia2t−i,

εt ∼ i.i.d. (0, 1) .

6

Page 12: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 7

with α0 > 0 and αi ≥ 0. In 1986, Bollerslev proposed the GARCH(m,s) model, where the latter

equation extended to:

ht = α0 +m∑i=1

αia2t−i +

s∑j=1

βjht−j .

An extension to this model is the GJR-GARCH (also known as threshold GARCH). The model,

extended by the parameter(s) δi, is given below:

ht = α0 +

m∑i=1

(αi + δiI{at−i<0}

)a2t−i +

s∑j=1

βjht−j .

In empirical studies, it is commonly found that when modelling a financial time series with a

GJR-GARCH(1,1), δ1 > 0. This phenomenom is called the leverage effect: A negative return

causes a decrease in equity, hence an increase in leverage ratio1 and thus a larger return on

equity. The GJR-GARCH model is therefore more realistic than the GARCH model, where

negative shocks are equivalent to postive shocks. Other models that incorporate asymmetry are

the EGARCH and asymmetric power ARCH (APARCH). These models however, do provide

results comparable to the GARCH model (see Rodrıguez and Ruiz (2012)) and therefore will

not be investigated for the sake of computational ease. The multivariate (asymmetric) GJR-

DCC-GARCH model is the standard workhorse in the multivariate setting and is given below:

Ht = DtPtDt,

Dt = diag(√hi,t),

Pt = {diag Qt}−12 Qt {diag Qt}−

12 ,

Qt = Qt(1− θ1 − θ2) + θ1εt−1ε′t−1 + θ2Qt−1 + θ3(vt−1v

′t−1 − N),

εt = D−1t at.

Where vt = max(0,−εt) and N = Var(vt). As one may notice, it allows for dynamic correlations.

Because of computational complexity though, we will not investigate the multivariate case.

2.2 Inference methods

Whilst frequentist inference being mainstream for decades, the field of Bayesian inference is

upcoming. In the following two sections we will describe estimation techniques for both inference

methods.

2.2.1 Frequentist method

In the frequentists framework, there are two estimation methods for GARCH models: Gen-

eralized Method of Momoments (GMM) and (Quasi-) Maximum Likelihood ((Q)ML). An il-

1Leverage ratio = Total debtTotal equity

Page 13: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 8

lustration of GMM estimation for an ARCH model is given by Mark (1988), who estimates a

model of forward foreign exchange rates based on the CAPM equations. However, frequently

GARCH models are estimated by (Q)ML and therefore we will consider this frequentist esti-

mation method only.

If we let γ be the vector of AR parameters and φ the vector of GARCH parameters, the

AR-GARCH process is written as below:

rt = µt(γ) +√ht(γ,φ)εt.

Then, we assume that rt is i.i.d. and follows a normal conditional density f(·), leading to the

following likelihood:

L(γ,φ | rt) =

T∏t=m+1

f(rt|Ft−1,γ,φ),

∝T∑

t=m+1

log f(rt|Ft−1,γ,φ),

=T∑

t=m+1

`t(γ,φ),

∝T∑

t=m+1

−1

2log ht(γ,φ)− 1

2

(rt − µ(γ))2

ht(γ,φ).

The parameters (γMLE , φMLE) which maximize the latter function are the ML estimates. The

function can be optimized by numerically solving the first order conditions. Note however, that

we need m = max(p, q,m, s) initial values for at and ht as they are unobserved. Therefore, a

typical assumption is:

at = 0, ht =1

T −m

T∑t=m+1

(rt − µt(γ))2, t = 1, . . . ,m.

To estimate the variance-covariance matrix, define (with ψ = (γ,φ)):

A = −T∑

t=m+1

∂2`t(ψ)

∂ψ∂ψ′and B = −

T∑t=m+1

∂`t(ψ)

∂ψ

∂`t(ψ)

∂ψ′.

If the information equality holds (that is in this case, the error term is indeed normally dis-

tributed), then the variance can be consistently estimated by either A−1, B−1 or A−1BA−1.

However, if one opines that errors follow a t-distribution instead of a normal distribution -

which is very plausible for financial time series - one can still apply QML, by using Bollerslev-

Wooldridge standard errors.

Page 14: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 9

2.2.2 Bayesian method

The concept of Bayesian statistics

The difference between the frequentist and the Bayesian approach stems from the underlying

assumption on the parameter, say θ = (θ1, . . . , θd), which lies in a parameter space Θ ⊆ Rd.Frequentists assume that there exists a fixed and true θ. Contrarily, Bayesians assume θ is a

random variable with a prior density p(θ). The prior density represents the information about

θ known by the researcher in advance (which is not necessarily informative). If we define the

likelihood function L(θ|rt) = p(rt|θ), then by Bayes’ rule we have:

p(θ|rt) =p(rt|θ)p(θ)p(rt)

=L(θ|rt)p(θ)∫

Θ p(θ|rt)p(θ)dθ,

where the denominator is simply a normalization. The posterior density p(θ|rt) describes the

distribution of θ after combining the researcher’s belief of the distribution of θ with the likelihood

of θ, given the data. The following figure depicts this relationship:

-8 -6 -4 -2 0 2 4 6 8

0

50

100

150

200

250

300

350

400

Posterior

Likelihood

Prior

Figure 2.1: From prior and likelihood to posterior

Note, that if we would set a flat prior p(θ) ∝ 1, we would have

P (θ|rt) ∝ L(θ|rt).

Hence, when maximizing the Bayesian posterior we would obtain a result equivalent to the

one in the frequentist method. Also, under certain specifications of the prior distribution, the

Bernstein-Von Mises theorem implies that both inference methods estimates converge asymp-

totically to the same distribution.

An often convenient choice is to choose a prior that is conjugate to the likelihood such that the

posterior can be determined analytically. However, a conjugate prior not necessarily represents

Page 15: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 10

the prior state. In these cases, one can find a solution by Monte Carlo methods.

The most popular Markov Chain Monte Carlo (MCMC) methods are the Gibbs sampler and

the Metropolis-Hastings (MH) algorithm. Which MCMC algorithm to use depends on whether

the full conditional density p(θi|θ 6=i, rt) is known or not, with θ 6=i = (θ1, . . . , θi−1, θi+1, . . . , θd).

If it is known, the Gibbs sampler can be applied and if not, one should apply the MH algorithm.

For the GARCH model parameters the full conditionals are unknown (due to the recursiveness

of ht) and thus the MH algorithm should be applied. For an extensive discussion on MCMC

strategies, we refer to Tierney (1994).

Bayesian estimation of GARCH(1,1) with normal innovations

To the author’s knowledge, the first one who demonstrates Bayesian inference applied to a

GARCH-type model is Geweke (1989). The Bayesian estimation method of the univariate

GARCH model has been extensively discussed by Ardia (2008) and therefore we have based the

methodology on Ardia’s formulation. Let us redefine the model as follows:

rt = x′tγ + at,

at =√htεt,

ht = α0 + α1a2t−1 + βht−1,

εt ∼ N (0, 1).

with αi > 0 and β > 0 such that ht > 0 and xt is a m × 1 vector of exogenous or lagged

dependent variables. Let us regroup the model parameters as ψ = (γ,φ) = (γ,α, β) and define

Σ = diag(ht(ψ)Tt=1) such that the likelihood function equals:

L(ψ | r,X) ∝ |det Σ|−12 exp

[−1

2a′Σ−1a

]. (2.1)

In addition, the following priors are proposed:

p(γ) = Nm(γ | µγ ,Σγ),

p(α) = N2(α| µα,Σα)I{α>0},

p(β) = N (β | µβ,Σβ)I{β>0}.

where µ• and Σ• are hyperparameters and Nd is the d-dimensional normal density. For the sake

of convenience we assume prior independence such that:

p(ψ) = p(γ)p(α)p(β).

Page 16: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 11

Then, according to Bayes’ law:

p(ψ | r, X) ∝ L(ψ | r,X)p(ψ).

For the MH algorithm we need initial values ψ[0] = (γ[0],α[0], β[0]) such that we can iterate J

passes. A single pass looks as follows:

γ[j] ∼ p(γ | α[j−1], β[j−1], r,X),

α[j] ∼ p(α | γ[j], β[j−1], r,X),

β[j] ∼ p(β | γ[j],α[j], r,X).

Since none of these full conditional densities is known analytically, we draw the parameters from

proposal densities. The proposal density for γ is obtained by combining the likelihood in (2.1)

and the prior density by the Bayesian update:

qγ(γ | γ,α, β, r, X) = Nm(γ | µγ , Σγ), (2.2)

with:

Σ−1γ = X ′Σ−1X + Σ−1

γ ,

µγ = Σγ

(X ′Σ−1r + Σ−1

γ µγ

),

Σ = diag({ht(γ,α, β)}Tt=1

),

where γ is the previous draw. Then, a candidate γ? is sampled from the proposal density in

(2.2) and accepted with probability:

min

{p(γ?,α, β | r, X)

p(γ,α, β | r, X)

qγ(γ | γ?,α, β, r, X)

qγ(γ? | γ,α, β, r, X), 1

}The parameters α and β are obtained by transforming the GARCH(1,1) model. We define

wt = a2t − ht such that:

ht = α0 + α1a2t−1 + βht−1,

⇔ a2t = α0 + (α1 + β) a2

t−1 − βwt−1 + wt,

where:

wt = a2t − ht =

(a2t

h2t

− 1

)ht = (χ2

1 − 1)ht.

The variable wt has a conditional mean of zero and a conditional variance of 2h2t and can be

approximated by the normally distributed variable zt ∼ N (0, 2h2t ). Replacing wt by zt(α, β)

Page 17: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 12

yields the following expression:

zt(α, β) = a2t − α0 − (α1 + β) a2

t−1 − βzt−1(α, β). (2.3)

Now, similarly as for γ, we can define the likelihood function of (α, β) which is defined by:

L(α, β | γ, r, X) ∝ |det Λ|−12 exp

[1

2z′Λ−1z

]. (2.4)

Let us define vt = a2t such that the recursive transformations are:

ct =

(l∗t

v∗t

)=

(1 + βl∗t−1

vt−1 + βv∗t−1

),

where the initial values (l∗0, v∗0)′ are equal to zero. Then, the function zt = vt − c′tα can be

evaluated in (2.4) to approximate α. The proposal density is then:

qα(α | γ, α, β, r, X) ∝ Np(α | µα, Σα)I{α>0}

with,

Σ−1α = C ′Λ−1

α C + Σ−1α ,

µα = Σα

(C ′Λ−1

α v + Σ−1α µα

),

Λα = diag({

2h2t (γ, α, β)

}Tt=1

).

Likewise, the tilde represents the previous draw and the star represents the candidate. The

candidate γ? is sampled from the proposal and accepted with probability:

min

{p(γ,α?, β | r, X)

p(γ, α, β | r, X)

qα(α | γ,α?, β, r, X)

qα(α? | γ, α, β, r, X), 1

}.

Finally, we need a proposal function for β. The function zt(α, β) in (2.3) is linear with respect

to α but not with respect to β due to the βzt−1(α, β) term in it. Therefore, we use a first order

Taylor approximation to estimate zt(β) at point β:

zt(β) ' zt(β) +∂zt∂β|β=β· (β − β).

Let,

st = zt(β) + β∇t,

∇t = u2t − zt−1(β) + β∇t−1,

with ∇0 = 0. The function zt(β) is defined as in Equation (2.3) with α being treated as a

constant. Then we have that for (2.4), z ' s − β∇. Just as for γ and α, we combine the

Page 18: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 13

likelihood with the prior density to obtain the proposal density for β:

qβ(β | γ,α, β, r, X) ∝ N (β | µβ, Σβ)I{β>0},

with,

Σ−1β = ∇′Λ−1

β ∇+ Σ−1β ,

µβ = Σβ

(∇′Λ−1

β s + Σ−1β µβ

),

Λβ = diag

({2h2

t (γ,α, β)}Tt=1

).

A candidate β? is generated from this density and accepted with probability:

min

{p(γ,α, β? | r, X)

p(γ,α, β | r, X)

qβ(β | γ,α, β?, r, X)

qβ(β? | γ, β, β, r, X), 1

}

Accordingly, the algorithm will start the next iteration again with γ until the J-th iteration is

reached. This results in a distribution, the posterior to be precise, of the parameters. Credible

intervals can be obtained by quantiles of the posterior distribution. Point estimates are typically

the mean, median or the mode (obtained from a non-parametric kernel function).

2.3 Risk measures

In this research we will examine three risk measures: VaR, ES, and Expectiles. Let us first

define a stationary process Rt such that:

Rt = µt +√htZt,

where Z ∼ i.i.d.(0, 1). Let us also define PR(r) and FR(r) which represent the predictive

cumulative distribution and the true distribution, respectively. Then, the definitions of the

unconditional Value-at-Risk, Expected Shortfall, and Expectile are given below:

−VaRp(R) = inf {r ∈ R : PR(r) ≥ p} ,

−ESp(R) = E [R|R ≤ −VaRp(R)] =1

p

∫ p

0−VaRu(R)du,

eτ (R) = arg minr∈R

τE[max(R− r, 0)2

]+ (1− τ)E

[max(r −R, 0)2

],

where 0 < p, τ < 1. In the figure below, the latter functions of p and τ are given for R ∼ N (0, 1).

For the interested reader, Bellini and Di Bernardino (2014) discuss a wide variety of distributions

in the light of the quantiles and Expectiles.

Page 19: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 14

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Quantile

-3

-2

-1

0

1

2

3R

isk m

easure

s-VaR

-ES

Expectile

Figure 2.2: Risk measure for p or τ under standard normal distribution.

Note that in the left tail: -ES < -VaR < e . Also VaR.01(R) ≈ ES.025(R) ≈ −e.00145(R). From

the formulas above it can be seen that the risk measures do not rely on t - they are unconditional.

If we do take the stochastic nature into account and condition on the filtration Ft−1, we can

get the conditional risk measures for the one day ahead return:

−VaRtp(R) = µt+1 +

√ht+1zp,

−EStp(R) = µt+1 +√ht+1E [Z|Z ≤ zp] ,

etτ (R) = µt+1 +√ht+1e

tτ (Z),

where zp is the p-st quantile of an assumed distribution of Z (for instance normal). Note that

we explicitly distinguish between the quantile p and τ , as τ is not a quantile. For a discussion

on conditional and unconditional VaR and ES we refer to McNeil and Frey (2000).

Properties

Earlier, we mentioned that VaR was not coherent. Artzner et al. (1999) defined a risk measure

ρ(·) to be coherent if it satisfies the following four properties:

1. Translation invariance ρ(Z − c) = ρ(Z)− c, ∀ a ∈ R.

2. Subadditivity ρ(Z1 + Z2) ≤ ρ(Z1) + ρ(Z2).

3. Positive homogeneity ρ(λZ) = λρ(Z), ∀ λ ≥ 0.

4. Monotonicity P (S ≤ Z) = 1⇒ ρ(S) ≤ ρ(Z).

Besides these, there exist other important properties such as:

Page 20: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 15

5. Law-invariance ρ(Z1) = ρ(Z2)⇒ P (Z1 ≤ c) = P (Z2 ≤ c) ∀ c ∈ R.

6. Comonotonic additivity ρ(Z1 + Z2) = ρ(Z1) + ρ(Z2).

7. Elicitability

The latter notion, elicitability, has drawn a lot of attention lately after Gneiting (2011), who

showed that ES is not elicitable, whereas VaR and the Expectile are. In fact, the Expectile

is the only elicitable coherent risk measure. A risk measure ρ(Z) is said to be elicitable if it

minimizes an expected value of the scoring function S:

ρ = arg minω∈R

E[S(ω,Z)] (2.5)

The estimator for the expected scoring function is the mean score over the realizations. The

scoring functions of VaR and the Expectile are given below:

S(ω, z, p)VaR = (1(ω>r) − p) · (ω − z),

S(ω, z, τ)Expectile = |1(ω>r) − τ | · |ω − z|.2

The following table provides an overview of the VaR, ES and Expectile and which properties

they satisfy.

1.-4. 5. 6. 7.

VaR x x

ES x x

Expectiles x x x

Table 2.1: Risk measures and their properties.

For a broad discussion on these risk measures’ properties, we refer to Emmer et al. (2013).

2.4 Backtests

In this section some commonly applied backtests will be discusssed. As literature on VaR

backtests is immense and Acerbi and Szekely (2014) proposed three backtests for ES, we will

elaborate on Expectile backtests. In fact, we develop two ourselves.

2This notation comes from Newey and Powell (1987). Note that when we defined the Expectile we alreadydefined a scoring function.

Page 21: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 16

2.4.1 Kupiec’s backtest (VaR)

One of the reasons why VaR was such a popular risk measure in practice is because its backtest

is very intuitive. Let us define the hit series for a fixed time interval as below:

It+1(p) =

0 if rt,t+1 ≤ −VaRp

1 if rt,t+1 > −VaRp

.

Then, under H0 we should have thatT∑t=1

It ∼ Bin(T, p) and we can use asymptotically valid

tests3 based on the t-statistics:

t0 =p− p0√

p0(1− p0)/Tor t =

p− p0√p(1− p)/T

,

where p =1

T

T∑t=1

It. Note that because of the asymptotic approximation t0 and t follow a normal

distribution. Then for a given confidence level α, we reject the hypothesis that p0 represents

the frequency that the loss is beyond VaRp if |t| > z1−α, where z1−α is the 1− α-st quantile of

the standard normal distribution.

This test is known as Kupiec’s [1995] test. The CRD-IV (latest capital requirements regu-

lation and directive) penalizes banks by enforcing them to hold more capital if in their modelT∑t=1

It exceeds p · T too much. The test and possible penalties are named the Basel Commit-

tee’s traffic light system. It consists of three zones (green, orange and red), each with different

penalties.

VaR can also be backtested by Christoffersen’s test [1998] or Engle and Manganelli’s test [2004].

Both are conditional coverage tests as they take the time series structure into account. The

backtest proposed by Christoffersen tests for independence between hit series in a Markov Chain

context. This test is out of scope though, as it does concern the independence of frequencies

rather than the frequency of exceedance of the VaR itself. The Engle-Manganelli backtest will

not be discussed in the VaR context, but will be applied to an Expectile statistic.

2.4.2 ES backtests

In 2014, Acerbi and Szekely proposed three backtests for ES as a reaction to the ongoing

criticism towards the backtestability of ES. In the paper they discussed three tests Z1, Z2 and

Z3, each having their own strengths. Acerbi and Szekely concluded that Z2 would be a suitable

3Normal approximations roughly hold if T · p > 5 and T · (1− p) > 5. If this does not hold we can still use theBinomial distribution. If normal approximations cannot be applied, one can evaluate the point Fn,p(

∑Tt=1 It),

and compare it with the boundaries α2

and 1− α2

.

Page 22: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 17

replacement for the current backtest for VaR (defined above). The test statistic is:

Z2(R) =

T∑t=1

Rt · ItT · p · ESp,t

+ 1,

where the appropriate hypothesis is:

H0 : P[a]t = F

[a]t

H1 : ESFa,t ≥ ESa,t, for all t and > for some t

and VaRFa,t ≥ VaRa,t, for all t

The testing of the hypothesis goes as follows: we simulate the distribution PZ under H0 to

compute p = PZ(Z(r)) of realization Z2(r):

simulate independent Rit ∼ Pt ∀t,∀i = 1, . . . ,M

compute Zi2 = Z2(Ri)

estimate p =

M∑i=1

(Zi < Z(r))/M

A great advantage of this test over Z1 and Z3 is that it does not require to store a lot of data.

In fact, testing Z2 requires to record only the magnitude of Rt · It and the predicted ESa,t per

day. A disadvantage of these that is that they require Monte Carlo simulation and are therefore

computationally intensive.

2.4.3 Expectile backtests

In this subsection we propose two new backtests. Note from earlier notation that the Expectile

depends on τ rather than p. The relation between τ and p depends on the underlying distribution

of the random variable of interest and therefore cannot be compared a priori. This is not the only

reason: even if we knew this relationship, each backtest would test uncomparable hypotheses,

leading to ’apples and oranges comparisons’. Henceforth, we are not so much interested in how

the proposed Expectile backtests perform relatively to each other, but how they perform per

se.

FOC backtest

We developed the first backtest by taking the first order derivative of the Expectile’s scoring

function. This yields the following equation:

τ =E[(Z − eτ )−]

E[|Z − eτ |]. (2.6)

Page 23: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 18

Thus, if the true Expectile is eτ , it would imply that Equation (2.6) holds. Hence we form

hypothesis:

H0 : Equation (2.6) holds, with eτ = eτ .

H1 : Equation (2.6) does not hold.

where eτ is the hypothesized expectile. Equation (2.6) also enables us to provide some intuition

about the Expectile; Bellini and Di Bernardino (2014) state that ”the Expectile is the amount of

money that should be added to a position in order to have a prespecified, sufficiently high gain-

loss ratio of τ”. We construct the test statistic E based on sample equivalent of the equation

above using the return data {rt}Tt=1 and the hypothesized Expectile eτ :

zt ≡rt − µt√

ht

yt,τ ≡ zt − eτ , (2.7)

xt,τ ≡ τ |yt,τ |+ yt,τ · 1(yt,τ<0),

E(τ) =1

T

T∑t=1

xt,τ .

In Figure 2.3 we have illustrated the statistic xt,.00145 for 100 i.i.d. observations with Z ∼N (0, 1). Recall that under the standard normal distribution the theoretical Expectile of .00145

is equal to the 99% VaR and hence we expect yi to be negative once. Indeed, in Figure 2.3 we

observe that xt < 0 ⇒ yt < 0 occurs once. Note that when yt,τ < 0, its magnitude is large.

Ideally we would have that its magnitude be just as large as the 99 observations larger than 0

summed together.

0 10 20 30 40 50 60 70 80 90 100

T

-0.3

-0.25

-0.2

-0.15

-0.1

-0.05

0

0.05

xt,τ

xt,τ

Figure 2.3: Realisation of xt,.00145.

Page 24: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 19

Also, note that E can be rewritten as

E(τ) = τ1

T

T∑t=1

yt,τ1(yt,τ≥0) + (1− τ)1

T

T∑t=1

yt,τ1(yt,τ<0).

Under the null hypothesis and assuming xt,τ is i.i.d., we have by LLN and CLT that:

√TE(τ)→ N (0, Q),

where Q is consistently estimated by the sample variance s2x. Then, with a 1 − α confidence

level we reject H0 if E(τ) < tα2,T−1 · sx√T or E(τ) > t1−α

2,T−1 · sx√T . Note that E(τ) is equal to

the OLS estimate of λ in the equation

x = ι · λ+ u,

where x, ι and u are N × 1 vectors containing xt, ones and normally distributed error terms,

respectively. Then,

λOLS =ι′x

ι′ι=

1

T

T∑t=1

xt,τ and Var[λOLS] =σ2x

T,

with the equivalent hypothesis H0 : λ = 0;H1 : λ 6= 0. Generally, τ is very small leading to a

a strong asymmetry in the distribution of xt,τ which causes poor predictions for the Expectile.

This problem may be overcome by bootstrapping.

ALS backtest

Alternatively, let β(τ) be the parameter that solves (2.5) for the Expectile scoring function.

That is, asymmetric least squares with a constant on the residual data zt. Newey and Powell

(1987) showed that for:

ut,τ ≡ xt − β(τ),

wt,τ ≡ |τ − 1(ui,τ<0)|,

W =1

T

T∑t=1

wt,τ ,

V =1

T

T∑i=1

w2i,τ u

2t,τ ,

√T (β(τ)− β(τ))

d→ .N (0,W−1VW−1).

Page 25: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 20

We can estimate the variance-covariance matrix consistently by its sample analogue. We test

the following hypothesis by using a t-test:

H0 : β(τ) = eτ ; H1 : β(τ) 6= eτ ,

where eτ is the Expectile implied by the assumed distribution of Z.

Expectile F-test

So far we have only considered unconditional coverage tests for the Expectile. The Engle and

Manganelli (2004) test however, is a conditional coverage test: the statistic jointly accounts for

independence of lags and correct coverage of the Expectile. It was constructed for the use with

VaR, but we will use an equivalent test for the Expectile. It is basically an F-test performed on

a regression of xt on a constant and lags of xt for the hypothesis that all coefficients are zero.

The regression model we use for this model is therefore the following:

xt = λ+K∑k=1

xt−kδk + u′t.

The model above is basically the FOC Expectile backtest regression model extended by lags of

xt. As a result we can verify whether there is serial correlation left in xt. Suppose for instance

that we cannot reject the FOC hypothesis but do reject the EM test. In that case we would

have reason to believe there is serial correlation left in xt as the FOC test does not have any

power against dependence. The F statistic is given by:

F =(TSS −RSS)/(K + 1)

RSS/(T − 2K − 1)∼ FK+1,T−2K−1.

Note that F follows an F distribution with T − 2K − 1 degrees of freedom as we have T −Kobservations. TTS and RRS stand for total and residual sum of squares, respectively.

Realized loss functions

A statistic to compare multiple models based on the Expectile, the realized loss, is illustrated

by Bellini and Di Bernardino (2014) and is given below:

L(eτ , xt) =

(1− τ) · (xt − eτ )2 if xt − eτ ≤ 0,

τ · (xt − eτ )2 if xt − eτ > 0.

The lower the realized loss, the better the accuracy of the Expectile’s forecast. If one wishes

to, it is possible to backtest based on realized loss function although it requires simulation.

Therefore we will not perform such a test. For the interested reader, we refer to the extensive

review on (VaR) backtests given by Campbell (2005); we will not perform such a backtest.

Page 26: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 21

2.5 Bootstrapping

Because there is a strong asymmetry in xt, we may mistrust the correctness of standardized

intervals for small T . Therefore we could prefer to bootstrap instead which allows for asymmetric

confidence intervals. For the unconditional coverage test we will apply the resampling method.

2.5.1 Resampling method

This method is probably the most straightforward bootstrap method. From the original sample

{x1,τ , . . . , xT,τ} we resample exactly T draws with replacement. The probability of drawing a

certain xt,τ is uniformly distributed such that every observation has a probability of 1T of being

drawn. With this bootstrapped sample we calculate a t-value, simply by using the bootstrapped

sample as input for the hypothesis test instead of the original sample.

If we repeat this resampling B times, we end up with a distribution of {tb}Bb=1. Finally, we

can estimate the p-value of the hypothesis by

p-value = 2 min

(1

B

B∑b=1

1(tb<tobs), 1−1

T

B∑b=1

1(tb<tobs)

),

where tobs is the t-value of the original sample.

2.5.2 Moving Block Bootstrap

An advantage of the resampling method is that it is very intuitive and simple. A disadvantage is

that the random drawing of observations destroys the stochastic nature of the original sample.

For the unconditional coverage tests this is not a problem because we are not interested in it

stochastic structure. All the more this is a problem for the F -test: breaking the stochastic

structure of serial correlated variables would lower the significance of lags and result in a rela-

tively lower p-values.

To remedy this, we use the moving block bootstrap. Let us define N = T − `+ 1 with ` ∈ N+.

We cut the sample of {xt,τ}Tt=1 in N blocks,

B1 = {x1,τ , . . . , x`,τ},

B2 = {x2,τ , . . . , x`+1,τ}... =

...

BN = {xN,τ , . . . , xT,τ},

and draw each with probability 1N . In total, we draw k blocks with k = T

l , such that the

bootstrap sample length is close to the original sample length. Then, if this will be repeated B

Page 27: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 2. METHODOLOGY 22

times one obtains a bootstrapped F distribution. The p-value is then calculated by

p-value =1

B

B∑b=1

1(Fb>Fobs),

where Fobs is the statistic raising from the original sample. Choice of ` is crucial here: too

small blocks will break the stochastic structure of the sample and a too large blocks will not be

random enough. Literature suggests to choose ` ≈ T13 .

Page 28: Bayesian GARCH Estimation and Expectile Backtesting

Chapter 3

Monte Carlo study

3.1 Monte Carlo DGP

In this section we describe the default parameters series. These are, if not specified differently

in following sections, given in the table below. The data generating process is a GARCH(1,1)

process with standard normal innovations and zero mean. For the sake of convenience it is chosen

to leave out an AR(p) mean process as it only produces additional noise when estimating. In

the Appendix the process is depicted and the table below summarizes the parameter values.

α0 α1 β r0 h0 T

0.00001 0.05 0.94 0 0.001 500

Table 3.1: GARCH(1,1) Parameters.

This process resembles a typical financial time series of returns, with two years of daily market

data (about 250 workdays a year). Note that we set the initial values equal to their expectation

(unconditional mean and variance).

r0 = 0, h0 =α0

1− α1 − β.

3.2 Inference Methods

In this section we will investigate the research questions by applying the methodology on the

data as illustrated in the earlier two chapters. For the MCMC method, a common procedure is

to choose J = 10, 000 iterations. Typically, we rely on Monte Carlo to strengthen our analysis

and thus we choose 1000 simulations. As a result, the analysis becomes computationally inten-

sive - we estimate 1000 times an MCMC algorithm with 10, 000 iterations!

Since we require the MCMC parameter estimates to converge to the posterior, we choose a

burn-in period of 5, 000. This means that we drop the first 5, 000 iterations and only consider

the last 5, 000. For the initial values of the MCMC algorithm, we choose the ones suggested by

23

Page 29: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 3. MONTE CARLO STUDY 24

Ardia: (α[0], β[0]) = (0.01, 0.1, 0.7).

In his book, Ardia chooses priors proportional to the truncated normal distribution. To be

specific, he chooses diffused priors, which are given below:

µα = 0, µβ = 0, Σα = 10, 000 · I2 and Σβ = 10, 000,

As a result, the prior distribution contains little information, in fact approximately none due

to the wide variance. We concur with this diffuse prior as it does not restrict the posterior

distribution to a prespecified range of potential parameter estimates.

Now a prior is chosen, we will focus on the difference in point estimates between both in-

ference methods. Subsequently, convergence of parameter estimates is explored by increasing

the sample length. Furthermore we will investigate the behaviour of both inference methods

estimates’ under an error distribution different from the standard normal. In the following

chapter we will apply such an analysis to the S&P 500 and the Nikkei 225.

For the analysis we have made use of MATLAB and R. More precisely, we made use of a package

in R named "bayesGARCH" developed by David Ardia, which consists of a MCMC algorithm for

GARCH(1,1) models with t or normal innovations.

3.2.1 Point estimates

In this subsection we compare point estimates for the frequentist and Bayesian method. For the

frequentist method we consider the ML estimate, for the Bayesian methods we will consider the

mean of the posterior distribution. For time series, there are multiple approaches to evaluate

parameter estimates. For instance, one could forecast n days ahead and forecast these either

statically or dynamically. Similarly one can evaluate the fit on the data. Common statistics

used to evaluate estimation error are the Bias, Standard Deviation and Root Mean Squared

Error (RMSE). For a parameter estimate θ, the statistics are given by:

Bias[θ] = E[(θ − θ)],

StDev[θ] =

√E[(θ − E[θ])2],

RMSE[θ] =

√E[(θ − θ)2].

Note that MSE = Bias2 + Var. The statistics are given in the table below for all parameter

estimates of ψ and the 1-day ahead forecast of hT+1.

Page 30: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 3. MONTE CARLO STUDY 25

α0 (·10−4) ML MCMC α1 (·10−2) ML MCMC

Bias 0.3564 1.183 Bias 0.2485 4.546

St. Dev 0.9052 0.4662 St. Dev 2.433 3.419

RMSE 0.9726 1.272 RMSE 2.445 5.688

β (·10−1) ML MCMC hT+1 (·10−4) 1 ML MCMC

Bias -0.4261 -1.7455 Bias 0.02325 0.02713

St. Dev 1.154 0.7191 St. Dev 7.056 6.875

RMSE 1.230 1.888 RMSE 7.056 6.875

Table 3.2: Statistics for ML and MCMC estimates.

The table above displays that the MCMC estimates suffer from considerably larger biases than

the ML estimates. On the other hand we find that the MCMC estimates center more closely

around their (biased) estimate than the ML estimates. If we combine both results by examining

the RMSE, they favor the ML estimates. In fact, we have observed that MCMC estimates are

biased to the extent that posterior parameter distributions barely intersect, if not intersect at

all, with the true parameter values.

When we take a closer look at the ML estimates from the Monte Carlo simulation, we find

that their distribution is skewed and fat-tailed (around the true value). Indeed a Jarque-Bera

test confirms the non-normality by rejecting (p-values of approximately 0) that the skewness

and kurtosis are equal to those of the normal distribution. As a result, inference based on

asymptotic theory will lead to type I (false positives) and type II (false negatives) errors. The

advantage of Bayesian inference is that it does not rely asymptotic theory, yet on its the poste-

rior distribution, which may have any shape - including the normal distribution - and is therefore

more flexible. It should be mentioned though, relying on asymptotic theory can by avoided by

bootstrapping.

3.2.2 Sample length

By means of an illustration, we show how the estimates behave for different sample lengths for

(α0, α1, β) = (.001, .05, .9). We consider only one time series because a Monte Carlo simulation

will be a computational burden for large T . By theory it should hold that for t → ∞, the

frequentist and Bayesian estimates converge to the true value since we have a diffuse prior. As

a result, both estimates will be close to one another. The table below depicts the parameter

estimates for multiple sample lengths.

1The approximation of hT+1 is based on hT , that is, the true (and thus unobservable) conditional variance attime T .

Page 31: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 3. MONTE CARLO STUDY 26

T αMLE0 αMLE

1 βMLE EMLE(10) αMCMC0 αMCMC

1 βMCMC EMCMC(10)

250 .0653 .0183 .9444 11.51 .1035 .0512 .3627 16.22

500 .0052 .1678 .5815 32.64 .0902 .2045 .3796 34.27

1,000 .0067 .0346 .9298 4.91 .01027 .0683 .3877 11.07

10,000 .00091 .0566 .8991 6.92 .00118 .0621 .8804 7.08

100,000 .00097 .0508 .9005 6.31 .00101 .0516 .8980 6.32

Table 3.3: Estimates for different values of T .

where E(l) is the mean absolute percentage error (MAPE) for the l day ahead forecast, defined

by:

E(l) =1

l

T+l∑t=T+1

|ht − ht|ht

Even though the MAPE does not decrease monotonically as T increases, we do find that for

each number of observations, the MH estimate has a larger MAPE than the MLE estimate.

Additional evidence can be found in Table 6.1, which contains a DGP equal to the one in

Table 3.2, but with a sample length of 1000 observations. Again, in terms of RMSE, the ML

estimates are superior to the MCMC estimates. The Monte Carlo distribution of the MCMC

estimates are given in figure 6.4. What can be seen is that even for T = 1000, results are

massively biased.

3.2.3 Innovations

In this section we demonstrate the behaviour of both estimation methods under different in-

novations for 100 MC simulations. Besides, we will examine how the estimates behave under

misspecification. We will examine two different error distributions: the standardized student t

distribution with ν = 3 and the standard normal distribution. The true value of α0 has been

modified here to .01.

Est. t(·) Φ(·)DGP α0 α1 β ν α0 α1 β

ν = 3MLE .0108 .0513 .9394 3.016 .0168 .0698 .9144

MCMC .0209 .0751 .9115 2.948 .0365 .0824 .8602

Φ(·)MLE .0134 .0523 .9378 10.00 .0129 .0490 .9376

MCMC .0559 .0814 .8605 89.91 .0536 .0786 .8642

Table 3.4: Parameter estimates under different error innovations and assumptions.

On the diagonal boxes we find the correctly specified models and on the off-diagonals we find the

misspecified models. If we compare the parameter estimates with the true values, we first note

Page 32: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 3. MONTE CARLO STUDY 27

that the MCMC estimation method has difficulties estimating the normal innovations DGP: it

highly overestimates α and underestimates β. Overall we perceive that MLE has smaller biases

than MCMC, especially when misspecified. Note also that the MLE method was bounded from

above by v = 10 due to the used package fGarch in R.

3.3 Backtests

From the interim results, it has been observed that a Monte Carlo simulation over a MCMC

algorithm causes computational limitations. Also, for the Monte Carlo DGP, Bayesian point

estimates suffered from serious bias with respect to MLE. Using poor estimates would result in a

’garbage in, garbage out’-effect. Therefore, it has been decided not to investigate risk measures

under a Bayesian GARCH framework for the Monte Carlo DGP.

The following graph depicts the return series with the corresponding negative conditional VaR

(a = 0.01) for the one day ahead return based on a GARCH(1,1) model with normal innovations

estimated by ML:

0 500 1000 1500 2000

−0

.10

0.0

00

.05

0.1

0

Time

retu

rns

Figure 3.1: Returns and Negative Value at Risk.

Note that for τ = 0.00145, the Expectile is approximately equal to the VaR under a standard

normal distribution (2.33). In this section we will perform a Monte Carlo study (5, 000 simula-

tions) to examine the rejection frequency of the backtests for p(p), F (p), E(τ), β(τ) and F (τ)

with a significance level of 5% for a = 0.01 and τ = 0.00145. As in Figure 3.1, the Monte Carlo

DGP is kept as input, but the sample length is set to T = 2, 000 unless specified differently.

Page 33: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 3. MONTE CARLO STUDY 28

Size

For a correctly specified model, we expect that the rejection frequency equals the size of α.

Thus, for a very large number of observations a correctly specified model should have minuscule

estimation error and thus rejection frequencies should be close to a 5%. Also, the t-statistics

should converge to normal distributed variables. Figure 3.2 depicts the distribution of 5, 000

simulated t-values with T = 100, 000 for the t distributed backtests:

Kupiec’s test

t−statistics

Fre

quency

−3 −1 0 1 2 3

0200

400

600

800

1000

FOC Expectile test

t−statistics

Fre

quency

−3 −1 0 1 2 3

0200

400

600

800

ALS Expectile test

t−statistics

Fre

quency

−3 −1 0 1 2 3

0200

400

600

800

1000

Figure 3.2: t-statistics for all three unconditional backtests.

The corresponding rejection percentages are 5.34%, 5.18% and 5.2%, respectively. Hence we

observe that the size distortion (Rej. Freq. - α) are very small, indicating tests’ asymptotic

validity. Also, the Jarque-Bera hypothesis of the third and fourth moments matching those of

a normal distribution, cannot be rejected.

In the following plot we have depicted the convergence of rejection frequencies to α as T →∞.

Page 34: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 3. MONTE CARLO STUDY 29

500 1000 1500 2000

T

0

0.05

0.1

0.15

0.2R

eje

ction F

requency

Kupiec's

F(a)

FOC

ALS

F(τ)

Figure 3.3: Backtests’ convergence to α as T increases.

What we see is that for relatively small sample size, there is a positive size distortion; all tests

except Kupiec’s over reject. Surprisingly, Kupiec’s test remains rather steady when decreasing

the sample size. As T converges to a larger number, the rejection frequencies converge to α

although they still differ a little from the size. The explanation here is that the GARCH(1,1)

model parameters are not exactly equal to the true values, causing estimation error. Figure 3.3

therefore tells us more about how the tests behave when including estimation error and how

they converge to α as t→∞. We observe that of the VaR tests the F (p) test is most close to

the significance level (p-value of 5.14%) and converges to α fast. For the Expectile backtests it

is the ALS test with a p-value of 5.88%.

In the following table we have depicted the rejection frequencies for different values of τ .

τ E(τ) β(τ) F (τ)

.00045 .1308 .1094 .1142

.00145 .0700 .0588 .0694

.00245 .0520 .0462 .0590

.5 .0468 .0468 .0542

Table 3.5: Rejection Frequencies for Multiple τ .

What we see is that as τ gets larger, size distortions become smaller. Most probably because the

number hits in zi,τ increase, such that outliers affect the mean less heavily. In other words, an

increase in number of observations in the tail causes size distortions to decrease. Resultantly, we

would expect the smallest size distortion when we are exactly in the middle of the distribution

that is, τ = 0.5. Indeed, we find a very low size distortion, but it is also worth mentioning is

that for τ = 0.5 the Expectile test statistics are identical.

Page 35: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 3. MONTE CARLO STUDY 30

Bootstrapped t-values

If we plot the distribution of both Expectile backtest t-statistics for T = 2000, we find that

they are skewed to the right. A Jarque-Bera test confirms the non-normality as we find p-values

of approximately zero, resulting in a rejection of its null hypothesis (normal skewness and kur-

tosis). The VaR backtest on the other hand, does not fail the test. Hence, bootstrapping is

worthwhile for the Expectile backtests.

For the unconditional coverage tests (the t-tests) we apply a resampling method with B = 399

draws. For the F -test we choose a block length of ` = 400 such that include 5 blocks in one

bootstrap sample. The rejection frequencies of the bootstrapped Expectile backtests are given

in Table 3.6

E(τ) β(τ) F

Rej. Freq. .0416 .0460 .0384

Table 3.6: Rejection Frequencies using Bootstrapped t-values.

When we compare the second row of Table 3.5 with Table 3.6, we find that the bootstrapped

rejection frequencies are closer to α than the ones under asymptotic theory. Even though

this encourages the use of bootstrapped t-values when using small samples, we continue with

inference based on asymptotic theory as bootstrapping within a Monte Carlo analysis is a

computational burden.

3.3.1 Power

In the previous part we investigated the size of the test. As we have seen, all the experiments

yielded results reasonably close to the size of 5% for proper values of T and τ . Another inter-

esting property of statistical tests is their power: the probability of rejecting the null hypothesis

given that the alternative hypothesis holds:

P (Reject H0 | H1 holds)

Accordingly, a high power leads to small probabilities of a type II error: the probability of

rejecting H0 whilst it holds.

3.3.2 Deviations from the unconditional VaR/Expectile

The most trivial way to verify the power of the tests is by testing the hypotheses for different

values of the VaR or Expectile. For a standard normally distributed random variable, the value

of the risk measures under τ = 0.00145 or a = 0.01 is about 2.33. In this case, the rejection

frequencies are about equal to the size. The figure below, illustrates how fast the rejection

frequencies increase when we deviate from the unconditional VaR/Expectile.

Page 36: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 3. MONTE CARLO STUDY 31

1.9 2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8

Risk Measure Amount

0

0.2

0.4

0.6

0.8

1R

eje

ction F

requency

Kupiec's

F(a)

FOC

ALS

F(τ)

Figure 3.4: Backtests’ power against misspecified risk measure amounts.

Apparently, all tests have more power against a too low value than against a too high amount

because the lines left from 2.33 increase faster to one than the lines on the right hand side. An

explanation for this might be that in the right hand there would be less data to evaluate the

hypotheses, leading to less power. A similar pattern we have seen in the case when we increased

τ . An increase in τ (decrease in the risk measure amount) improved estimates because there

were more observations in the tail. Similarly, if we lower the risk measure amount, power

increases as there is more data to verify the statement of the hypothesis. We further note that

the power of the F (τ) is smaller than the FOC tests’s power. This finding comes in as expected

because this deviation from the null concerns solely the coverage level. Less unforeseen is the

skewness of Kupiec’s test’ around 2.33: at an amount of 2.1 its rejection frequency is circa 0.9

whereas at 2.56 it is about 0.55.

Dynamic Misspecification

If we assume that the series are independently and identically distributed (i.i.d.), it implies

that the time series are independent from each other and the variance is unconditional of time.

Hence, we treat the Monte Carlo DGP as being i.i.d. and estimate the residuals zt based on a

fixed variance (over time). To be able to compare the GARCH data with the standard normal

distribution, we set the long run variance equal to 1 by choosing α0 = 0.01, α1 = .05 and

β = .94. The rejection frequencies for this misspecification are given below:

p(p) F (p) E(τ) β(τ) F (τ)

Rej. Freq. .2560 .3312 0.2826 .3372 .3222

Table 3.7: Rejection Frequencies assuming i.i.d.-ness.

Table 3.7 confirms that neglecting the conditional volatility structure of the GARCH(1,1) model

with normal innovations leads to a higher rejection frequency than when taking this structure

Page 37: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 3. MONTE CARLO STUDY 32

into account (correctly specifying the model). Namely, rejection frequencies in the second row

of Table 3.5 are considerably lower and closer to α. We find that the F (·) tests have only

little more power against this misspecification than their equivalent unconditional coverage

test (Kupiec’s and FOC). This is not necessarily because F (·) tests have little additional power

besides the coverage level, but because the distribution of the simulated data has excess kurtosis

by definition. This excess kurtosis is theoretically implied by the conditional volatility structure.

As a result, coverage levels will not be correctly specified, resulting in power for the unconditional

coverage tests. Yet, including more lags of hit series or xt though might improve rejection

frequencies of the F (·) tests relative to the unconditional coverage tests.

Distributional Misspecification

In this paragraph, we skipped the GARCH(1,1) estimation part and directly drew from i.i.d.

distributed data, which can be seen as the residuals in the GARCH(1,1) model (but then without

estimation error). First we estimate a risk measure based on data from a standardized t(ν)-

distribution. Then, we test the backtest statistics against the hypothesized value. Of course, for

ν =∞, the distribution would be correctly specified and we would expect rejection frequencies

around 5%. Moreover, the power should increase as ν decreases.

0 10 20 30 40 50 60 70 80 90 100

ν

0

0.2

0.4

0.6

0.8

1

Reje

ction F

requency

Kupiec's

F(a)

FOC

ALS

F(τ)

Figure 3.5: Backtests’ power against misspecified t(ν)-distribution.

Figure 3.5 exactly represents what we would expect: gains in power the moment the model

is misspecified. If we look more closely, we find that the ALS, FOC and Kupiec’s test have

substantially more power against misspecified distribution than the two F (·)-tests. When the

residuals resemble approximately a t(ν)-distribution with ν ≤ 10, the unconditional coverage

tests reject the hypothesis of being correctly specified with 1.

Another conclusion we can draw is that once we suspect the data are i.i.d., we should not

use the F -tests: Since one part of the hypothesis is true (that is, lags are independent), the

Page 38: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 3. MONTE CARLO STUDY 33

tests have more difficulties rejecting the misspecification of the coverage level compared to the

unconditional coverage tests. For instance, the difference between the FOC and F (τ) test

represents the gain in power if the lag of xt is discarded and we only test for the intercept

(unconditional coverage). Still they increase in power as v gets even smaller because they test

for the coverage level as well.

When we simulate the backtests for the correctly specified distribution (ν =∞), we can compare

how GARCH(1,1) estimation would affect the results. Table 3.8 depicts the rejection frequen-

cies, and can be compared with the second row of Table 3.5 which involves the GARCH(1,1)

estimation process.

ν p(p) F (a) E(τ) β(τ) F (τ)

∞ .0560 .0510 .0490 .0564 .0530

Table 3.8: Rejection Frequencies for i.i.d. data.

This table represents once again evidence that if the model would be correctly specified, the

rejection frequency is close to the size. We also observe that rejection frequencies in Table 3.8

have a smaller absolute size distortion than the ones in Table 3.5. From this it can be concluded

that estimation error has only a marginal effect on the rejection frequencies.

Page 39: Bayesian GARCH Estimation and Expectile Backtesting

Chapter 4

Empirical study

In this Chapter we apply our methodology to two financial market datasets. More precisely, we

investigate the S&P 500 and the Nikkei 225. Just as in the previous chapter, we first apply the

two inference methods to the data and continue by backtesting the model. When backtesting,

we investigate different innovation processes and sample lengths too.

4.1 Market data

For the empirical study we will consider two time series of financial markets. More precisely, we

consider two stock indices: the S&P 500 and the Nikkei 225. These time series are widely used

in empirical research and therefore results will be comparable with other findings. The data are

retreived from Bloomberg, but can easily be found on websites such as Yahoo Finance too.

4.1.1 S&P 500

The S&P 500 (daily) closing price (in dollars) will be used when applying the models to market

data. The S&P (Standard & Poor’s) 500 is an American stock index of 500 large companies

listed either on the NASDAQ or NYSE (both American stock markets). Therefore, this time

series represents typical financial market behaviour and is therefore a widely used dataset in

GARCH model studies. The starting date is January 1st of 2010, the ending date is December

31st, 2014. This period consists of 1258 trading days and includes the aftermath of the credit

crisis from 2008, which is relatively volatile, but also a recovery period in which a positive trend

is noticed. Similarly, the log returns process depicts turbulent periods followed by relatively

tranquil periods. Figures of the S&P 500 can be found in the Appendix (Figure 6.2) as well.

The table below summarizes the log return process by some statistics. Note though that except

for the number of observations, all values are given in basis points. The same holds for Table

4.2. Also, the careful reader will notice that that the log-returns consist of one observation less

due to first differencing.

34

Page 40: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 4. EMPIRICAL STUDY 35

Obs. mean med. var. min max

rS&P 500t 1257 4.8 7.2 1.0 −690 463

Table 4.1: Descriptive statistics S&P 500 (in basis points).

4.1.2 Nikkei 225

Just as the S&P 500 is a stock index of 500 large companies listed on American stock markets,

the Nikkei 225 (prices in yen) is a stock index of 225 large companies listed on the Tokyo Stock

Exchange (TSE). As is the case for the S&P 500, we have collected data from the 1st of January,

2010 up to the 31st of December, 2014. However, since there were fewer trading days, we have

1238 observations.

Obs. mean med. var. min max

rNikkei 225t 1237 4.0 5.7 1.9 −1120 552

Table 4.2: Descriptive statistics Nikkei 225 (in basis points).

The price and log-return processes are depicted in Figure 6.3. At first sight it looks like the

log-return process of the Nikkei 225 is far more volatile than the S&P 500, mainly due to the

higher spikes. The descriptive statistics confirm this belief as the unconditional variance is

higher.

For both indices the returns are positive and skewed. The magnitude of the mean return

is negligible compared its standard deviation. The skewness of the returns though, is serious.

This is for instance described by the difference in size of the minima and maxima.

4.2 Inference methods

In the following two subsections we align the parameter estimates of the Bayesian and frequentist

inference methods. The innovation processes are assumed to be normally distributed. For

the MCMC estimates we have provided 95% credible intervals, for the ML estimates we have

provided 95% confidence intervals.

Page 41: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 4. EMPIRICAL STUDY 36

4.2.1 S&P 500

The results are given in the table below and are based on the full sample length:

MCMC MLE

φ φ φ0.5 φ0.025 φ0.975 φMLE SE min 1 max

α0 (·10−6) 4.358 4.287 2.863 6.237 3.448 0.8287 1.824 5.072

α1 0.1495 0.1512 0.1104 0.1966 0.1218 0.0209 0.0900 0.1721

β 0.8088 0.8101 0.7612 0.8510 0.8341 0.0231 0.7888 0.8794

Table 4.3: Estimates S&P 500.

We have defined φq as the q-st quantile of the posterior distribution. The estimates above

are based on the first 500 observations. In comparison with Monte Carlo results, we find that

the point estimates are relatively close to each other and their intervals intersect for the greatest

part. Yet, their interpretation is different. For instance, for the ML estimate of α1 we would

say that ”if this experiment is repeated many times, in 95% of these cases α1 will be contained

in the constructed interval”. For the MCMC we could say the following: ”Given our observed

data, there is a 95% probability that the true value of α1 lies within [0.1003, 0.2134]”. Before

even regarding parsimony of the models, one could prefer one method to another based on this

difference in interpretation. A discussion on the fundamental differences between confidence

and credible regions is given by Vanderplas (2014) and Jaynes and Kempthorne (1976). We

will not dive into this discussion because we are specifically interested in the models’ relation

to backtestability. Besides, if we increase the sample size we find that both estimates converge

to each other - just as we have seen with the Monte Carlo DGP.

The RMSEs of the 10-day ahead static forecasts of hT+l for the MLE and MCMC estimates are

9.335 and 9.293 (both ·10−5), respectively. Hence, in contradiction to earlier results, estimates

perform evenly well. This result aligns with the one of Hoogerheide et al. (2012), who found

no significant difference between frequentist and Bayesian GARCH estimates for the S&P 500.

Likewise, Ardia (2006) found the same result.

4.2.2 Nikkei 225

Based on the full sample, we find the following results for the Nikkei 225 log-returns:

1min and max represent the lower and upper of a 95% confidence interval, respectively.

Page 42: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 4. EMPIRICAL STUDY 37

MCMC MLE

φ φ φ0.5 φ0.025 φ0.975 φMLE SE min max

α0 (·10−5) 1.195 1.145 0.6546 1.978 0.823 0.2837 0.2670 1.379

α1 0.1248 0.1235 0.0866 0.1702 0.1112 0.0199 0.0722 0.1502

β 0.8160 0.8186 0.7494 0.8672 0.8482 0.0271 0.7951 0.9013

Table 4.4: Estimates Nikkei 225.

Just as with the S&P 500, we find that α0 and α1 are larger for the Bayesian method, whereas

β is larger for the frequentist method. Also, all coefficients are found to be significant on a 5%

significance level as well.

In the previous section we observed that the Nikkei 225 has larger spikes than the S&P 500.

For the GARCH(1,1) model, it is theoretically implied that a high α1 leads to large spikes in

the time series. Results show that α1 is somewhat larger for the Nikkei 225 than for the S&P

500 which aligns with what we observe. It also means that unexpected shocks of yesterday

have a relatively larger effect on the volatility of Nikkei 225 than the volatility of the S&P 500.

Another finding is that α1 +β is approximately equal for the S&P 500 and the Nikkei 225. This

implies that the half-life of a shock on the S&P 500 is about as long as on the Nikkei 225.

4.3 Backtests

The estimates in the previous section allow us to estimate the standardized residuals, which

we backtest in this section. The backtests we will apply here are the same as in Section 3.3.

Correspondingly, conlusions are drawn based on a size of 5%.

4.3.1 S&P 500

Table 4.5 contains the p-values of the backtest. We distinguish between estimation methods,

innovation processes and sample sizes. For instance, the p-values on the first correspond to the

ML estimation method with normal innovations for the first 500 observations. In the second

row we investigated the effect of changing MLE to MCMC estimates, so we can identify the

influence of the estimation method keeping other factors constant. For the third and fourth row

the estimated innovation process is changed from a normal to a t(ν) distribution. Accordingly a

change in distribution would change the value of the risk measure. Bear in mind that different

estimation methods could lead to similar p-values when the estimated conditional variances vary

only slightly. The same goes for distributions: when ν is large, normal and t(ν) innovations are

approximately identical.

Page 43: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 4. EMPIRICAL STUDY 38

Method εt T p(p) F (p) E(τ) β(τ) F (τ)

MLE Φ 500 .0003 .0676 .0356 .0463 .1028

MCMC Φ 500 .0004 .0676 .0387 .0320 .1100

MLE t 500 .1781 .5274 .3682 .4575 .6657

MCMC t 500 .1521 .2518 .8773 .8819 .9790

MLE Φ 1000 .0000 .0073 .0109 .0020 .0356

MCMC Φ 1000 .0005 .0421 .0349 .0009 .0400

MLE t 1000 .3406 .6445 .1098 .1438 .2780

MCMC t 1000 .1124 .3814 .1614 .2045 .3738

Table 4.5: p-values S&P 500.

If we look at the first two rows, we find that p-values are approximately the same. Hence, es-

timation methods provide approximately the same conditional variances for this sample length

and innovation process. Indeed, the third and fourth row suggest that it is because the innova-

tion process since this similarity does not occur under t innovations. This is confirmed when we

double the sample size. For T = 1000, we clearly see that all models with normal innovations

will be rejected whereas the models with t innovations cannot be rejected. If look more closely

at the models with a t innovations process, we note that the VaR backtest’s p-values are higher

for MLE, and the Expectile backtests’ p-values are higher for the MCMC.

4.3.2 Nikkei 225

Below we find another table with p-values, this time for the Nikkei 225.

Method εt T p(p) F (p) E(τ) β(τ) F (τ)

MLE Φ 500 .6533 .0019 .2150 .2315 .0000

MCMC Φ 500 .3691 .0103 .2584 .2849 .0000

MLE t 500 1.000 .0000 .4361 .3054 .0000

MCMC t 500 .6533 .0019 .2669 .2477 .0000

MLE Φ 1000 .5252 .0622 .1388 .1379 .0000

MCMC Φ 1000 .5252 .0622 .1488 .1656 .0000

MLE t 1000 .7507 .0046 .3316 .2359 .0000

MCMC t 1000 .7507 .0364 .2725 .2262 .0000

Table 4.6: p-values Nikkei 225.

This table shows a rather different structure than Table 4.5. Our first observation is that F (τ)

rejects all the hypotheses. Indeed, if we look at the OLS regression statistics of F (τ) we find

that the lag of xt is extremely significant. For F (p) this phenomenon also occurs with respect

to the hit lag. Nevertheless, we find for all unconditional coverage tests p-values above 5%.

The table also shows that for allmost all cases the unconditional coverage tests based on a

Page 44: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 4. EMPIRICAL STUDY 39

model with t-innovations results in higher p-values than backtests based on models with normal

innovations. We could firmly state that the unconditional coverage level might be sufficient,

but there is still serial correlation left in the residuals. Therefore the zero mean GARCH(1,1)

model might be misspecified. For the sample of T = 1000 we find approximately equal p-values

for MCMC and MLE estimates, indicating that both estimation methods converge to the same

parameter values.

Page 45: Bayesian GARCH Estimation and Expectile Backtesting

Chapter 5

Conclusion

We have compared the use of two different inference techniques on a univariate GARCH(1,1)

model with normal innovations. For the Monte Carlo DGP, the MCMC method heavily under-

performed compared to MLE: RMSEs were substantially smaller for multiple sample lengths,

parameters and misspecifications. By constrast, if we apply both methods on market data we

barely see any differences.

Secondly, we developed two unconditional coverage Expectile backtests: one based on the FOC

of the Expectile’s score function and the other based on asymptotics of the asymmetric least

squares estimate. Results from the Monte Carlo study show acceptable rejection frequencies

for both backtests. These tests however, do have a larger size distortion than Kupiec’s test for

small samples, but are closer to the size for large T . An advantage is that they reject too high

risk amounts more easily than Kupiec’s test. That being said, we find little further difference

between the power of the unconditional tests. In addition to these backtests we have shown

that one can also perform a test comparable to the Engle-Manganelli test. Also, differences

between these tests in terms of rejection frequencies were found to be small. The empirical

analysis confirms this: for (almost) each case, conclusions based on the (un)conditional tests

would be the same.

A huge practical advantage of the Expectile is that its backtests do not rely on Monte Carlo

simulation, whereas ES backtests do. Considering both risk measures’ practical advantages

and their theoretical properties one could argue that the Expectile is the golden mean of risk

measures. As a result the Expectile might be a beneficial contribution to financial risk modelling.

For future research it would be interesting to simulate the paths of each MCMC iteration

and apply the risk measures to the posterior’s estimates. This would yield 5, 000 paths of the

returns and one could apply a risk measure on its distribution. Comparing this with the ’ordi-

nary’ risk measure could yield interesting insights. Another extension would be to investigate

this study in the multivariate setting. Both require intensive use of computing power, though.

40

Page 46: Bayesian GARCH Estimation and Expectile Backtesting

Bibliography

Acerbi, C., Nordio, C., and Sirtori, C. (2001). Expected shortfall as a tool for financial risk

management. arXiv preprint cond-mat/0102304.

Acerbi, C. and Szekely, B. (2014). Back-testing expected shortfall. Risk, 27(11).

Ardia, D. (2006). Bayesian estimation of the garch (1, 1) model with normal innovations.

Ardia, D. (2008). Financial risk management with Bayesian estimation of GARCH models.

Springer.

Ardia, D. and Hoogerheide, L. F. (2014). Garch models for daily stock returns: Impact of

estimation frequency on value-at-risk and expected shortfall forecasts. Economics Letters,

123(2):187–190.

Artzner, P., Delbaen, F., Eber, J., and Heath, D. (1999). Coherent measures of risk. Mathe-

matical Finance, 9:203–228.

Aussenegg, W. and Miazhynskaia, T. (2006). Uncertainty in value-at-risk estimates under

parametric and non-parametric modeling. Financial Markets and Portfolio Management,

20(3):243–264.

Bellini, F. and Di Bernardino, E. (2014). Risk management with expectiles. Available at SSRN

2475106.

Bollerslev, T. (1986). Generalized autoregressive conditional heteroskedasticity. Journal of

econometrics, 31(3):307–327.

Campbell, S. D. (2005). A review of backtesting and backtesting procedures. Divisions of Research

& Statistics and Monetary Affairs, Federal Reserve Board.

Christoffersen, P. F. (1998). Evaluating interval forecasts. International economic review, pages

841–862.

Committee, B. et al. (1988). Basle committee on banking supervision. The New Basel Capital

Accord. Bank for International Settlements, Basle (April 2003).

Dardac, N., Grigore, A., et al. (2011). Modeling the market risk in the context of the basel iii

acord. Theoretical and Applied Economics, 11(11):5.

41

Page 47: Bayesian GARCH Estimation and Expectile Backtesting

BIBLIOGRAPHY 42

di Basilea per la vigilanza bancaria, C. (2004). International convergence of capital measurement

and capital standards: a revised framework. Bank for International Settlements.

Emmer, S., Kratz, M., and Tasche, D. (2013). What is the best risk measure in practice? a

comparison of standard measures.

Engle, R. F. (1982). Autoregressive conditional heteroscedasticity with estimates of the variance

of united kingdom inflation. Econometrica: Journal of the Econometric Society, pages 987–

1007.

Engle, R. F. and Manganelli, S. (2004). Caviar: Conditional autoregressive value at risk by

regression quantiles. Journal of Business & Economic Statistics, 22(4):367–381.

Geweke, J. (1989). Bayesian inference in econometric models using monte carlo integration.

Econometrica: Journal of the Econometric Society, pages 1317–1339.

Glosten, L. R., Jagannathan, R., and Runkle, D. E. (1993). On the relation between the

expected value and the volatility of the nominal excess return on stocks. The journal of

finance, 48(5):1779–1801.

Gneiting, T. (2011). Making and evaluating point forecasts. Journal of the American Statistical

Association, 106(494):746–762.

Hoogerheide, L. F., Ardia, D., and Corre, N. (2012). Density prediction of stock index returns

using garch models: Frequentist or bayesian estimation? Economics Letters, 116(3):322–

325.

Jaynes, E. T. and Kempthorne, O. (1976). Confidence intervals vs bayesian intervals. In

Foundations of probability theory, statistical inference, and statistical theories of science,

pages 175–257. Springer.

Kondor, I., Caccioli, F., Papp, G., and Marsili, M. (2015). Contour map of estimation error for

expected shortfall. Available at SSRN 2567876.

Kupiec, P. H. (1995). Techniques for verifying the accuracy of risk measurement models. THE

J. OF DERIVATIVES, 3(2).

Li, T., Zhang, Z., and Zhao, L. (2011). Garch family model and its application in calculating

stock index future var in chinese market. Scientific Journal of Mathematics Research.

Mark, N. C. (1988). Time-varying betas and risk premia in the pricing of forward foreign

exchange contracts. Journal of Financial Economics, 22(2):335–354.

Marshall, A., Maulana, T., and Tang, L. (2009). The estimation and determinants of emerging

market country risk and the dynamic conditional correlation garch model. International

Review of Financial Analysis, 18(5):250–259.

Page 48: Bayesian GARCH Estimation and Expectile Backtesting

BIBLIOGRAPHY 43

McNeil, A. J. and Frey, R. (2000). Estimation of tail-related risk measures for heteroscedastic

financial time series: an extreme value approach. Journal of empirical finance, 7(3):271–

300.

Nakatsuma, T. and Tsurumi, H. (1996). Arma-garch models: Bayes estimation versus mle, and

bayes non-stationarity test. Technical report, Working Papers, Department of Economics,

Rutgers, The State University of New Jersey.

Newey, W. K. and Powell, J. L. (1987). Asymmetric least squares estimation and testing.

Econometrica: Journal of the Econometric Society, pages 819–847.

Rodrıguez, M. J. and Ruiz, E. (2012). Revisiting several popular garch models with leverage

effect: Differences and similarities. Journal of Financial Econometrics, page nbs003.

Stegmueller, D. (2013). How many countries for multilevel modeling? a comparison of frequen-

tist and bayesian approaches. American Journal of Political Science, 57(3):748–761.

Tierney, L. (1994). Markov chains for exploring posterior distributions. the Annals of Statistics,

pages 1701–1728.

Vanderplas, J. (2014). Frequentism and bayesianism: A python-driven primer. arXiv preprint

arXiv:1411.5018.

Xu, J., Zhang, Z., Zhao, L., and Ai, D. (2011). The application review of garch model. In Mul-

timedia Technology (ICMT), 2011 International Conference on, pages 2658–2662. IEEE.

Yamai, Y. and Yoshiba, T. (2002). Comparative analyses of expected shortfall and value-at-risk

(3): their validity under market stress. Monetary and Economic Studies, 20(3):181–237.

Yamai, Y. and Yoshiba, T. (2005). Value-at-risk versus expected shortfall: A practical perspec-

tive. Journal of Banking & Finance, 29(4):997–1015.

Zhu, D. and Galbraith, J. W. (2011). Modeling and forecasting expected shortfall with the

generalized asymmetric student-t and asymmetric exponential power distributions. Journal

of Empirical Finance, 18(4):765–778.

Page 49: Bayesian GARCH Estimation and Expectile Backtesting

Chapter 6

Appendix

6.1 A.

6.1.1 Data plots

In the figures below features of the Monte Carlo DGP are depicted:

Figure 6.1: Returns and volatility of the DGP.

Below, the S&P 500 dataset is depicted:

Figure 6.2: S&P 500.

Below, the Nikkei 225 dataset is depicted:

44

Page 50: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 6. APPENDIX 45

Figure 6.3: Nikkei 225.

6.1.2 DGP output

The following table can be compared with Table 3.2. Namely, the DGP is equal, except for the

sample length, which is doubled to 1000 observations.

α0 (·10−2) ML MCMC α1 (·10−4) ML MCMC

Bias 0.8506 7.634 Bias -0.06442 3.737

St. Dev 1.551 4.206 St. Dev 1.456 2.258

RMSE 1.769 8.716 RMSE 1.457 4.366

β (·10−1) ML MCMC hT+1 (·10−4) ML MCMC

Bias -0.08889 -1.187 Bias 0.00645 0.009311

St. Dev 0.2448 0.5473 St. Dev 6.282 6.133

RMSE 0.2605 1.307 RMSE 6.282 6.133

Table 6.1: Statistics for ML and MCMC estimates.

Page 51: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER

6.

APPENDIX

46

Below, the Monte Carlo distribution of the MCMC estimates are given:

Figure 6.4: Monte Carlo distribution of MCMC estimates.

6.1.3 Empirical Analysis output

Below, the posterior distributions of the S&P 500 are depicted:

Figure 6.5: Posterior distributions of S&P 500.

Page 52: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 6. APPENDIX 47

6.2 B.

6.2.1 Matlab code

1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

2 %% thesis Script v1.12 %%%%%%%

3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

4

5 % DESCRIPTION

6 % This code performs a Markov Chain Monte Carlo algorithm on a GARCH(1,1)

7 % model with normal innovations. The MCMC algorithm used in this code is

8 % the Metropolis-Hastings algorithm. The prior is a truncated normal

9 % distribution with mean 0 a variance of 10000, such that it is

10 % approximately flat.

11

12 % NECESSARY FUNCTIONS

13 % alphaParameters.m

14 % betaParameters.m

15 % logLikelihood.m

16 % logPriorAlpha.m

17 % logPriorBeta.m

18 % logProposalAlpha.m

19 % logProposalBeta.m

20 % updateAlpha.m

21 % updateBeta.m

22 % variance.m

23

24 %% Initialisation

25 clear all

26 tic;

27

28 %% Parameters

29 T = 1000;

30 alpha0 = [.039; .198];

31 beta0 = .686;

32

33 %% GARCH(1,1) DGP with Normal Innovations

34 epsilon = normrnd(0,1,T,1);

35 h = zeros(T,1);

36 h(1) = alpha0(1);

37 y = zeros(T,1);

38 y(1) = epsilon(1)*h(1)ˆ.5;

39

40 for t = 2:T

41 h(t) = alpha0(1) + alpha0(2)*y(t-1)ˆ2 + beta0*h(t-1);

42 y(t) = epsilon(t)*h(t)ˆ.5;

43 end

Page 53: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 6. APPENDIX 48

44

45 v = y.ˆ2;

46

47 %% Hyperparameters and Initial Values

48 muAlpha = [0;0];

49 sigmaAlphaInv = eye(2)/10000;

50 muBeta = 0;

51 sigmaBetaInv = 1/10000;

52 alpha = [.01; .05];

53 beta = .9;

54 Psi = [alpha; beta];

55 k = length(Psi);

56

57 %% MCMC Algorithm

58 J = 10000;

59 chain = zeros(J,k);

60 for i=1:J

61

62 alpha = updateAlpha(alpha, beta, v, muAlpha, sigmaAlphaInv);

63 beta = updateBeta(alpha, beta, v, muBeta, sigmaBetaInv);

64

65 chain(i,:) = [alpha', beta];

66 end

67

68 %% Figure

69 plot(cumsum(chain(:, 1)) ./ (1:J)')

70 toc;

1 function [newAlpha] = updateAlpha(alpha, beta, v, muAlpha, sigmaAlphaInv)

2 %updateAlpha.m

3 %Randomly draws an alpha from a prespecified distribution and either

4 %rejects or accepts it with a certain probability. The rejection is based

5 %on the prior distribution, likelihood and proposal distribution. If the

6 %proposed alpha is rejected, the original value remains.

7

8 alphaTilde = alpha;

9 [muAlphaHatTilde, SigmaInvAlphaHatTilde] = alphaParameters(alphaTilde, beta,v,

muAlpha, sigmaAlphaInv);

10 SigmaAlphaHatTilde = inv(SigmaInvAlphaHatTilde);

11 alphaStar = mvnrnd(muAlphaHatTilde, SigmaAlphaHatTilde)';

12 while any(alphaStar <= 0)

13 alphaStar = mvnrnd(muAlphaHatTilde, SigmaAlphaHatTilde)';

14 end

15

16 LogA = logLikelihood(alphaStar,beta,v) - logLikelihood(alphaTilde, beta, v) + ...

17 logPriorAlpha(alphaStar, muAlpha, sigmaAlphaInv) - logPriorAlpha(alphaTilde,

muAlpha, sigmaAlphaInv) + ...

18 logProposalAlpha(alphaTilde, alphaStar, beta, v, muAlpha, sigmaAlphaInv) - ...

Page 54: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 6. APPENDIX 49

19 logProposalAlpha(alphaStar, alphaTilde, beta, v, muAlpha, sigmaAlphaInv);

20

21 threshold = log(rand(1));

22 newAlpha = (threshold > LogA)*alphaTilde + (threshold <= LogA)*alphaStar;

23 end

1 function [newBeta] = updateBeta(alpha, beta, v, muBeta, sigmaBetaInv)

2 %updateBeta.m

3 %Randomly draws a beta from a prespecified distribution and either

4 %rejects or accepts it with a certain probability. The rejection is based

5 %on the prior distribution, likelihood and proposal distribution. If the

6 %proposed beta is rejected, the original value remains.

7 betaTilde = beta;

8 [muBetaHatTilde, SigmaInvBetaHatTilde] = betaParameters(alpha, betaTilde,v,muBeta,

sigmaBetaInv);

9 SigmaBetaHatTilde = 1 / SigmaInvBetaHatTilde;

10 betaStar = mvnrnd(muBetaHatTilde, SigmaBetaHatTilde)';

11 while any(betaStar <= 0)

12 betaStar = mvnrnd(muBetaHatTilde, SigmaBetaHatTilde)';

13 end

14

15 LogA = logLikelihood(alpha,betaStar,v) - logLikelihood(alpha, betaTilde, v) + ...

16 logPriorBeta(betaStar, muBeta, sigmaBetaInv) - logPriorBeta(betaTilde, muBeta,

sigmaBetaInv) + ...

17 logProposalBeta(betaTilde, alpha, betaStar, v, muBeta, sigmaBetaInv) - ...

18 logProposalBeta(betaStar, alpha, betaTilde, v, muBeta, sigmaBetaInv);

19

20 threshold = log(rand(1));

21 newBeta = (threshold > LogA)*betaTilde + (threshold <= LogA)*betaStar;

22 end

1 function [mu, sigmaInv] = alphaParameters(alpha, beta,v,muAlpha, sigmaAlphaInv)

2 % alphaParameters.m

3 %Returns the mean and inverse variance-covariance matrix for the proposal

4 %function of alpha based on the hyperparameters, parameter estimates and

5 %squared data (i.e. variance).

6 T = length(v);

7 l = ones(T,1);

8 vStar = zeros(T,1);

9

10 for t =2:T

11 l(t) = 1 + beta*l(t-1);

12 vStar(t) = v(t-1) + beta*vStar(t-1);

13 end

14 C = [l, vStar];

15 Lambda = spdiags(2 * variance(alpha, beta, v).ˆ2, 0, T, T);

Page 55: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 6. APPENDIX 50

16 sigmaInv = C'*(Lambda\C) + sigmaAlphaInv;

17 mu = sigmaInv\(C'*(Lambda\v) + sigmaAlphaInv*muAlpha);

18 end

1 function [ mu, sigmaInv] = betaParameters(alpha, beta,v,muBeta, sigmaBetaInv)

2 % betaParameters.m

3 %Returns the mean and inverse variance-covariance matrix for the proposal

4 %function of beta based on the hyperparameters, parameter estimates and

5 %squared data (i.e. variance).

6 T = length(v);

7 z = [v(1) - alpha(1); zeros(T-1,1)];

8 nabla = zeros(T,1);

9 for t =2:T

10 z(t) = v(t) - alpha(1) - (alpha(2)+beta)*v(t-1) + beta*z(t-1);

11 nabla(t) = v(t-1) - z(t-1) + beta*nabla(t-1);

12 end

13 r = z + beta*nabla;

14 Lambda = spdiags(2 * variance(alpha, beta, v).ˆ2, 0, T, T);

15 sigmaInv = nabla'*(Lambda\nabla) + sigmaBetaInv;

16 mu = sigmaInv\(nabla'*(Lambda\r) + sigmaBetaInv*muBeta);

17 end

1 function [h] = variance( alpha, beta, v)

2 %variance.m

3 %returns the estimated condtional variance based on a GARCH(1,1) process

4 %with normal innovations.

5 T = length(v);

6 h = [alpha(1); zeros(T-1,1)];

7

8 for t=2:T

9 h(t) = alpha(1) + alpha(2)*v(t-1) + beta*h(t-1);

10 end

11

12 end

1 function [logL] = logLikelihood(alpha, beta, v)

2 % logLikelihood.m

3 % Estimates the log-likelihood assuming a normal distribution

4 h = variance(alpha,beta,v);

5 logL = -.5*sum(log(h)) - .5*sum(v./h);

6

7 end

1 function [logPrior] = logPriorAlpha(alpha, mu, sigmaInv)

Page 56: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 6. APPENDIX 51

2 % logPriorAlpha.m

3 % Estimates the log-likelihood of the prior distribution of alpha based on

4 % the normal distribution.

5 logPrior = .5*log(det(sigmaInv)) - .5*(alpha - mu)'*sigmaInv*(alpha - mu);

6 end

1 function [logPrior] = logPriorBeta(beta, mu, sigmaInv)

2 % logPriorBeta.m

3 % Estimates the log-likelihood of the prior distribution of beta based on

4 % the normal distribution.

5 logPrior = .5*log(det(sigmaInv)) - .5*(beta - mu)'*sigmaInv*(beta - mu);

6 end

1 function [ logProp ] = logProposalAlpha(x, alpha, beta, v, muAlpha, sigmaAlphaInv)

2 % logProposalAlpha.m

3 % Estimates the log-likelihood of the proposal function of alpha based on a

4 % normal distribution

5 [mu, sigmaInv] = alphaParameters(alpha, beta,v,muAlpha, sigmaAlphaInv);

6 sigma = inv(sigmaInv);

7 logProp = .5*log(det(sigmaInv)) - .5*(x - mu)'*sigmaInv*(x - mu) - ...

8 log(mvncdf([0;0], [Inf; Inf], mu, sigma));

9

10 end

1 function [ logProp ] = logProposalBeta(x, alpha, beta, v, muBeta, sigmaBetaInv)

2 % logProposalBeta.m

3 % Estimates the log-likelihood of the proposal function of beta based on a

4 % normal distribution

5 [mu, sigmaInv] = betaParameters(alpha, beta,v,muBeta, sigmaBetaInv);

6 sigma = inv(sigmaInv);

7 logProp = .5*log(det(sigmaInv)) - .5*(x - mu)'*sigmaInv*(x - mu) - ...

8 log(mvncdf(0, Inf, mu, sigma));

9

10 end

1 function [ logProp ] = logProposalAlpha(x, alpha, beta, v, muAlpha, sigmaAlphaInv)

2 % logProposalAlpha.m

3 % Estimates the log-likelihood of the proposal function of alpha based on a

4 % normal distribution

5 [mu, sigmaInv] = alphaParameters(alpha, beta,v,muAlpha, sigmaAlphaInv);

6 sigma = inv(sigmaInv);

7 logProp = .5*log(det(sigmaInv)) - .5*(x - mu)'*sigmaInv*(x - mu) - ...

8 log(mvncdf([0;0], [Inf; Inf], mu, sigma));

9

Page 57: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 6. APPENDIX 52

10 end

6.2.2 R code

1 ## Clear & Settings

2 rm(list=ls())

3 dev.off()

4 ptm <- proc.time()

5 options(digits=4)

6 dev.off()

7 setwd("C:/Users/nlzeins2/Documents/MSc Thesis/R")

8

9 ## Install Packages

10

11 #install.packages("tseries");

12 #install.packages("coda");

13 #install.packages("fGarch");

14 #install.packages("bayesGARCH");

15 #install.packages("miscTools");

16 #install.packages("~/MSc Thesis/R/bayesDccGarch 1.2.zip", repos = NULL, type = "win

.binary")

17 #install.packages("~/MSc Thesis/R/numDeriv 2014.2-1.zip", repos = NULL, type = "win

.binary")

18

19 require("tseries");

20 require("fGarch");

21 require("fBasics");

22 require("bayesGARCH");

23 require("miscTools");

24 require("rugarch")

25 require("fUnitRoots")

26 require("bayesDccGarch")

27 require("tikzDevice")

28 require("rmgarch")

29 require("readxl")

30 require("VaRES")

31 require("DataCombine")

32 require("rms")

33

34

35

36 ###############

37 ## Functions ##

38 ###############

39 ALS = function(y,tau){40 lengthX = length(y);

41 X = as.vector(rep(1,lengthX));

42 start = mean(y);

Page 58: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 6. APPENDIX 53

43 ALSfunction = function(b,y, X,tau){44 lambda = y - X*b;

45 ALSfunction = sum(abs(as.vector(rep(tau,length(y))) - (lambda < 0))*lambdaˆ2);

46 }47 betaALS = nlm(ALSfunction, start,y, X, tau);

48 return(betaALS$estimate);

49 }50

51 rejectH0 = function(left, right, point){52 reject = (point < left) + (point > right);

53

54 }55

56

57 bern test=function(p,v){58 a=pˆ(sum(v))*(1-p)ˆ(length(v)-sum(v))

59 b=(sum(v)/length(v))ˆ(sum(v))*(1-(sum(v)/length(v)))ˆ(length(v)-sum(v))

60 return(-2*log(a/b))

61 }62

63 zstatistic=function(y, alpha){64 z = alpha*(y >= 0)*y + (1 + alpha)*(y < 0)*y;

65 return(z);

66 }67

68 ttest=function(samplemean, mean, SE){69 t = (samplemean - mean)/SE;

70 return(t);

71 }72

73 VarCovALS = function(stdzdres, bALS){74 u = stdzdres - rep(bALS,(t)) ;

75 w = abs(rep(alphaExpec,(t)) - (u<0)) ;

76 What = mean(w) ;

77 Vhat = mean(wˆ2*uˆ2) ;

78 VarCovALS = Vhat/Whatˆ2 ;

79 return(VarCovALS);

80 }81

82

83 ##################

84 ## S&P 500 Data ##

85 ##################

86 sp500Data = read.csv("sp500.csv")

87 sp500 = rev(sp500Data[,7])

88 sp500r = diff(log(sp500))

89 plot(sp500, main = "S&P 500", ylab = "Prices", xlab = "Trading days", col = "blue"

, type = "l")

Page 59: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 6. APPENDIX 54

90 plot(sp500r, main = "S&P 500", ylab = "Log-returns", xlab = "Trading days", col = "

blue" , type = "l")

91

92

93

94

95 #####################

96 ## Monte Carlo DGP ##

97 #####################

98 t = 2000;

99 l = 0;

100 tT = seq(1:t);

101 tl = t + l;

102

103 a11 = .00001;

104 A11 = .05;

105 B11 = .94;

106 hMLE = matrix(,t,1);

107

108

109 ## Risk Measure statistics

110 alphaVaR = p = .01;

111 alphaES = .025;

112 alphaExpec = .00145;

113

114

115 ## Backtest statistics

116 alphaSign = .050;

117 tleft = qt(alphaSign/2, t - 1);

118 tright = qt(1 - alphaSign/2, t - 1 );

119 ExpecStdNorm = ALS(matrix(rnorm(5000000)), alphaExpec);

120 X = as.vector(rep(1,t));

121

122

123 ## Monte Carlo

124 R = 5000

125 MLEs = matrix(,R,3)

126 tstatVaR = vector(,R);

127 tstatExp = vector(,R);

128 tstatALS = matrix(,R,1);

129 EMtest = matrix(,R,1);

130 pval1 = matrix(,R,1);

131 pval2 = matrix(,R,1);

132

133

134 ## Bootstrap

135 B = 399;

136 randNumbersB = matrix(ceiling(runif(t*B, min = 0, max = t)), ncol = B)

137 tB1 = matrix(,B,1);

Page 60: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 6. APPENDIX 55

138 tB2 = matrix(,B,1);

139

140 ## GARCH(1,1) with normal innovations DGP

141 garchModel = list(omega = a11, alpha = A11, beta = B11 );

142 garchSpec = garchSpec(model = garchModel, cond.dist = c("norm") );

143

144

145 for(r in 1:R){146 dataset = as.vector(garchSim(spec = garchSpec, n = t, n.start = 1, extended = F

));

147 MLEobject = garchFit(formula = ~garch(1,1), data = dataset[1:t], cond.dist = c(

"norm"),

148 include.mean = F, trace = F, leverage = F);

149 MLE = MLEobject@fit$matcoef;

150 MLEs[r,] = c(MLE[1,1], MLE[2,1], MLE[3,1]);

151 hMLE[1] = MLE[1,1]/(1- MLE[2,1] - MLE[3,1]);

152 for (k in 2:t){153 hMLE[k] = MLE[1,1] + MLE[2,1]*dataset[k-1]ˆ2 + MLE[3,1]*hMLE[k-1];

154 }155

156 stdzdres = dataset/sqrt(hMLE);

157

158 ## Value at Risk t-test

159 VaRtt = -qnorm(alphaVaR)*rep(1,t);

160 hitVaRseries = (stdzdres < -VaRtt[(1):t]);

161 tstatVaR[r] = ((sum(hitVaRseries)/(t)) - p)/(sqrt(p*(1-p)/(t)));

162

163

164 ## Expectile T-test

165 Expectt = ExpecStdNorm;

166 y = stdzdres - Expectt;

167 z = zstatistic(y, alphaExpec);

168 lambda = X%*%z/t(X)%*%X;

169 Varlambda = t((z - X*lambda))%*%(z - X*lambda)/(t(X)%*%X);

170 tstatExp[r] = lambda/sqrt(Varlambda/t);

171

172 ## ALS;

173 bALS = ALS(stdzdres,alphaExpec);

174 VarCovA = VarCovALS(stdzdres, bALS);

175 tstatALS[r] = ttest(bALS, ExpecStdNorm,sqrt(VarCovA/(t)));

176

177 ## Engle-Manganelli

178 z1 = c(NA, z[-t]);

179 EMtest[r] = ols(z[2:t] ~ z1[2:t])$stats[2];

180

181 ## Bootstrap FOC and ALS Expectile test

182 for (b in 1:B){183 zboot = zstatistic(y[randNumbersB[,b]], alphaExpec);

184 tB1[b] = ttest(mean(zboot), 0, stdev(zboot)/sqrt(t));

Page 61: Bayesian GARCH Estimation and Expectile Backtesting

CHAPTER 6. APPENDIX 56

185

186 bALSboot = ALS(matrix(stdzdres[randNumbersB[,b]]), alphaExpec);

187 tB2[b] = ttest(bALSboot, Expectt,

188 sqrt(VarCovALS(matrix(stdzdres[randNumbersB[,b]]),bALSboot)/t));

189 }190

191 pval1[r] = 2*min(mean(tB1 < tstatExp[r]), (1-mean(tB1 < tstatExp[r])))

192 pval2[r] = 2*min(mean(tB2 < tstatALS[r]), (1-mean(tB2 < tstatALS[r])))

193 }194

195

196 ## Rejection Frequencies

197 RejFreqttestVaR = sum(rejectH0(tleft, tright, tstatVaR))/R;

198 RejFreqttestExp = sum(rejectH0(tleft, tright, tstatExp))/R;

199 RejFreqALS = sum(rejectH0(tleft, tright, tstatALS))/R;

200 RejFreqEM = sum(rejectH0(0, qf(1-alphaSign, df1 = 1, df2 = t-2), EMtest))/R;

201 RejFreqttestExpBoot = sum(rejectH0(alphaSign, Inf, pval1))/R

202 RejFreqALSBoot = sum(rejectH0(alphaSign, Inf, pval2))/R;

203

204

205

206 ## Plots Value at Risk and Expectile

207 #plot(1:t, dataset[1:t], type = "l", col = "gray75", lwd = 1, xlab = "Time", ylab =

"returns",

208 # ylim=c(min(dataset[1:t]),max(dataset[1:t])))

209 #lines(1:t, -VaRtt[1:t], type = "l", col = "yellow2", lwd = 2)

210 #legend("topright", inset=.05, ,

211 # c("Return","VaR"), fill= c("gray75", "yellow2"), horiz=FALSE)

212 #plot(1:t, dataset[1:t], type = "l", col = "gray75", lwd = 1, xlab = "Time", ylab =

"returns",

213 # main = "returns and Expectile", ylim=c(min(-Expectt),max(Expectt)))

214 #lines(1:t, -Expectt[1:t], type = "l", col = "yellow2", lwd = 2)

215 #legend("topright", inset=.05, ,

216 # c("Return","Expectile"), fill= c("gray75", "yellow2"), horiz=FALSE)