CS计算机代考程序代写 chain Bayesian algorithm Markov Chain Monte Carlo for inference on assets

Markov Chain Monte Carlo for inference on assets

Dr. Tanut Treetanthiploet

October 31, 2021

This exercises will describe how we can use the Markov Monte Carlo Method as a Bayesian inference
for stock dynamic using historical data.

1 Convergence of Markov chain

The necessary background for the Markov chain is given below. If you are not familiar with the idea
of Markov chain, you should first study the Markov chain with the discrete time and space in [3] as an
introduction (You may also study [2] for an advance discussion). The main result from Markov chain that
will be used is given in Theorem 1.3. Some discussion and verification regarding the Gibbs sampling may
be found in [5].

Definition 1.1. 1 Let (X(n))n2N be a sequence of random variable taking values in Rd. We say (X(n)) is
a Markov chain if the distribution of X(n+1) depends only on X(n). In particular, for any (Borel) set A,

P(X(n+1) 2 A|X(n) = x(n), …, X(1) = x(1)) = P(X(n+1) 2 A|X(n) = x(n)).

We call P (x,A) := P(X(n+1) 2 A|X(n) = x), the transition kernel of the Markov chain (X(n)).

For simplicity of our discussion, we shall assume that P (x,A) =
R
y2A �(x, y)dy. Given the transition

kernel in this form, we can compute the conditional expectation of f(X(n+1)) given that X(n) by

E[f(X(n+1))|X(n) = x] =
Z

Rd
f(y)�(x, y)dy.

Definition 1.2. We say the distribution ⇡ is an invariant distribution of a transition kernel P if (X(n))
is a Markov chain with a transition kernel P then X(n) ⇠ ⇡ implies X(n+1) ⇠ ⇡ for all n 2 N.

In particular, if ⇡ has a density � (i.e. ⇡(A) =
R
A
�(x)dx), then ⇡ is an invariant distribution if

Z

Rd
�(x)�(x, y)dx = �(y).

Theorem 1.3. Let X(n) be a Markov chain with transition kernel P (x,A) =
R
y2A �(x, y)dy such that �

is continuous and �(x, y) > 0 for all x, y 2 Rd and X(0) = x(0). Let ⇡ be an invariant distribution of the
transition kernel P . Suppose that ⇡ has a continuous density � where �(x) > 0 for all x 2 Rd.

Then for any function f : Rd ! R such that
R
Rd |f(y)|�(y)dy < 1, we have that 1 N NX n=1 f(X(n)) ! Z Rd f(y)�(y)dy almost surely. 1We give a definition for the Markov chain on the uncountable state space which is slightly more general than what is discussed in [3], but the analogy is similar. 1 ⼀ 2 Gibbs Sampling We will now discuss Gibbs Sampling method and we will use it to obtain statistical estimate of param- eters under Bayesian inference. You may also study [1] or [4] for further discussion and directions. Suppose that we have a distribution ⇡ on Rd where we cannot directly take a sample from. However, it is possible to take a sample from its conditional distribution, i.e., it is possible to obtain a sample from ⇡(xk|x1, ..., xk�1, xk+1, ..., xd) for all k = 1, 2, ..., d. We construct a Markov chain (X(n)) as follows : given X(n), X(n+1) is obtained by • X(n+1)1 ⇠ ⇡( · |X (n) 2 , X (n) 3 , X (n) 4 , ..., X (n) d ) • X(n+1)2 ⇠ ⇡( · |X (n+1) 1 , X (n) 3 , X (n) 4 , ..., X (n) d ) • X(n+1)3 ⇠ ⇡( · |X (n+1) 1 , X (n+1) 2 , X (n) 4 , ..., X (n) d ) • · · · • X(n+1)d ⇠ ⇡( · |X (n+1) 1 , X (n+1) 2 , X (n+1) 3 , ..., X (n+1) d�1 ). Theorem 2.1. Suppose that ⇡ has a density �. Then ⇡ is the invariant distribution of the Markov chain defined by the procedure above. Proof. Recall that for Z ⇠ ⇡, the conditional density function of Zk given Z1 = z1, ..., Zk�1 = zk�1, Zk+1 = zk+1, ..., Zd = zd is given by �k(zk|z1, ...., zk�1, zk+1, ..., zd) = �(z1, z2, ..., zd)R R �(z1, ...., zk�1, z, zk+1, ..., zd)dz . We now obtain Z Rd �(x)�(x, y)dx = Z Rd �(x1, x2, ..., xd) dY k=1 �k(yk|y1, ..., yk�1, xk+1, ..., xd)dx1...dxd = Z Rd �(x1, x2, ..., xd)�1(y1|x2, x3, ..., xd) dY k=2 �k(yk|y1, ..., yk�1, xk+1, ..., xd)dx1...dxd = Z Rd�1 ⇣Z R �(x1, x2, ..., xd)dx1 ⌘✓ �(y1, x2, x3, ..., xd)R R �(z, x2, x3, ..., xd)dz ◆ dY k=2 �k(yk|y1, ..., yk�1, xk+1, ..., xd)dx2...dxd = Z Rd�1 �(y1, x2, x3, ..., xd) dY k=2 �k(yk|y1, ..., yk�1, xk+1, ..., xd)dx2...dxd = Z Rd�2 ⇣Z R �(y1, x2, ..., xd)dx2 ⌘✓ �(y1, y2, x3, ..., xd)R R �(y1, z, x3, ..., xd)dz ◆ dY k=3 �k(yk|y1, ..., yk�1, xk+1, ..., xd)dx3...dxd = Z Rd�2 �(y1, y2, x3, ..., xd) dY k=3 �k(yk|y1, ..., yk�1, xk+1, ..., xd)dx3...dxd = ... = �(y1, y2, ..., yd). Therefore, ⇡ is an invariant distribution of the Markov chain given by the above procedure. 3 Exercises Your report and presentation on this topic should begin by a brief introduction on the ideas of Markov Chain (either with discrete space or continuous space) and Monte Carlo Simulation. You should then give a brief description how we can combine those two ideas and proceed to answer the following exercises. You shall request the data for simulation by e-mailing me at .uk. 2 Suppose that there are d available assets. Given the parameter (µk,� 2), the return of the kth asset follows the Black–Scholes model dSk(t) = � µk + � 2/2 � Sk(t)dt+ �Sk(t)dWk(t) (3.1) where � Wk(t) � t2[0,⌧ ] is a Brownian motion which are independent for each k. Define the log (base e) of the ratio of our asset price by Zk,m = log ⇣ Sk(mh) Sk � (m� 1)h � ⌘ : m = 1, 2, ...,M and h = ⌧/M. Exercise 1: Conditional on (µk,� 2), show that (Zk,m)m=1,...,M is a sequence of independent random variables with mean µk and variance � 2. Identify the distribution of Zk,m. We will consider parameters (µ1, µ2, ..., µd,� 2) from Bayesian perspective and assume that the prior of the parameters are given by µk ⇠IID N(✓, ⌘2), ✓ ⇠ N(�, ⇢2) and ��2 ⇠ �(↵,�)2 (3.2) where �, ⇢2, ⌘2,↵ and � are known parameter. In particular, under this model, we assume that all assets have the same volatility � but they may have the di↵erent drift µk. These drifts are sampled with the mean ✓. The parameter ✓ may interpreted as a movement of assets overall. Denote Z := (Zk,t : k = 1, ..., d and m = 1, ...,M). Exercise 2: Express the joint density function of (µ1, µ2, ..., µd, ✓,� �2,Z). Are µ1, ...., µd independent conditional on the historical observation Z, the hyper-parameter ✓ and the precision ��2? Are µ1, ...., µd independent conditional on the historical observation Z? Exercise 3: Find the following conditional distribution: (a) µk|(µ1, ..., µk�1, µk+1, ..., µk, ✓,��2,Z) for each k = 1, ..., d. (b) ��2|(µ1, µ2..., µd, ✓,Z) (c) ✓|(µ1, µ2..., µd,��2,Z) Express your expression for Z in terms of PM m=1 Zk,m and PM m=1 Z 2 k,m. Exercise 4: Take � = 0, ⇢2 = 1, ⌘2 = 8⇥ 10�7,↵ = 0.1,� = 0.1 as known. The provided data is obtained with h = 1 and ⌧ = 100. (You will be given 101 days for the opening price of 27 assets.). By considering (µ1, µ2, ..., µd, ✓,� 2) as a sample from the posterior density in the earlier exercise, use the Gibbs sampling method and programming of your choice to find an estimate parameter (µ1, µ2, ..., µd, ✓,� 2). You may also provide some histograms or some plots to describe accuracy of your estimate. Exercise 5: Describe how to estimate P(✓ > 0|Z), P(µk > ✓|Z) and P(µk > maxi 6=k µi|Z) for each
k = 1, …, d. Write a code to evaluate those quantities. What is the trend of the market overall? Which
assets would you like or do not like to hold? Justify your answers.

Exercise 6: Estimate the expected return of the digital put option with payo↵

I

Sk(T )  K


=

(
1 : Sk(T )  K
0 : Sk(T ) > K

at time T = 150 for your chosen asset and chosen strike price.
(Hint: Use historical observation upto time ⌧ to estimate µk and �. Then treat ⌧ as our initial time

and see T � ⌧ as our maturity time. Note: You are asking to estimate the expected return not the price of
this digital option.)

2The Gamma distribution �(↵,�) has density p(z) = �↵z↵�1 exp(��z)/�(↵) for z > 0 where �(↵) =
R1
0

z↵�1 exp(�z)dz.

3

Exercise 7: Instead of parameterise drifts and volatility of the Black–Scholes dynamic by (3.1), we
assume that the asset price follows

dSk(t) = µkSk(t)dt+ �Sk(t)dWk(t) (3.3)

but the prior of µk and �
�2 still follows (3.2). Describe how could you perform earlier analysis.

(Hint: What is the conditional posterior distribution of ��2? You are expected to study further Markov
Chain Monte Carlo algorithm (e.g. in [1] or [4]) and find how could you obtain a sample when we only have
a density of a form �(z) = �̃(z)/c where the constant c is not know. You should present this algorithm
with clear explanation.)

References

[1] M. B. Haugh. A Tutorial on Markov Chain Monte-Carlo and Bayesian Modeling. Available at SSRN:
https://ssrn.com/abstract=3759243.

[2] S. Meyn and R. L. Tweedie. Markov Chains and Stochastic Stability. Cambridge University Press, 2009.

[3] J. R. Norris. Markov Chains. Cambridge University Press, 1997.

[4] P. Rebeschini. Advanced simulation methods. 2018.

[5] G.O. Roberts and A.F.M. Smith. Simple conditions for the convergence of the Gibbs sampler and
Metropolis-Hastings algorithms. Stochastic Processes and their Applications, 1994.

4