Learn R Programming

sde (version 2.0.18)

dcSim: Pedersen's simulated transition density

Description

Simulated transition density \(X(t) | X(t_0) = x_0\)X(t) | X(t0) = x0 of a diffusion process based on Pedersen's method.

Usage

dcSim(x0, x, t, d, s, theta, M=10000, N=10, log=FALSE)

Value

x

a numeric vector

Arguments

x0

the value of the process at time 0.

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.

Author

Stefano Maria Iacus

Details

This function returns the value of the conditional density of \(X(t) | X(0) = x_0\) at point x.

The functions d and s, must be functions of t, x, and theta.

References

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.

Examples

Run this code
if (FALSE) {
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))
}

Run the code above in your browser using DataLab