Upload
buikhue
View
225
Download
4
Embed Size (px)
Citation preview
1 / 41
From the sde package to the Yuima Project
S.M. Iacus (University of Milan)
Meielisalp, R/RMetrics Workshop, June 28th - July 2nd, 2009
Overview of the sde package
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
2 / 41
Why SDE’s?
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
3 / 41
Continuous time models are not just a matter of taste, particularly in economics
and finance.
The sde package, is focused on simulation and inference for continuous time
models solutions to SDE’s observed at discrete times.
Why continuous time matters if observations are always discrete?
Why SDE’s?
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
3 / 41
Continuous time models are not just a matter of taste, particularly in economics
and finance.
The sde package, is focused on simulation and inference for continuous time
models solutions to SDE’s observed at discrete times.
Why continuous time matters if observations are always discrete?
An example: according to McCrorie & Chambers (2006, J. of Econ.) and
others, “spurious Granger causality [tested with VAR models] is only a
consequence of the intervals in which economic data are generated being finer
than the econometrician’s sampling interval.”
Conclusions: assume a continuous time model (SDE). Discretize that, build a
VAR from the discretized SDE and the spurious Granger causality vanishes!
Why SDE’s?
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
3 / 41
Continuous time models are not just a matter of taste, particularly in economics
and finance.
The sde package, is focused on simulation and inference for continuous time
models solutions to SDE’s observed at discrete times.
Why continuous time matters if observations are always discrete?
An example: according to McCrorie & Chambers (2006, J. of Econ.) and
others, “spurious Granger causality [tested with VAR models] is only a
consequence of the intervals in which economic data are generated being finer
than the econometrician’s sampling interval.”
Conclusions: assume a continuous time model (SDE). Discretize that, build a
VAR from the discretized SDE and the spurious Granger causality vanishes!
Rephrasing: why using a binomial distribution if your underlying model is a
Gaussian?
A few examples of SDEs
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
4 / 41
� gBm : dXt = µXtdt + σXtdWt
� CIR : dXt = (θ1 + θ2Xt)dt + θ3
√XtdWt
� CKLS : dXt = (θ1 + θ2Xt)dt + θ3Xθ4
t dWt
� nonlinear mean reversion (Aıt-Sahalia)
dXt = (α−1X−1t + α0 + α1Xt + α2X
2t )dt + β1X
ρt dWt
� double Well potential (bimodal behaviour, highly nonlinear)
dXt = (Xt − X3t )dt + dWt
� Jacobi diffusion (political polarization):
dXt = −θ(
Xt − 12
)
dt +√
θXt(1 − Xt)dWt
� radial Ornstein-Uhlenbeck : dXt = (θX−1t − Xt)dt + dWt
� hyperbolic diffusion : dXt = σ2
2
[
β − γ Xt√δ2+(Xt−µ)2
]
dt + σdWt
Diffusion processes solutions to SDEs
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
5 / 41
From the statistical point of view, we are interested in the parametric family of
diffusion process solutions of the SDE
dXt = b(Xt, θ)dt + σ(Xt, θ)dWt, X0 = x0, t ∈ [0, T ]
θ = (α, β) ∈ Θα × Θβ = Θ, where Θα ⊂ Rp and Θβ ⊂ Rq .
Observations always come in discrete time form at some times ti = i∆n,
i = 0, 1, 2, ..., n, where ∆n is the length of the steps. We denote the
observations by Xn := {Xi = Xti}0≤i≤n.
Diffusion processes solutions to SDEs
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
5 / 41
From the statistical point of view, we are interested in the parametric family of
diffusion process solutions of the SDE
dXt = b(Xt, θ)dt + σ(Xt, θ)dWt, X0 = x0, t ∈ [0, T ]
θ = (α, β) ∈ Θα × Θβ = Θ, where Θα ⊂ Rp and Θβ ⊂ Rq .
Observations always come in discrete time form at some times ti = i∆n,
i = 0, 1, 2, ..., n, where ∆n is the length of the steps. We denote the
observations by Xn := {Xi = Xti}0≤i≤n.
Different sampling schemes, different statistical procedures:
1. Large sample asymptotics: ∆ fixed, T = n∆ → ∞ as n → ∞
2. High frequency: T = n∆n fixed, ∆n → 0 as n → ∞
3. Rapidly increasing design: T = n∆ → ∞, ∆n → 0 as n → ∞ under
the additional condition n∆kn → 0 for k > 1
Likelihood in discrete time
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
6 / 41
By Markov property of diffusion processes, the likelihood has this form
Ln(θ) =n
∏
i=1
pθ (∆, Xi|Xi−1)pθ(X0)
Problem: the transition density pθ (∆, Xi|Xi−1) is often not available! Only
for OU, CIR and gBm
Likelihood in discrete time
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
6 / 41
By Markov property of diffusion processes, the likelihood has this form
Ln(θ) =n
∏
i=1
pθ (∆, Xi|Xi−1)pθ(X0)
Problem: the transition density pθ (∆, Xi|Xi−1) is often not available! Only
for OU, CIR and gBm
Solutions:
� discretization of the SDE (Euler, Milstein, Ozaki, etc)
� simulation method
� hermite polynomial expansion
� partial differential equations
� other approximations of the transition density
Local Gaussian Approximation. Euler Scheme.
7 / 41
By Euler discretization of the SDE : dXt = b(Xt, θ)dt + σ(Xt, θ)dWt
Xt+∆t − Xt = b(Xt, θ)∆t + σ(Xt, θ)(Wt+∆t − Wt),
we get an approximate transition density which is Gaussian. This is widely seen in applied
contexts. But is this approximation good or not? In general no!
For example, for gBm, the true transition density is a log-normal and the Euler schemes provides
only a Gaussian approximation!
It is possible to prove that estimators are not even consistent for non negligible ∆.
Euler, ∆ and bias
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
8 / 41
Consider OU model
dXt = (θ1 − θ2Xt)dt + θ3dWt, X0 = x0
Both true and Euler approximation are Gaussian respectively with mean and
variance
m(∆, x) = xe−θ2∆ +θ1
θ2
(
1 − e−θ2∆)
, v(∆, x) =θ23
(
1 − e−2θ2∆)
2θ2,
and (Euler)
mEuler(∆, x) = x(1 − θ2∆) + θ1∆ , vEuler(∆, x) = θ23∆ ,
Only under high-frequency setting, i.e. ∆ → 0, the approximation is
acceptable.
Simulated likelihood method
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
9 / 41
Let pθ(∆, y|x) be the true transition density of Xt+∆ at point y given
Xt = x. Consider a δ << ∆, for example δ = ∆/N for N large enough,
and then use the Chapman-Kolmogorov equation as follows:
pθ(∆, y|x) =
∫
pθ(δ, y|z)pθ(∆ − δ, z|x)dz = Ez{pθ(δ, y|z)|∆− δ} ,
It means that pθ(∆, y|x) is seen as the expected value over all possible
transitions of the process from time t + (∆ − δ) to t + ∆, taking into account
that the process was in x at time t.
So we need simulations!
What about N? We need many simulations
10 / 41
Example: approximation for the CIR model
0.00 0.05 0.10 0.15 0.20
05
1015
2025
x
cond
ition
al d
ensi
ty
exactN=2N=5N=10
What about N? We need many simulations
10 / 41
Example: approximation for the CIR model
0.00 0.05 0.10 0.15 0.20
05
1015
2025
x
cond
ition
al d
ensi
ty
exactN=2N=5N=10
We need many simulations (N ) for each time points (Xti , Xti+∆). But not all simulation
schemes are stable for all models
Numerical instability. Up |Down ∆ = 0.1|0.25
11 / 41
Aıt-Sahalia process dXt = (5 − 11Xt + 6X2t − X3
t )dt + dWt, X0 = 5
Numerical instability. Up |Down ∆ = 0.1|0.25
11 / 41
Aıt-Sahalia process dXt = (5 − 11Xt + 6X2t − X3
t )dt + dWt, X0 = 5
Aıt-Sahalia’s approximation
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
12 / 41
True likelihood (continuous line), Euler approximation (dashed line), Aıt-Sahalia
approximation (dotted line). Where is the dotted line? Coincides with the
continuous line! Model dXt = βXtdt + dWt
−3 −2 −1 0 1 2 3
26.0
26.5
27.0
27.5
β
log−
likel
ihoo
d
no need to have ∆ small, but (was) very difficult to implement!
The sde package
13 / 41
The sde package implements Aıt-Sahalia method. It also implements the following methods
� local Gaussian (dcEuler), Elerian (dcElerian), Ozaki (dcOzaki) and Shoji-Ozaki
(dcShoji) approximations
� Simulated Likelihood Method (dcSim), Kessler’s (dcKessler) and Aıt-Sahalia
(HPloglik) approximations
all of them can be passed to the mle function in R or used to build appropriate likelihood
functions.
The sde package
14 / 41
The sde package also implements many simulation schemes, including: Euler, Milstein,
Milstein2, Elerian, Ozaki, Ozaki-Shoji, Exact Simulation Scheme, Simulation from conditional
distribution, Predictor-Correction scheme, etc via the unique sde.sim function
sde.sim(t0 = 0, T = 1, X0 = 1, N = 100, delta, drift, sigma,
drift.x, sigma.x, drift.xx, sigma.xx, drift.t,
method = c("euler", "milstein", "KPS", "milstein2",
"cdist","ozaki","shoji","EA"),
alpha = 0.5, eta = 0.5, pred.corr = T, rcdist = NULL,
theta = NULL, model = c("CIR", "VAS", "OU", "BS"),
k1, k2, phi, max.psi = 1000, rh, A, M=1)
The sde.sim function
15 / 41
For the OU process, dXt = −5Xtdt + 3.5dWt, it is as easy as
> d <- expression(-5 * x)
> s <- expression(3.5)
> sde.sim(X0=10,drift=d, sigma=s) -> X
> str(X)
Time-Series [1:101] from 0 to 1: 10 9.32 8.79 8.89 8.48 ...
The sde.sim function
16 / 41
For the CIR model dXt = (6 − 3Xt)dt + 2√
XtdWt
d <- expression( 6-3*x )
s <- expression( 2*sqrt(x) )
sde.sim(X0=10,drift=d, sigma=s) -> X
or, via model name
sde.sim(X0=10, theta=c(6, 3, 2), model="CIR") -> X
or, via exact conditional distribution rcCIR (also implemented in sde)
sde.sim(X0=10, theta=c(6, 3, 2), rcdist=rcCIR, method="cdist") -> X
Also in the sde package
17 / 41
The package also implements other estimation procedures
� estimating functions (linear, quadratic, martingale)
� GMM (but be careful, not really what you want to use with SDE!)
� approximate AIC statistics for model selection (sdeAIC)
� φ-divergence test statistics for parametric hypotheses testing (not in the book)
� change point (cpoint) analysis; both parametric and nonparametric
� non parametric estimation of drift (ksdrift) and diffusion (ksdiff) coefficients
� Markov Operator distance (MOdist) for clustering of SDE paths
The companion book: Simulation and Inference for Stochastic Differential Equations, with R
Examples, Springer (2008).
Limits of the sde package
Overview of the sdepackage
Diffusions
Exact likelihood
Pseudo-likelihood
Simulated likelihoodmethod
Hermite expansion
The Yuima Project
18 / 41
� only deals with 1-dimensional SDE’s
� SDE only driven by a single Wiener noise
� no jumps
� essentially only Markovian SDE’s (via specification of cdist)
� (last but not least) written by a single person!
The Yuima Project
Overview of the sdepackage
The Yuima Project
Multidimensional SDE:theoretical model
The general Levy SDE
19 / 41
The Yuima Project Team
Overview of the sdepackage
The Yuima Project
Multidimensional SDE:theoretical model
The general Levy SDE
20 / 41
M. Fukasawa (Osaka Univ.)
H. Hino (Waseda Univ., Tokyo)
S.M. Iacus (Milan Univ.)
K. Kengo (Tokyo Univ.)
H. Masuda (Kyushu Univ.)
Y. Shimitzu (Osaka Univ.)
M. Uchida (Osaka Univ.)
N. Yoshida (Tokyo Univ.)
. . . more to come
The yuima package1 is written by people working in mathematical statistics
and finance, who actively publish results in the field, have some knowledge of
R, and have the feeling on “what’s next” in the field.
Aims at filling the gap between theory and practice!1
The Yuima project is funded by the Japan Science Technology (JST) Basic Research Programs PRESTO, Grants-in-Aid for ScientificResearch No. 19340021, and the Global COE program “The research and training center for new development in mathematics” of GraduateSchool of Mathematical Sciences, University of Tokyo.
The yuima package goal: fill the gap between theory and practice
Overview of the sdepackage
The Yuima Project
Multidimensional SDE:theoretical model
The general Levy SDE
21 / 41
The Yuima Project aims at implementing, via the yuima package, a very
abstract framework to describe probabilistic and statistical properties of
stochastic processes in a way which is the closest as possible to their
mathematical counterparts but also computationally efficient.
� it is an S4 package, where the basic class extends to SDE’s with jumps,
but soon to semimartingales (non Markov), Markov switching regime
processes, fBm driven SDE’s, etc.
� separates the data description from the inference tools and simulation
schemes
� the design allows for multidimensional, multi-noise processes
specification
� it includes a variety of tools useful in finance, like asymptotic expansion
of functionals of Levy processes via Malliavin calculus
The yuima package
Overview of the sdepackage
The Yuima Project
Multidimensional SDE:theoretical model
The general Levy SDE
22 / 41
� we plan to add soon I/O functions to connect to other R packages
(including those presented at this workshop!) to avoid replications
� the package is designed to have three layers
� layer 1: is the very basic, low-level framework, (occasional) user
unfriendly. You have to specify the correct model and arguments;
� layer 2: macros and short-cuts for the common user (e.g. “please,
fit this Levy process with NIG structure”)
� layer 3: point & click interface
Layers 1 and 2 almost completed. Layer 3...
Let’s see how it is supposed to work.
The yuima package
Overview of the sdepackage
The Yuima Project
Multidimensional SDE:theoretical model
The general Levy SDE
23 / 41
The basic object is an S4 object of class yuima, which contains the slots
yuima object
@ modelof class yuima.model: an abstractdescritiption of the model (e.g. SDE)
@ dataof class yuima.data is a wrapper forany data type zoo, xts, tseries,etc.
@ sampling
of class yuima.sampling: infor-mation about the sampling scheme(random, Poisson, deterministic, ticktimes)
@ characteristicof class yuima.characteristic:the characteristic triplet and more
The yuima package
Overview of the sdepackage
The Yuima Project
Multidimensional SDE:theoretical model
The general Levy SDE
24 / 41
Each slots of the yuima object can be a list of yuima.* objects or an
empty slot.
For example, one can have a yuima object “foo” with only the slot data, and
other two yuima objects “bar” (and SDE without jumps) and “baz” (and SDE
with jumps) with only the description of two different models.
Then, we want to fit the data foo to each model bar and baz separately, for
comparisons, model selection, etc.
The yuima package offers several constructors to build each object and merge
them together.
The idea: first describe the model, then manipulate it.
The yuima.model constructor
Overview of the sdepackage
The Yuima Project
Multidimensional SDE:theoretical model
The general Levy SDE
25 / 41
To describe the following SDE: dXt = −3Xtdt + 11+X2
t
dWt, we use
> mod1 <- set.model(drift = "-3*x", diffusion = "1/(1+x^2)")
Solution variable (lhs) not specified. Trying to use state variables
> str(mod1)
Formal class ’yuima.model’ [package "yuima"] with 9 slots
..@ drift : expression((-3 * x))
..@ diffusion :List of 1
.. ..$ : expression(1/(1 + x^2))
..@ parameter :Formal class ’model.parameter’ [package "yuima"] with 4 slots
.. .. ..@ all : chr(0)
.. .. ..@ common : chr(0)
.. .. ..@ diffusion: chr(0)
.. .. ..@ drift : chr(0)
..@ state.variable : chr "x"
..@ time.variable : chr "t"
..@ noise.number : num 1
..@ equation.number: int 1
..@ dimension : int [1:4] 0 0 0 0
..@ solve.variable : chr "x"
Automatic parameter extraction
Overview of the sdepackage
The Yuima Project
Multidimensional SDE:theoretical model
The general Levy SDE
26 / 41
To describe the following SDE: dXt = −θXtdt + 11+Xγ
t
dWt, we use
> mod2 <- set.model(drift = "-theta*x", diffusion = "1/(1+x^gamma)")
Solution variable (lhs) not specified. Trying to use state variables
> str(mod2)
Formal class ’yuima.model’ [package "yuima"] with 9 slots
..@ drift : expression((-theta * x))
..@ diffusion :List of 1
.. ..$ : expression(1/(1 + x^gamma))
..@ parameter :Formal class ’model.parameter’ [package "yuima"] with 4 slots
.. .. ..@ all : chr [1:2] "theta" "gamma"
.. .. ..@ common : chr(0)
.. .. ..@ diffusion: chr "gamma"
.. .. ..@ drift : chr "theta"
..@ state.variable : chr "x"
..@ time.variable : chr "t"
..@ noise.number : num 1
..@ equation.number: int 1
..@ dimension : int [1:4] 2 0 1 1
..@ solve.variable : chr "x"
Multidimensional SDE: theoretical model
27 / 41
dX1t = X2
t
∣
∣X1t
∣
∣
2/3dW 1
t ,
dX2t = g(t)dX3
t ,
dX3t = X3
t (µdt + σ(ρdW 1t +
√
1 − ρ2dW 2t ))
, (X10 , X2
0 , X30 ) = (1.0, 0.1, 1.0)
(1)
with µ = 0.1, σ = 0.2, ρ = −0.7 and g(t) = 0.4 + (0.1 + 0.2t)e−2t, for example, where
W = (W 1, W 2) is a 2-dim standard Brownian motion. Then, it corresponds to
Xt = X0 +
∫ t
0b(s, Xs)ds +
∫ t
0c(s, Xs)dWs (2)
with
b(s, x) =
0g(s)µx3
µx3
, c(s, x) =
x2|x1|2/3 0
g(s)σρx3 g(s)σ√
1 − ρ2x3
σρx3 σ√
1 − ρ2x3
for x = (x1, x2, x3).
Multidimensional SDE: R code
28 / 41
> mu <- 0.1; sig <- 0.2; rho <- -0.7
> g <- function(t) 0.4 + (0.1 + 0.2*t)* exp(-2*t)
> diff.coef.1 <- function(t, x1, x2, x3) {
+ ret <- 0
+ if(x1 > 0 && x2 > 0) ret <- x2*exp(log(x1)*2/3)
+ ret
+ }
> diff.coef.2 <- function(t, x1, x2, x3=0) {
+ ret <- 0
+ if(x3 > 0) ret <- rho*sig*x3
+ ret
+ }
> diff.coef.3 <- function(t, x1, x2, x3) {
+ ret <- 0
+ if(x3 > 0) ret <- sqrt(1-rho^2)*sig*x3
+ ret
+ }
> diff.coef.matrix <- matrix(c("diff.coef.1(t,x1,x2,x3)", "diff.coef.2(t,x1,x2,x3) * g(t)",
+ "diff.coef.2(t,x1,x2,x3)", "0", "diff.coef.3(t,x1,x2,x3)*g(t)", "diff.coef.3(t,x1,x2,x3)"),
+ 3, 2)
> sabr.mod <- set.model(drift = c("0", "mu*g(t)*x3", "mu*x3"), diffusion = diff.coef.matrix,
+ state.variable = c("x1", "x2", "x3"), solve.variable = c("x1", "x2", "x3"))
Multidimensional SDE
29 / 41
> str(sabr.mod)
Formal class ’yuima.model’ [package "yuima"] with 9 slots
..@ drift : expression((0), (mu * g(t) * x3), (mu * x3))
..@ diffusion :List of 3
.. ..$ : expression(diff.coef.1(t, x1, x2, x3), 0)
.. ..$ : expression(diff.coef.2(t, x1, x2, x3) * g(t), diff.coef.3(t, x1, x2, x3) * g(t))
.. ..$ : expression(diff.coef.2(t, x1, x2, x3), diff.coef.3(t, x1, x2, x3))
..@ parameter :Formal class ’model.parameter’ [package "yuima"] with 4 slots
.. .. ..@ all : chr "mu"
.. .. ..@ common : chr(0)
.. .. ..@ diffusion: chr(0)
.. .. ..@ drift : chr "mu"
..@ state.variable : chr [1:3] "x1" "x2" "x3"
..@ time.variable : chr "t"
..@ noise.number : int 2
..@ equation.number: int 3
..@ dimension : int [1:4] 1 0 0 1
..@ solve.variable : chr [1:3] "x1" "x2" "x3"
Simulation of paths
30 / 41
# Sets the sampling scheme
> yuima.samp <- set.sampling(Terminal=1,division=1000)
# build the yuima object: put together model and sampling
> my.yuima <- set.yuima(model=sabr.mod, sampling=yuima.samp)
# Solve/Simulate SDE using Euler-Maruyama method
# add the simulated data to the yuima object
> my.sde <- simulate(my.yuima, xinit=c(1.0,0.1,1.0))
# and a plot method exists inherited from ‘zoo’ package
> plot(my.sde)
The newly generated yuima object
31 / 41
> str(my.sde)
Formal class ’yuima’ [package "yuima"] with 4 slots
..@ data :Formal class ’yuima.data’ [package "yuima"] with 2 slots
.. .. ..@ original.data: mts [1:1001, 1:3] 1 0.998 0.999 0.996 1.001 ...
.. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. ..$ : NULL
.. .. .. .. ..$ : chr [1:3] "Series 1" "Series 2" "Series 3"
.. .. .. ..- attr(*, "tsp")= num [1:3] 0 1 1000
.. .. .. ..- attr(*, "class")= chr [1:2] "mts" "ts"
.. .. ..@ zoo.data :List of 3
.. .. .. ..$ Series 1:zooreg series from 0 to 1
Data: num [1:1001] 1 0.998 0.999 0.996 1.001 ...
Index: num [1:1001] 0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 ...
Frequency: 1000
.. .. .. ..$ Series 2:zooreg series from 0 to 1
Data: num [1:1001] 0.1 0.104 0.106 0.106 0.103 ...
Index: num [1:1001] 0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 ...
Frequency: 1000
.. .. .. ..$ Series 3:zooreg series from 0 to 1
Data: num [1:1001] 1 1.01 1.01 1.01 1.01 ...
Index: num [1:1001] 0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 ...
Frequency: 1000
..@ model :Formal class ’yuima.model’ [package "yuima"] with 9 slots
.. .. ..@ drift : expression((0), (mu * g(t) * x3), (mu * x3))
.. .. ..@ diffusion :List of 3
.. .. .. ..$ : expression(diff.coef.1(t, x1, x2, x3), 0)
.. .. .. ..$ : expression(diff.coef.2(t, x1, x2, x3) * g(t), diff.coef.3(t, x1, x2, x3) * g(t))
.. .. .. ..$ : expression(diff.coef.2(t, x1, x2, x3), diff.coef.3(t, x1, x2, x3))
.. .. ..@ parameter :Formal class ’model.parameter’ [package "yuima"] with 4 slots
.. .. .. .. ..@ all : chr "mu"
.. .. .. .. ..@ common : chr(0)
.. .. .. .. ..@ diffusion: chr(0)
.. .. .. .. ..@ drift : chr "mu"
.. .. ..@ state.variable : chr [1:3] "x1" "x2" "x3"
Motivation
32 / 41
It is better than the sde package because it allows for multidimensional specification but also
provide a formal definition of an SDE.
But we need more that this!
Motivation
32 / 41
It is better than the sde package because it allows for multidimensional specification but also
provide a formal definition of an SDE.
But we need more that this! We need at least Levy processes
Asset prices (left) do not evolve continuously, they exhibit jumps or spikes and log returns (right)
are non-gaussian, skewed, heavy tails
100
105
110
115
120
125
130
135
140
145
150
Oct 1997 Oct 1998 Oct 1999 Oct 2000 Oct 2001 Oct 2002 Oct 2003 Oct 2004
USD/JPY
!0.02 !0.01 0.0 0.01 0.02
020
40
60
80
The general L evy SDE
33 / 41
In general the sde.model describes the following d-dimensional SDE:
dXt = a(Xt)dt + b(Xt)dWt
+
∫
|z|>1c(Xt−, z)µ(dt, dz) +
∫
0<|z|≤1c(Xt−, z){µ(dt, dz)− ν(dz)dt},
X0 = x0, (3)
where the ingredients are given as follows.
� the initial random variable X0 ∈ Rd;
� an rW -dimensional standard Wiener process W ;
� a random measure µ on (0,∞) × Rrµ associated with jumps of X , that is,
µ(dt, dz) =∑
s>0
1{∆Zs 6=0}δ(s,∆Zs)(dt, dz), (4)
where δ denotes the Dirac measure
The general L evy SDE
34 / 41
� Z the driving pure-jump Levy process of the form
Zt =
∫ t
0
∫
|z|≤1z{µ(ds, dz) − ν(dz)ds} +
∫ t
0
∫
|z|>1zµ(ds, dz); (5)
� a Levy measure ν, which is any measure satisfying ν({0}) = 0 and∫
(1 ∧ |z|2)ν(dz) < ∞;
� the coefficient functions a : Rd → R
d, b : Rd → R
d ⊗ Rrw , and c : R
d × Rrµ → R
d.
Input of the jump part
35 / 41
> set.model( drift = "a(x,theta)", diffusion = "b(x,sigma)",
+ jump.coeff = "c(x,z,xi)", measure = list(*),
+ measure.type = string(**),
+ state.var = c("x"), jump.var = c("z"), time.var = "t",
+ solve.var="c("x") )
where measure and measure.type are strictly related. For example, suppose that Z is a
gamma process with Levy density
f(z) =a
ze−bz
1(0,∞)(z).
Then Zt ∼ Γ(at, b), therefore one uses
> set.model(measure="dgamma(a*t,b)", measure.type="increment", ...)
Input of the jump part
36 / 41
Suppose that νη(dz) = η0 × Fη(dz), where η0 ≥ 0 is a constant and Fη(z) is a distribution
function (d.f.) of jump size with a parameter vector η = (η1, η2, . . .). This is the Compound
Poisson formulation of a Levy measure.
In this case users can input the intensity η0 and the d.f. Fη(z) separately as follows:
> my.meas <- list( intensity=eta0, df=list(F(z,eta1,eta2,...))
where eta0 and F() are defined somewhere in the R workspace and
> set.model( measure = my.meas, measure.type = "CP", ... )
Input of the jump part
37 / 41
Or one can directly input the density of the Levy measure ν, i.e.
νη(dz) = f(z, η) dz.
In this case users can input the intensity η0 and the d.f. Fη(z) separately as follows:
> set.model(measure = list(density=f(z,eta)), measure.type = "density", ... )
or
> F <- function(z,eta) f(z,eta)
> set.model(measure = list(df=F(z,eta)), measure.type = "density", ... )
Many other options and already coded typical Levy measures are implemented in the yuima
package (e.g. NIG, stable, tempered stable, bilateral Gamma, etc.)
Simulation and Inference
38 / 41
Once a yuima model is available, it can be passed to the simulate method or to some
estimation methods along with the data.
When passed to simulate, the output is a new yuima.object with both the yuima.model,
yuima.data and yuima.sampling slots.
There is a function called simulate.levy which is a shortcut function, used to simulate Levy
paths according to the above specifications.
For the inference and simulation, the methods are supposed to work, by default, using the best
theory available for the data and the model, up to current literature, unless the user specifies
differently.
e.g. in the high frequency case the limiting distributions are of mixed-normal type, so confidence
intervals and standard errors are more delicate to handle
Toy examples
39 / 41
Just to prove different aspects and flexibility of this approach, we have implemented several
methods
� the covariance estimator of Yoshida-Hayashi for multidimensional Ito processes with
asynchronous data.
� quasi-likelihood estimation for multidimensional diffusions with jumps
� asymptotic expansion of functionals of the solutions of SDE’s with small noise (useful in
option pricing)
� change point estimation for multidimensional Ito processes
� Bayes type estimators
� asymptotic expansion of the distribution of estimators (for small sample asymptotics)
A formula-type interface
40 / 41
We also plan to add the formula interface to mimic model specification in R. A few working
examples are
dXt = b(Xt)dt + σ(Xt)dWt
passed to set.model as
dX ~ b(X)*dt + s(X)*dW
or, the following stochastic volatility model
dXt = b(Xt, θ, t)dt + σ(Xt, Yt, β)dWt
dYt = d(Yt, τ)dZt
as
dX ~ b(X,theta,t)*dt + s(X,Y,beta)*dW
dY ~ d(Y,tau)*dZ
First release?
Overview of the sdepackage
The Yuima Project
Multidimensional SDE:theoretical model
The general Levy SDE
41 / 41
Roadmap
� we plan to release openly the basic infrastructure by the end of this year
� implement several basic methods in early 2010
� open development to potential new contributors (if there is enough
interest) mid 2010
� write the point & click layer 3 (...one day!)
First release?
Overview of the sdepackage
The Yuima Project
Multidimensional SDE:theoretical model
The general Levy SDE
41 / 41
Roadmap
� we plan to release openly the basic infrastructure by the end of this year
� implement several basic methods in early 2010
� open development to potential new contributors (if there is enough
interest) mid 2010
� write the point & click layer 3 (...one day!)