An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20110703/b9aea5a7/attachment.pl>
Simulating inhomogeneous Poisson process without loop
3 messages · Tristan Linke, Krishna Kumar, Harun Ozkan
A reproducible example would help, have you tried FOREACH On Jul 3, 2011, at 7:53 AM, Tristan Linke <tristan.linke at gmail.com> wrote:
Dear all
I want to simulate a stochastic jump variance process in which N is
Bernoulli (Poisson approximation) with intensity lambda0 + lambda1*Vt.
lambda0 is constant and lambda1 can be interpreted as a regression
coefficient on the current variance level Vt. J is the scaling factor
How can I rewrite this avoiding the loop structure which is very
time-consuming for long simulations?
for (i in 1:N){
...
N <- rbinom(n=1, size=1, prob=(lambda0+lambda1*Vt))
Vt <- ... + J*N
..
}
P.S. This is going towards the Duffie, Pan, Singleton 2000 Transform
Pricing
paper, here stochastic volatility with state-dependent correlated
jumps
(Eraker 2004).
Thanks a lot in advance.
[[alternative HTML version deleted]]
_______________________________________________ R-SIG-Finance at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
dt=.01;
t=seq(0, .5, by=dt)
apply(matrix(t), 1, function (x) { rbinom(1,1,prob=x )} )
would produce a series of Bernoulli trials with success probability t
\in [0, .5].
In my humble opinion, this style is more pertinent in terms of the
programming logic of R although I am not very sure about the efficiency.
All the best.
7/3/2011 7:09 PM, Krishna wrote:
A reproducible example would help, have you tried FOREACH On Jul 3, 2011, at 7:53 AM, Tristan Linke <tristan.linke at gmail.com> wrote:
Dear all
I want to simulate a stochastic jump variance process in which N is
Bernoulli (Poisson approximation) with intensity lambda0 + lambda1*Vt.
lambda0 is constant and lambda1 can be interpreted as a regression
coefficient on the current variance level Vt. J is the scaling factor
How can I rewrite this avoiding the loop structure which is very
time-consuming for long simulations?
for (i in 1:N){
...
N <- rbinom(n=1, size=1, prob=(lambda0+lambda1*Vt))
Vt <- ... + J*N
..
}
P.S. This is going towards the Duffie, Pan, Singleton 2000 Transform
Pricing
paper, here stochastic volatility with state-dependent correlated jumps
(Eraker 2004).
Thanks a lot in advance.
[[alternative HTML version deleted]]