fptsde1d for simulate first-passage-time (f.p.t) in 1-dim stochastic differential equations.fptsde1d(N, ...)
## S3 method for class 'default':
fptsde1d(N = 100, M = 10, x0 = 0, t0 = 0, T = 1, Dt, c = 0.5,
drift, diffusion, alpha = 0.5, mu = 0.5, type = c("ito", "str"),
method = c("euler", "milstein", "predcorr", "smilstein", "taylor",
"heun", "rk1", "rk2", "rk3"), ...)
## S3 method for class 'fptsde1d':
summary(object, \dots)
## S3 method for class 'fptsde1d':
mean(x, \dots)
## S3 method for class 'fptsde1d':
median(x, \dots)
## S3 method for class 'fptsde1d':
quantile(x, \dots)
## S3 method for class 'fptsde1d':
kurtosis(x, \dots)
## S3 method for class 'fptsde1d':
skewness(x, \dots)
## S3 method for class 'fptsde1d':
moment(x, order = 2, \dots)
## S3 method for class 'fptsde1d':
bconfint(x, level=0.95, \dots)t0.missing a default $\Delta t = \frac{T-t_{0}}{N}$.expression of two variables t and x.expression of two variables t and x.alpha of the predictor-corrector scheme; the default alpha = 0.5.mu of the predictor-corrector scheme; the default mu = 0.5.method = "euler"; see snssde1d."fptsde1d".fptsde1d returns an object inheriting from class "fptsde1d".fptsde1d returns a random variable $\tau_{c}$ "first passage time", defined by :
$$\tau_{c} = { t \geq 0 ; X_{t} \geq c },\quad if \quad (x_{0} < c)$$
$$\tau_{c} = { t \geq 0 ; X_{t} \leq c },\quad if \quad (x_{0} > c)$$
with $c$ is a fixed boundary or barrier.fptsde2d and fptsde3d simulation fpt for sde 2 and 3-dim.
FPTL in package ## dX(t) = -3*(1+X(t)) *dt + 0.5*X(t) *dW(t)
## tau(c=0) = inf{t>=0, X(t) <= 0}
f <- expression( -3*(1+x) )
g <- expression( 0.5*x )
res <- fptsde1d(drift=f,diffusion=g,x0=1,c=0,M=100,N=1000)
res
summary(res)
bconfint(res,level=0.95)
moment(res,order=c(2,3,4,5))
plot(density(res$tau[!is.na(res$tau)]))Run the code above in your browser using DataLab