jakobsen+lins (1)

Upload: nguyentai325

Post on 02-Jun-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 Jakobsen+Lins (1)

    1/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

    [email protected], [email protected]

    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.

    0x 1x 1tx tx X: Unobserved variables

    Y: Observations: Parameters

    0y 1y 1ty ty

    modelnalObservatio1for),|(

    modelspacestateMarkovian1for),|(

    ondistributistatePrior)(

    1

    0

    txyp

    txxp

    xp

    tt

    tt

    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 betracked or forecasted:

    Tracking problems (robots, vision, radar etc.) Time series analysis (economical/financial data etc.)

    General online inference

    Sequential Monte Carlo methods are algorithms forinference in hidden state space models.

    Also known as particle filters, condensation, samplingimportance resampling etc.

  • 8/11/2019 Jakobsen+Lins (1)

    2/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

    SMC methods: Basically a nonlinear, non-Gaussianversion of the Kalman filter (but approximate notclosed form)

    The posterior at time t-1 is represented by a set ofweighted particles. The particles are drawn i.i.d. andrecursively 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 throughseparate analysis).

    However: If parameters are unknown, how to carry outcombined 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

    Algori thm Liu & West, Combined Parameter and State Estimation:

    (auxiliary particle filter with state estimation)

    )()(

    )((j)

    t

    )()(11

    )(1

    )(11)(

    1

    )(1

    )()(

    2)()(1

    )()(11

    )()(1

    )()(1

    )(1

    )()()(

    weightsandfrommatrixvarianceandmeanPosterior:,)1(m

    accurate.lysufficientisionapproximatuntil5.-2.Repeat

    ),|(

    ),|(:weightEvaluate.5

    ).,|(~Sample.4

    ).,|(~Sample.3

    ),|(

    yprobabilitwithN}{1,...,integeranSample2.

    ),|(:,...,1For1.

    .,...,1,weightsand),(sampleCarloMonte:Input

    j

    t

    j

    ttt

    t

    j

    t

    k

    t

    k

    tt

    k

    t

    k

    ttk

    t

    k

    t

    k

    t

    k

    t

    t

    k

    t

    k

    t

    j

    t

    j

    tt

    j

    t

    j

    t

    j

    t

    j

    tt

    j

    t

    j

    t

    j

    t

    j

    t

    wVaa

    myp

    xypw

    xpx

    VhmN

    mypwg

    k

    xxENj

    Njwx

    +=

    ==

    =

    ++

    +++

    +

    +

    +

    +++

    ++

  • 8/11/2019 Jakobsen+Lins (1)

    3/5

    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 ownfunctions as arguments to main SMC function (togetherwith 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(

    variancesnoiseticIdiosyncra)|(~

    matrixvariancesInnovation

    sInnovation)|(~

    iancesfactor varLog)(

    )exp(

    iancesFactor var),,(diagFactors),0|(~

    matrixloadingsFactor

    levelseriesLocal

    nsObservatio

    1

    1

    1

    k

    t

    ttt

    titi

    tktt

    tt

    t

    tttt

    N

    N

    h

    hhN

    y

    =

    ++=

    =

    =

    ++=

    0,

    U

    U0,

    H

    Hf

    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, artific ial 2-factor model

  • 8/11/2019 Jakobsen+Lins (1)

    4/5

    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 currencyi on dayt is given by

    wheres is the spot rate in US dollars.

    )log(,1it

    titi

    s

    sy

    =

    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

    JPYUSDCHFUSD

    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

  • 8/11/2019 Jakobsen+Lins (1)

    5/5

    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 implementingefficient particle filters

    For large datasets, however, an optimized C/C++version is really needed (because of the heavycomputational burden).

    Combined parameter and state estimation can be usefulbut 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 StateEstimation 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:[email protected]

    [email protected]

    Web site: www.saxobank.com