Sunteți pe pagina 1din 5

useR!

2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Sequential Monte Carlo Methods
in R
Thomas Jakobsen
Jeffrey Todd Lins
Saxo Bank A/S
jtl@saxobank.com, tj@saxobank.com
www.saxobank.com
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Overview
The model
An introduction to sequential Monte Carlo methods
Algorithm & implementation
A factor stochastic volatility model
Example, artificial 2-factor model
Analysis of forex data
Conclusions
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
The Model
Markovian, nonlinear, non-Gaussian state-space model:
Described by
Observations arrive sequentially and are noisy.
Problem statement:
Estimate recursively in time the posterior distribution p(x|y,). (tracking the state)
Additionally: Estimate .
0
x
1
x 1 t
x
t
x

X: Unobserved variables
Y: Observations
: Parameters
0
y
1
y 1 t
y
t
y

model nal Observatio 1 for ) , | (


model space state Markovian 1 for ) , | (
on distributi state Prior ) (
1
0

t x y p
t x x p
x p
t t
t t
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Sequential Monte Carlo Methods
Useful when a (partially observed) state needs to be
tracked or forecasted:
Tracking problems (robots, vision, radar etc.)
Time series analysis (economical/financial data etc.)
General online inference
Sequential Monte Carlo methods are algorithms for
inference in hidden state space models.
Also known as particle filters, condensation, sampling
importance resampling etc.
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Sequential Monte Carlo Methods
SMC methods: Basically a nonlinear, non-Gaussian
version of the Kalman filter (but approximate not
closed form)
The posterior at time t-1 is represented by a set of
weighted particles. The particles are drawn i.i.d. and
recursively updated.
Next slide: Illustration of update
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
A bootstrap approach (from [1])
Unweighted measure
Compute importance
weights using info at time t-1
Weighted measure
Resampling
Prediction
Apprx. of p(x_t|y_1:t-1)
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Comb. Parameter and State Estimation
Often the parameters are known (or obtained through
separate analysis).
However: If parameters are unknown, how to carry out
combined estimation of x and ?
Liu & West describe a simple approach.
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Algorithm
Liu & West, Combined Parameter and State Estimation:
(auxiliary particle filter with state estimation)
) ( ) (
) ( (j)
t
) ( ) (
1 1
) (
1
) (
1 1 ) (
1
) (
1
) ( ) (
2 ) ( ) (
1
) ( ) (
1 1
) ( ) (
1
) ( ) (
1
) (
1
) ( ) ( ) (
weights and from matrix variance and mean Posterior : ,
) 1 ( m
accurate. ly sufficient is ion approximat until 5. - 2. Repeat
) , | (
) , | (
: weight Evaluate . 5
). , | ( ~ Sample . 4
). , | ( ~ Sample . 3
) , | (
y probabilit with N} {1,..., integer an Sample 2.
) , | ( : ,..., 1 For 1.
. ,..., 1 , weights and ) , ( sample Carlo Monte : Input
j
t
j
t t t
t
j
t
k
t
k
t t
k
t
k
t t k
t
k
t
k
t
k
t
t
k
t
k
t
j
t
j
t t
j
t
j
t
j
t
j
t t
j
t
j
t
j
t
j
t
w V
a a
m y p
x y p
w
x p x
V h m N
m y p w g
k
x x E N j
N j w x

+ =


= =
=
+ +
+ + +
+
+
+
+ + +
+ +

useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
R Implementation
To describe the model, the user supplies his own
functions as arguments to main SMC function (together
with Y and [hyper]parameters).
R language very suitable for implementation,
especially because of
Vectorization
Built-in statistical functions
The possibility of supplying user-defined functions as arguments
Ease of visualization and interaction
Quite efficient but still computationally heavy.
For large datasets, a C/C++ optimization is needed
(we already developed a faster C# version).
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Factor Stochastic Volatility Model
(similar to the model of Liu & West)
) ,..., diag(
variances noise tic Idiosyncra ) | ( ~
matrix variance s Innovation
s Innovation ) | ( ~
iances factor var Log ) (
) exp(
iances Factor var ) , , ( diag
Factors ) , 0 | ( ~
matrix loadings Factor
level series Local
ns Observatio
1
1
1
k
t
t t t
ti ti
tk t t
t t
t
t t t t
N
N
h
h h
N
y
=

+ + =
=
=

+ + =

0,
U
U 0,

H
H f
X

Xf
t

useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Example, artificial 2-factor model
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Example, artificial 2-factor model
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Example, FX data
Model exchange rates with a factor stochastic volatility
model.
Per-minute data
EURUSD, GBPUSD, JPYUSD, CHFUSD.
The log return for currency i on day t is given by
where s is the spot rate in US dollars.
) log(
, 1i t
ti
ti
s
s
y

=
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
FX data, example
Spot rates. 434 bank days of data. Index 1.0 at 2004-10-01.
EURUSD
GBPUSD
JPYUSD
CHFUSD
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
FX data, example
Log return, log (s(t)/s(t-1)) (50 data points)
EURUSD
GBPUSD
JPYUSD
CHFUSD
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
FX data, results
Volatility factor 1
Log returns
Volatility factor 2
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Conclusion
R is flexible and powerful enough for implementing
efficient particle filters
For large datasets, however, an optimized C/C++
version is really needed (because of the heavy
computational burden).
Combined parameter and state estimation can be useful
but also unstable when there are too many parameters
Alternative: Do separate/offline estimation of parameters (using,
e.g., full MCMC)
Package may be forthcoming
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
References
[1] A. Doucet, N. de Freitas and N. Gordon, editors,
Sequential Monte Carlo Methods in Practice, Springer,
2001.
[2] Liu and West: Combined Parameter and State
Estimation in Simulation-Based Filtering, pp. 197-223, in
[1].
useR! 2006
Vienna, June 15-17, 2006
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
Questions?
Thanks for your attention.
Emails:
jtl@saxobank.com
tj@saxobank.com
Web site:
www.saxobank.com

S-ar putea să vă placă și