[R] Generating a double-exponential jump diffusion process
Ben Bolker
bolker at zoo.ufl.edu
Mon Nov 6 00:51:57 CET 2006
Tolga Uzuner <tolga <at> coubros.com> writes:
>
> Dear R Users,
>
> Does anyone know of a package which can generate random realisations of
> a double-exponential jump diffusion process with a drift ? Something
> where I can specify the likelihoods of an up or a down jump, the drift
> rate, and the mean size, and get back a vector of realisation of the
> process (for purposes of a Monte-Carlo).
>
Hmmm. I'm not exactly sure what you mean (this is one of the things
to remember about the R list -- there is a vast variety of readers,
most of whom aren't in your field, so the only things you can assume
we all know are basic statistics and stuff about R). By "drift"
do you mean that likelihood of up is not equal to likelihood of down?
I can imagine that it would be easy to generate such a realisation
(without a particular package), if you could give us the precise definition.
As a starting example:
jumpdiff <- function(start=0,nt=100,up=0.5,scale=1) {
res <- numeric(nt)
res[1] <- start
for (i in 2:nt) {
dir <- if (runif(1)<up) 1 else -1
res[i+1] <- res[i]+dir*rexp(1,scale=scale)
}
}
I wrote this out as a for loop to make it clearer: a much
more efficient way would be
dir <- ifelse(runif(nt)<up,1,-1)
jump <- rexp(nt,scale=scale)
cumsum(start+dir*jump)
hope that helps
Ben Bolker
More information about the R-help
mailing list