Date post: | 04-Jul-2015 |
Category: |
Technology |
Upload: | paperbags |
View: | 659 times |
Download: | 1 times |
Bayesian Inference on a Stochastic Volatilitymodel Using PMCMC methods
Jonas Hallgren
August 1, 2011
OutlineFinancial Time Series
Model
Parameter Estimation
Bayesian inference
Parameter simulation
Sequential Monte Carlo methods
Sequences
MC-integrals
Particle MCMC
Estimation
Parallel computation
Simulations and results
PMMH vs. Gibbs
Simulating data
Prediction comparison
Financial Time series
2004 2006 2008 20100
2
4
6
8
10
12x 10
9 S&P500 Daily returns
Modeling
We want to model the price of an instrument in order to be ableto:
I Price options
I Evaluate future risks
I Predict future prices
OutlineFinancial Time Series
Model
Parameter Estimation
Bayesian inference
Parameter simulation
Sequential Monte Carlo methods
Sequences
MC-integrals
Particle MCMC
Estimation
Parallel computation
Simulations and results
PMMH vs. Gibbs
Simulating data
Prediction comparison
LogreturnsSk = log( Sk
Sk−1)
−4 −2 0 2 40
50
100
150
200
250Histogram of 40 years S&P 500 logreturn
1980 2000−4
−2
0
2
4logreturns
year
−3 −2 −1 0 1 2 3
0.0010.003
0.010.020.050.100.250.500.750.900.950.980.99
0.9970.999
Data
Pro
babi
lity
Normal Probability Plot
Model proposal
Yk = βe12Xkuk =
√hkuk
Xk = αXk−1 + σwk = log h2k + b, b , −2 log β
(uk ,wk) ∼ N (0,Σ)
Σ =
[1 ρρ 1
]When ρ = 0, VYk = hk
OutlineFinancial Time Series
Model
Parameter Estimation
Bayesian inference
Parameter simulation
Sequential Monte Carlo methods
Sequences
MC-integrals
Particle MCMC
Estimation
Parallel computation
Simulations and results
PMMH vs. Gibbs
Simulating data
Prediction comparison
Estimation
Bayesian inference, view the parameter as a random variable:
Observation:Y ∼ p(y |θ), θ ∈ Θ
Parameter posterior distribution:
π(θ|y) =p(y |θ)π(θ)´
Θ p(y |ξ)π(dξ)∝ p(y |θ)π(θ)
p(β|α, σ, ρ, x0:n, y0:n) ∝ p(β, α, σ, ρ, x0:n, y0:n)
= p(x0:n, y0:n|β, α, ρ, σ)p(β)p(. . .)
Prior selection
p(β|α, σ, ρ, x0:n, y0:n) ∝ 1
β2p(x0:n, y0:n| . . .)
p(α|β, σ, ρ, x0:n, y0:n) ∝ (α + 1)δ−1 (1− α)γ−1 p(x0:n, y0:n| . . .)
p(ρ|β, α, σ, x0:n, y0:n) ∝ 1
2p(x0:n, y0:n| . . .)
p(σ|β, α, ρ, x0:n, y0:n) ∝ 1
σ2σ2(t/2−1)e−
12σ2 S0p(x0:n, y0:n| . . .)
p(x , y) =
exp
− 12(1−ρ2)
( y
βe12 x
)2
+(
x−αxk−1σ
)2−2ρ
y(x−αxk−1)
σβe12 x
− 12x
|β|σ2π
√1−ρ2
OutlineFinancial Time Series
Model
Parameter Estimation
Bayesian inference
Parameter simulation
Sequential Monte Carlo methods
Sequences
MC-integrals
Particle MCMC
Estimation
Parallel computation
Simulations and results
PMMH vs. Gibbs
Simulating data
Prediction comparison
Gibbs sampler
1. For the first iteration we choose ξ0 = {X (0)0:n , θ
(0)}, arbitrarily
2. For k = 1, 2, . . ., draw random samples
2.1 x(k)0:n ∼ pX (·|θ(k−1), y0:n)
2.2 θ(k)1 ∼ pX (·|x (k)
0:n , θ(k−1), y0:n)
...2.3 θ
(k)D ∼ pX (·|x (k)
0:n , θ(k)1 , . . . , θ
(k−1)D , y0:n)
New problem: How do we sample θ and x?
Metropolis-Hastings sampler
Choose θ0 arbitrarily then for k = 0, ...,N
1. Simulate θ∗ ∼ q(·, θk−1)
2. with probability
1 ∧ p(θ∗)q(θ∗, θk)
p(θk)q(θk , θ∗)
set θk+1 = θ∗, otherwise set θk+1 = θk .
OutlineFinancial Time Series
Model
Parameter Estimation
Bayesian inference
Parameter simulation
Sequential Monte Carlo methods
Sequences
MC-integrals
Particle MCMC
Estimation
Parallel computation
Simulations and results
PMMH vs. Gibbs
Simulating data
Prediction comparison
SMC
φk , p(xk |y0:k)
Propose:
φk(ξ̃) =
´lk−1(ξ, ξ̃)φk−1(ξ)dξ´
φk−1(ξ)´lk−1(ξ, ξ̃)d ξ̃dξ
Our model
In our setting:
φk+1 = p(xk+1, y0:k+1)/p(y0:k+1)
∝ˆ
p(yk+1|xk+1, xk , y0:k)p(xk+1|xk , y0:k)p(xk , y0:k)dxk
=
ˆp(yk+1|xk:k+1)p(xk+1|xk)p(xk |y0:k)p(y0:k)dxk
=
ˆp(yk+1|xk:k+1)p(xk+1|xk)φkp(y0:k)dxk
=
ˆG (yk+1, xk:k+1)Q(xk+1|xk)φkp(y0:k)dxk
Summarized
Filter:
φk+1 =
´G (yk+1, xk:k+1)Q(xk+1, xk)φk|kdxk´ ´
G (yk+1, xk:k+1)Q(xk+1, xk)φk|kdxkdxk+1
Smoother:
φ0:k+1|k+1 =
´G (yk+1, xk:k+1)Q(xk+1, xk)φ0:k|kdx0:k´ ´
G (yk+1, xk:k+1)Q(xk+1, xk)φ0:k|kdx0:kdx0:k+1
OutlineFinancial Time Series
Model
Parameter Estimation
Bayesian inference
Parameter simulation
Sequential Monte Carlo methods
Sequences
MC-integrals
Particle MCMC
Estimation
Parallel computation
Simulations and results
PMMH vs. Gibbs
Simulating data
Prediction comparison
Monte Carlo Integration
We want to evaluate:
µ(f ) =
ˆf (x)
dµ
dν(x)ν(dx)
We use the estimate:
N−1N∑i=1
f (ξi )dµ
dν(ξi )
a.s.−−−−→N→∞
µ(f )
Sequential Importance Sampling
1. Sampling: for k = 0, 1, . . .
2. Draw ξ̃1k+1, . . . , ξ̃
Nk+1|ξ̃1
0:k , . . . , ξ̃N0:k
2.1 Compute the importance weights
ωik+1 = ωi
kgk+1(ξ̃ik+1)
3. Resampling:
3.1 Draw N particles from the with the probability of success being
the normalized weightsωi
k+1∑Ns ωs
k+1
.
4. Update the trajectory: Copy the resampled particlestrajectories and replace the ones that we did not use.
Example
0 50 100 150 200−1
−0.5
0
0.5
1
1.5
Xk
k
Degeneracy
0 50 100 150 200−1
−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
0.8
1
k
Xk
True XParticle trajectories
Recap
I Object: Model the price
I Need parameters
I Need X trajectories
Which we now have!
Yk = βe12Xkuk =
√hkuk
Xk = αXk−1 + σwk = log h2k + b, b , −2 log β
(uk ,wk) ∼ N (0,Σ)
Σ =
[1 ρρ 1
]
Gibbs sampler
1. For the first iteration we choose ξ0 = {X (0)0:n , θ
(0)}, arbitrarily
2. For k = 1, 2, . . ., draw random samples
2.1 x(k)0:n ∼ pX (·|θ(k−1), y0:n)
2.2 θ(k)1 ∼ pX (·|x (k)
0:n , θ(k−1), y0:n)
...2.3 θ
(k)D ∼ pX (·|x (k)
0:n , θ(k)1 , . . . , θ
(k−1)D , y0:n)
OutlineFinancial Time Series
Model
Parameter Estimation
Bayesian inference
Parameter simulation
Sequential Monte Carlo methods
Sequences
MC-integrals
Particle MCMC
Estimation
Parallel computation
Simulations and results
PMMH vs. Gibbs
Simulating data
Prediction comparison
Particle MMHStep 1: initialization, i = 0
(a) set θ0 arbitrarily
(b) run a SMC algorithm targeting pθ(0)(x1:T , |y1:T ), sample our
first trajectory of particles ξ̃(0)1:T ∼ p̂θ(0)(·|y1:T ) and denote the
marginal likelihood by p̂θ0(y1:T )
Step 2: for iteration i ≥ 1,
(a) sample θ∗ ∼ q(·|θi−1)
(b) run a SMC algorithm targeting pθ∗(x1:T , |y1:T ), sample ourtrajectory of particles ξ̃∗1:T ∼ p̂θ∗(·|y1:T ) and denote the marginallikelihood by p̂θ∗(y1:T )
(c) with probability
1 ∧ p̂θ∗(y1:T )p(θ∗)
p̂θi−1(y1:T )pθi−1
q(θi−1|θ∗)q(θ∗|θi−1)
put θi = θ∗, ξ(i)1:T = ξ∗1:T and pθi (y1:T ) = pθ∗(y1:T )
OutlineFinancial Time Series
Model
Parameter Estimation
Bayesian inference
Parameter simulation
Sequential Monte Carlo methods
Sequences
MC-integrals
Particle MCMC
Estimation
Parallel computation
Simulations and results
PMMH vs. Gibbs
Simulating data
Prediction comparison
UPPMMH
1. For t = 0, Choose τ1:C1:N arbitrarily (preferably through an
PMMH-sampler)
2. For t = 1, 2, ...,M
2.1 Simulation step, takes time but does not decrease efficiency asC increases: For γ = 1, 2, . . . ,C
2.1.1 Sample τγNt∼ rγ1:N·t(y , τ
γt·N)
2.2 Merging step, assumed to take zero time to compute: Samplea multidimensional, multinomial variable A1:C
t taking values in1, . . . ,C with equal probability.
2.3 for γ = 1, 2 . . . ,C
2.3.1 put τγ1:N·t = τAγt
1:N·t
3. Sample a multinomial variable Aoutt taking values in 1, . . . ,C
with equal probability and put τout1:K = τAoutt
1:K
PRPMMH
1. For t = 0, Choose τ1:C1:N arbitrarily (preferably through an
PMMH-sampler)
2. For t = 1, 2, ...,M
2.1 For γ = 1, 2, . . . ,C
2.1.1 Sample (ωγ , τγNt) ∼ rγ1:N·t(y , τ
γt·N)
2.2 Normalize weights and resample
2.2.1 For γ = 1, 2, . . . ,C put ω̄(γ) = ω(γ)∑j ω
(j)
2.2.2 Sample a multidimensional, multinomial variable A1:Ct taking
values in 1, . . . ,C with probability (ω̄(1), ω̄(2), . . . , ω̄(M))
2.3 for γ = 1, 2 . . . ,C
2.3.1 put τγ1:N·t = (τAγt
1:N·t , τAγt
Nt)
3. Sample a multinomial variable Aoutt taking values in 1, . . . ,C
with equal probability and put τout1:K = τAoutt
1:K
ImplementationX0 = randn(C,T); theta0 = randn(C,n_theta);
X(:,1) = X0; theta(:,1) = theta0;
for t = 2:M
% Simulationstep
parfor gamma = 2:C % Parallell for-loop
[X(gamma,Nt) theta(gamma,Nt) omega(gamma)] ...
= PMMH_SAMPLER(X(gamma,t), theta(gamma,t), N);
end
% Mergestep
A = randsample(1:C, C, true, omega/sum(omega))
X(:,1:N*t) = X(A,1:N*t);
theta(:,1:t) = theta(A,1:t);
end
A_out = randsample(1:C,1)
tau_out = [X(A_out,:); theta(A_out,:)];
OutlineFinancial Time Series
Model
Parameter Estimation
Bayesian inference
Parameter simulation
Sequential Monte Carlo methods
Sequences
MC-integrals
Particle MCMC
Estimation
Parallel computation
Simulations and results
PMMH vs. Gibbs
Simulating data
Prediction comparison
Gibbs
0 0.5 10
1000
2000
3000
4000
α0.4 0.6 0.8 10
2000
4000
6000
β
−1 −0.5 0 0.5 10
1000
2000
3000
ρ0 0.1 0.2 0.3 0.4
0
2000
4000
6000
σ
PMMH
0 0.5 10
1000
2000
3000
4000
α0 0.5 1
0
2000
4000
6000
8000
10000
β
−1 −0.5 0 0.5 10
1000
2000
3000
ρ0 0.2 0.4 0.6 0.8
0
2000
4000
6000
σ
OutlineFinancial Time Series
Model
Parameter Estimation
Bayesian inference
Parameter simulation
Sequential Monte Carlo methods
Sequences
MC-integrals
Particle MCMC
Estimation
Parallel computation
Simulations and results
PMMH vs. Gibbs
Simulating data
Prediction comparison
S&P500
0 10 20 30 40 50 60 70 80 90 100−1
−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
0.8
1
SimulatedReal
Risk measure comparison
VaR and ES answers two questions:
1. VaR: At least how large will a tail event that occurs withsome specific probability occur?
2. Given such a tail event, how large do we expect the loss tobe? Expressed in mathematical terms: ES , EY · IY<VaR
Model VaR ES
Empirical −0.2581 −0.3766
SVOL −0.2781 − 0.2772 −0.3561 − 0.3550
SVOLρ=0 −0.2735 − 0.2728 −0.3484 − 0.3474
OutlineFinancial Time Series
Model
Parameter Estimation
Bayesian inference
Parameter simulation
Sequential Monte Carlo methods
Sequences
MC-integrals
Particle MCMC
Estimation
Parallel computation
Simulations and results
PMMH vs. Gibbs
Simulating data
Prediction comparison
Prediction results
Dataset ModelRMSE(10−3)
MAE(10−3)
Qr PPV
GBP/USD SVOL 11.706 8.417 0.1753 0.55
GBP/USD SVOLρ=0 11.714 8.420 ∼ ∼GBP/USD Long 11.714 8.421 −0.2821 ∼
BIDU SVOL 20.188 15.503 0.1302 0.53
BIDU SVOLρ=0 20.232 15.535 ∼ ∼BIDU Long 20.231 15.531 −0.3031 ∼
S&P500 SVOL 252.94 175.72 0.0825 0.52
S&P500 SVOLρ=0 252.93 175.78 ∼ ∼S&P500 Long 252.93 175.80 −0.4821 ∼S&P500 Longµ 252.91 175.72 ∼ ∼
XBC/USD SVOL 5.5762 3.1417 0.2621 0.35
XBC/USD SVOLρ=0 5.5908 3.1347 ∼ ∼XBC/USD Long 5.5920 3.1323 −0.0477 ∼
Conclusions
I PMMH is nice.
I Correlation is relevant in price behavior.
I Predict risk, perhaps not price.
The End
Questions?