Sale!

MTH 4600 Homework 6 Volatility Estimation Via Hidden Markov Chain solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (8 votes)

The file XOM5YrsDaily.txt contains daily returns in percent for Exxon Mobil
over the five year (1258 trading day) period 1/3/2012 – 12/30/2016. In this
project you will estimate historical XOM price volatility over this period using a
hidden Markov chain approach. The underlying (imperfectly observed) Markov
chain is XOM’s time-dependent volatility, σt. We assume it is undergoing an
exponentiated random walk: σt = σ0 exp(αWt). Here 0 ≤ t ≤ 1258 is elapsed
time in days and (Wt : 0 ≤ t ≤ 1258) is a simple symmetric random walk on Z
starting at W0 = 0. The volatility process is not observed but we do observe a
realization of XOM’s daily returns (Rt), where Rt ∼ Normal (0, σ2
t
). Call this
realization (rt : 1 ≤ t ≤ 1258).
Preliminaries. Let us label the states of the MC according to the value of the
random walk, so S = {k : −1258 ≤ k ≤ 1258}. Note that at time t the only
states with positive probability are
St = {k : −t ≤ k ≤ t in steps of 2},
e.g., S2 = {−2, 0, 2}. For k ∈ St, let sk = σ0 exp(αk), the daily volatility when
the walk is in state k. Let Dt be the return data up to and including time t:
Dt = {R1 = r1, . . . , Rt = rt} = Dt−1 ∩ {Rt = rt},
with D0 = Ω (the entire sample space). For any events E and D, let PD[E] =
P[E | D] so, e.g., PD0
[E] = P[E | Ω] = P[E].
Estimating Volatility. To estimate the volatility for day t we may legitimately
only use the data Dt−1. Suppose that, with our Bayesian prowess, we have
calculated the numbers pk = PDt−1
[Wt−1 = k] for k ∈ St−1. (We have this for
t = 1, where p0 = 1 as W0 = 0.) Since from time t − 1 to time t the walk either
goes up one or down one, we get that the conditional distribution of the location
of the walk at time t given the data Dt−1 is given by
PDt−1
[Wt = k] = PDt−1
[Wt−1 = k − 1] ·
1
2
+ PDt−1
[Wt−1 = k + 1] ·
1
2
=
pk−1 + pk+1
2
. (∗)
Using MAP estimation, put ˆk = argmax (PDt−1
[Wt = k]), and take ˆσt = skˆ.
Bayesian Updating. Next we seek to update the pks, which reflect data
through time t − 1, to reflect the data at time t. To this end, for k ∈ St,
put
pek = PDt
[Wt = k] = PDt−1
[Wt = k | Rt = rt]
= PDt−1
[Rt = rt | Wt = k] ·
PDt−1
[Wt = k]
PDt−1
[Rt = rt]
.
2
We first calculate
gk = PDt−1
[Rt = rt | Wt = k] · PDt−1
[Wt = k],
as described below, then let Z = PDt−1
[Rt = rt] = P
k
gk and put each
pek = gk/Z.
Now PDt−1
[Wt = k] is given by (∗), and given {Wt = k} we have σt = sk and
hence Rt ∼ Normal (0, s2
k
). Then we have
PDt−1
[Rt = rt | Wt = k] = 1

2πsk
exp(−r
2
t /2s
2
k
).
(This is a density rather than a probability, but it gives the right answer; why?)
The numbers pek then become the new pk when we advance to updating for the
data at time t+ 1. In this manner we may compute the numbers (pk : k ∈ St−1)
for t = 1, then 2, then 3, and do forth to 1258.
Your mission is to implement this model. The model has two free parameters, σ0 and α, which must be estimated using the data. I have done that for you
— take σ0 = 0.25 and α = 0.03. The code HiddenMC.cpp will get you started.
As it stands, this code reads in the time series (rt : 1 ≤ t ≤ 1258) from the
data file XOM5YrsDaily.txt. Generate a (normal) histogram of the standardized returns rt/σˆt and a time series showing the annualized volatility √
252ˆσt
over time. Compare your results to the “EWMA” approach from Chapter 16.