# diffproc: Diffusion Processes In fptdApprox: Approximation of First-Passage-Time Densities for Diffusion Processes

 diffproc R Documentation

## Diffusion Processes

### Description

`diffproc` creates an object of class “diffproc” from the given set of values.

`as.diffproc` attempts to turn its argument into an object of class “diffproc”.

`is.diffproc` tests if its argument is an object of class “diffproc”.

`print` shows an object of class “diffproc”.

### Usage

``````diffproc(text)
as.diffproc(text)
is.diffproc(obj)

## S3 method for class 'diffproc'
print(x, ...)
``````

### Arguments

 `text` a character vector or list of length four to be coerced, containing the infinitesimal mean, infinitesimal variance, transition probability density function and transition probability distribution function of a diffusion process. `obj` an R object to be tested. `x` an object of class “diffproc”. `...` additional arguments potentially passed (currently none is considered).

### Details

The main goal of the `diffproc` function is to validate the mathematical expressions in the given character string vector or list. If no errors happen, the function converts the input into an object of class “diffproc”. Otherwise, the function reports the errors.

The mathematical expressions of the infinitesimal mean and variance should be expressions in `x` and `t`, `A_1(x,t)` and `A_2(x,t)`, respectively.

The mathematical expressions of the transition probability density and distribution functions should be expressions in `x`, `t`, `y` and `s`, `f(x,t|y,s)` and `F(x,t|y,s)`, respectively.

In addition, all mathematical expressions may depend on generic parameters and functions of `t`, or `s` and `t`, referred by name. To name the expression of a function `h(u)` we can use ``h(u)` = value` if we want to show its dependence on `u`, or `h` otherwise.

The function checks if the mathematical expressions show syntax errors and if R can compute the symbolic derivative with respect to `x` for the infinitesimal variance and transition probability density function.

### Value

If possible, this function returns an object of class “diffproc” that defines a family of diffusion processes. It is a four-component list:

 `mean` character of length 1 with the mathematical expression of the infinitesimal mean of the process. `var` character of length 1 with the mathematical expression of the infinitesimal variance of the process. `tpdf` character of length 1 with the mathematical expression of the transition probability density function of the process. `tpdF` character of length 1 with the mathematical expression of the transition probability distribution function of the process.

`is.diffproc` returns `TRUE` or `FALSE` depending on whether its argument is an object of class “diffproc” or not.

### Note

The transition probability density functions specified by the `dnorm` function should be expressed in terms of the standard normal distribution, since only its derivative is considered in R.

### Author(s)

Patricia Román-Román, Juan J. Serrano-Pérez and Francisco Torres-Ruiz.

### References

P. Román-Román, J.J. Serrano-Pérez, F. Torres-Ruiz. (2012) An R package for an efficient approximation of first-passage-time densities for diffusion processes based on the FPTL function. Applied Mathematics and Computation, 218, 8408–8428.

P. Román-Román, J.J. Serrano-Pérez, F. Torres-Ruiz. (2014) More general problems on first-passage times for diffusion processes: A new version of the fptdApprox R package. Applied Mathematics and Computation, 244, 432–446.

`D` to know more about the simple functions and expressions that support symbolic derivative in R, and in particular about the functions provided in R to evaluate probability density functions.

`FPTL` to locate the first-passage-time of a diffusion process through a continuous boundary.

### Examples

``````## Creating a diffproc object for the lognormal diffusion process
x <- c("m*x", "sigma^2*x^2",
"dnorm((log(x)-(log(y)+(m-sigma^2/2)*(t-s)))/(sigma*sqrt(t-s)),0,1)/
(sigma*sqrt(t-s)*x)", "plnorm(x,log(y)+(m-sigma^2/2)*(t-s),
sigma*sqrt(t-s))")

Lognormal <- diffproc(x)
Lognormal

## Creating a diffproc object for the Ornstein Uhlenbeck diffusion process
x <- c("alpha*x + beta", "sigma^2", "dnorm((x-(y*exp(alpha*(t-s))-beta*
(1-exp(alpha*(t-s)))/alpha))/(sigma*sqrt((exp(2*alpha*(t-s)) - 1)/
(2*alpha))),0,1)/(sigma*sqrt((exp(2*alpha*(t-s)) - 1)/(2*alpha)))",
"pnorm(x, y*exp(alpha*(t-s)) - beta*(1 - exp(alpha*(t-s)))/alpha,
sigma*sqrt((exp(2*alpha*(t-s)) - 1)/(2*alpha)))")

OU <- diffproc(x)
OU

## Creating a diffproc object for the lognormal diffusion process with exogenous factors
x <- c("`h(t)`*x", "sigma^2*x^2", "dnorm((log(x)-(log(y)+`H(s,t)`-(sigma^2/2)*
(t - s)))/(sigma*sqrt(t-s)),0,1)/(sigma*sqrt(t-s)*x)", "plnorm(x,log(y)+
`H(s,t)`-(sigma^2/2)*(t-s),sigma*sqrt(t-s))")

LognormalFEx <- diffproc(x)
LognormalFEx

## Testing diffproc objects
is.diffproc(Lognormal)
is.diffproc(OU)
is.diffproc(LognormalFEx)
``````

fptdApprox documentation built on Nov. 2, 2023, 5:07 p.m.