dcSim | R Documentation |
Simulated transition density X(t) | X(t_0) = x_0X(t) | X(t0) = x0 of a diffusion process based on Pedersen's method.
dcSim(x0, x, t, d, s, theta, M=10000, N=10, log=FALSE)
x0 |
the value of the process at time |
x |
value in which to evaluate the conditional density. |
t |
lag or time. |
theta |
parameter of the process; see details. |
log |
logical; if TRUE, probabilities p are given as log(p). |
d |
drift coefficient as a function; see details. |
s |
diffusion coefficient as a function; see details. |
N |
number of subintervals; see details. |
M |
number of Monte Carlo simulations, which should be an even number; see details. |
This function returns the value of the conditional density of
X(t) | X(0) = x0 at point x
.
The functions d
and s
, must be functions of t
,
x
, and theta
.
x |
a numeric vector |
Stefano Maria Iacus
Pedersen, A. R. (1995) A new approach to maximum likelihood estimation for stochastic differential equations based on discrete observations, Scand. J. Statist., 22, 55-71.
## Not run: d1 <- function(t,x,theta) theta[1]*(theta[2]-x) s1 <- function(t,x,theta) theta[3]*sqrt(x) from <- 0.08 x <- seq(0,0.2, length=100) sle10 <- NULL sle2 <- NULL sle5 <- NULL true <- NULL set.seed(123) for(to in x){ sle2 <- c(sle2, dcSim(from, to, 0.5, d1, s1, theta=c(2,0.02,0.15), M=50000,N=2)) sle5 <- c(sle5, dcSim(from, to, 0.5, d1, s1, theta=c(2,0.02,0.15), M=50000,N=5)) sle10 <- c(sle10, dcSim(from, to, 0.5, d1, s1, theta=c(2,0.02,0.15), M=50000,N=10)) true <- c(true, dcCIR(to, 0.5, from, c(2*0.02,2,0.15))) } par(mar=c(5,5,1,1)) plot(x, true, type="l", ylab="conditional density") lines(x, sle2, lty=4) lines(x, sle5, lty=2) lines(x, sle10, lty=3) legend(0.15,20, legend=c("exact","N=2", "N=5", "N=10"), lty=c(1,2,4,3)) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.