diffproc | R Documentation |

`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”.

```
diffproc(text)
as.diffproc(text)
is.diffproc(obj)
## S3 method for class 'diffproc'
print(x, ...)
```

`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 |

`x` |
an object of class “diffproc”. |

`...` |
additional arguments potentially passed (currently none is considered). |

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.

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.

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**.

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

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.

```
## 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)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.