Title: | Approximation of First-Passage-Time Densities for Diffusion Processes |
---|---|
Description: | Efficient approximation of first passage time densities for diffusion processes based on the First Passage Time Location (FPTL) function. |
Authors: | Patricia Roman-Roman, Juan J. Serrano-Perez and Francisco Torres-Ruiz. |
Maintainer: | Juan J. Serrano-Perez <[email protected]> |
License: | GPL-2 |
Version: | 2.5 |
Built: | 2025-03-01 06:06:50 UTC |
Source: | https://github.com/cran/fptdApprox |
Efficient approximation of first-passage-time (f.p.t.) densities for diffusion processes based on the First-Passage-Time Location (FPTL) function.
For a complete list of functions, use library(help=“fptdApprox”).
Package: | fptdApprox |
Type: | Package |
Version: | 2.4 |
Date: | 2022-08-21 |
License: | GPL-2 |
LazyLoad: | yes |
The fptdApprox package allows to approximate efficiently the f.p.t. density for a diffusion process through a continuous time-dependent boundary in the cases of conditioned and unconditioned f.p.t. problems.
For an unconditioned f.p.t. problem, a step by step study can be performed.
First, the diffusion process under consideration must be defined by using the function
diffproc
. Then, the FPTL
function will be used to calculate the FPTL function for the specified
process and boundary. The information provided by the function is then extracted by the method summary.fptl
and used to find the range of
variation of the f.p.t. variable. Finally, such information is used by the function Approx.cfpt.density
to obtain the approximation of the f.p.t. density.
In the general case (conditioned and unconditioned f.p.t. problems) the function Approx.fpt.density
allows to obtain directly the approximate f.p.t. density.
Patricia Román-Román, Juan J. Serrano-Pérez and Francisco Torres-Ruiz.
Maintainer: Juan J. Serrano-Pérez, [email protected]
Buonocore, A., Nobile, A.G. and Ricciardi, L.M. (1987) A new integral equation for the evaluation of first-passage-time probability densities. Adv. Appl. Probab., 19, 784–800.
Román, P., Serrano, J. J., Torres, F. (2008) First-passage-time location function: Application to determine first-passage-time densities in diffusion processes. Comput. Stat. Data Anal., 52, 4132–4146.
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.
Approx.cfpt.density
computes values of the approximate first-passage-time (f.p.t.) density, for a conditioned problem,
from an object of class “summary.fptl” that contains the information provided by First-Passage-Time Location (FPTL) function.
Approx.cfpt.density(sfptl, variableStep = TRUE, from.t0 = FALSE, to.T = FALSE, skip = TRUE, n = 250, p = 0.2, alpha = 1, tol = 1e-03, it.max = 50000L)
Approx.cfpt.density(sfptl, variableStep = TRUE, from.t0 = FALSE, to.T = FALSE, skip = TRUE, n = 250, p = 0.2, alpha = 1, tol = 1e-03, it.max = 50000L)
sfptl |
an object of class “summary.fptl”, a result of applying the |
variableStep |
a logical value indicating whether a variable integration step is used. |
from.t0 |
a logical value indicating whether the approximation should be calculated from the lower end of the
interval considered, |
to.T |
a logical value indicating whether the approximation should be calculated to the upper end of the
interval considered, |
skip |
a logical value indicating whether the intervals at which the FPTL function is near zero could be avoided. |
n |
Number of points used to determine the integration step in subintervals |
p |
Ratio of n used to determine the integration step in subintervals
|
alpha |
Parameter used to determine the integration step in subintervals
|
tol |
If the cumulative integral of the approximation is greater than or equal to 1 - tol the algorithm is stopped. |
it.max |
If the number of iterations required for the approximation process is greater than it.max, the function asks for permission to continue. |
For a diffusion process , the f.p.t. variable,
conditioned to
, through a continuous boundary
is defined as
Its density function is the solution to a Volterra integral equation of the second kind. The kernel of this equation depends on the infinitesimal moments of the process, the transition probability density function and the boundary.
Nevertheless, and apart from some particular processes and boundaries,
closed-form solutions for the integral equation are not available. For this reason,
in the cases without explicit solutions, numerical procedures are required. That is the situation
considered here and the numerical procedure implemented by the Approx.fpt.density
function is the one
proposed by Buonocore et al. (1987), based on the composite trapezoid method.
The Approx.cfpt.density
function computes efficiently the approximate f.p.t. density by
using the information provided by the FPTL function contained in the
sfptl
object. See the function summary.fptl
for details.
By default the function does not compute the approximate f.p.t. density
from the time instant , but from a more suitable time instant
provided by the FPTL function. It also uses a variable integration step.
The function makes an internal call to Integration.Steps
function in order to determine the subintervals and
integration steps to be used in the application of the numerical algorithm according to the variableStep
,
from.t0
, to.T
, n
, p
and alpha
arguments.
In addition, if skip = TRUE
, the function checks the approximate density value for each ,
and, if it is almost 0, the application of the numerical algorithm in the subinterval
is avoided, and then continued from instant
considering a zero value of the approximate
density.
Similarly, if to.T = FALSE
, the function checks the cumulative value of the integral for each
provided by the FPTL function and, if it is greater than or equal to 1 - tol, the numerical algorithm is stopped. In any case,
the algorithm is stopped in the final
, and if the cumulative value of the integral is less than 1 - tol
the function issues a warning.
The Approx.cfpt.density
function computes and returns an object of class “fpt.density”. It
is a three-component list:
x |
a sequence of suitable time instants in |
y |
the approximate conditioned f.p.t. density function values on the x sequence. |
y.x0 |
NULL (for consistency with the object of class “fpt.density” that produces the |
It also includes six additional attributes:
Call |
the unevaluated function call, substituting each name in this call by its value when |
the latter has length 1. | |
Steps |
matrix of subintervals and integration steps to consider for computing |
the approximate conditioned f.p.t. density. | |
cumIntegral |
vector of the values of the cumulative integral of the |
approximation for each subinterval considered. | |
skips |
a list that contains, for each subinterval, the value 1 if the application of the |
numerical algorithm has been avoided or integer(0) otherwise. | |
CPUTime |
matrix of user and system times, by columns, required to approximate |
the density for each subinterval considered, by rows. | |
summary.fptl |
the object used as sfptl argument in the function call. |
x
is the vector result of the concatenation of the sequences of equally spaced values in the suitable subintervals
determined by the Integration.Steps
function.
Patricia Román-Román, Juan J. Serrano-Pérez and Francisco Torres-Ruiz.
Buonocore, A., Nobile, A.G. and Ricciardi, L.M. (1987) A new integral equation for the evaluation of first-passage-time probability densities. Adv. Appl. Probab., 19, 784–800.
Román, P., Serrano, J. J., Torres, F. (2008) First-passage-time location function: Application to determine first-passage-time densities in diffusion processes. Comput. Stat. Data Anal., 52, 4132–4146.
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.
summary.fptl
to locate the f.p.t. variable and create objects of class “summary.fptl”.
is.fpt.density
to test for objects of class “fpt.density”.
print.fpt.density
to show objects of class “fpt.density”.
report.fpt.density
to generate a report.
plot.fpt.density
for graphical display.
FPTL
to evaluate the FPTL function and create objects of class “fptl”.
## Continuing the summary.fptl(.) example: ## Making an efficient approximation of the f.p.t. density ## (optimal variable integration steps and small computational cost) yyy <- Approx.cfpt.density(yy) yyy zzz <- Approx.cfpt.density(zz) zzz ## Making a less efficient approximation of the f.p.t. density ## (optimal fixed integration step but high computational cost related to ## the efficient approximation) ## Not run: yyy1 <- Approx.cfpt.density(yy, variableStep = FALSE, from.t0 = TRUE, to.T = TRUE, skip = FALSE) yyy1 ## End(Not run)
## Continuing the summary.fptl(.) example: ## Making an efficient approximation of the f.p.t. density ## (optimal variable integration steps and small computational cost) yyy <- Approx.cfpt.density(yy) yyy zzz <- Approx.cfpt.density(zz) zzz ## Making a less efficient approximation of the f.p.t. density ## (optimal fixed integration step but high computational cost related to ## the efficient approximation) ## Not run: yyy1 <- Approx.cfpt.density(yy, variableStep = FALSE, from.t0 = TRUE, to.T = TRUE, skip = FALSE) yyy1 ## End(Not run)
Approx.fpt.density
computes values of the approximate first-passage-time (f.p.t.) density, for conditioned and unconditioned problems.
For the unconditioned case, values of the approximate densities for f.p.t. problems conditioned to suitable values of the initial distribution are also calculated.
Approx.fpt.density(dp, t0, T, id, S, env = NULL, variableStep = TRUE, from.t0 = FALSE, to.T = FALSE, r = 4000, zeroSlope = 0.01, p0.tol = 8, k = 3, m = 100, n = 250, p = 0.2, alpha = 1, skip = TRUE, tol = 0.001, it.max)
Approx.fpt.density(dp, t0, T, id, S, env = NULL, variableStep = TRUE, from.t0 = FALSE, to.T = FALSE, r = 4000, zeroSlope = 0.01, p0.tol = 8, k = 3, m = 100, n = 250, p = 0.2, alpha = 1, skip = TRUE, tol = 0.001, it.max)
dp |
an object of class “diffproc” defining a family of diffusion processes. |
t0 , T
|
lower and upper limits of the considered time interval. Must be finite. |
id |
a numerical value specifying a fixed initial value of the process in the time instant specified in the |
S |
numerical value of a constant boundary or character string with the mathematical expression of a time dependent boundary. |
env |
a named list of objects of numeric or character type specifying the values of names which occur in
the mathematical expressions in objects |
variableStep |
a logical value indicating whether a variable integration step is used. |
from.t0 |
a logical value indicating whether the approximation should be calculated from the lower end of the
interval considered, |
to.T |
a logical value indicating whether the approximation should be calculated to the upper end of the
interval considered, |
r |
number of points at which the FPTL function is evaluated. |
zeroSlope |
maximum slope required to consider that a growing function is constant. |
p0.tol |
controls where the First-Passage-Time Location function begins to increase significantly. |
k |
controls whether the First-Passage-Time Location function decreases very slowly. |
m |
Number of equally spaced values to select from the specified initial distribution in the case of an unconditioned f.p.t. problem. |
n |
Number of points used to determine the integration step in subintervals |
p |
Ratio of n used to determine the integration step in subintervals
|
alpha |
Parameter used to determine the integration step in subintervals
|
skip |
a logical value indicating whether the intervals at which the FPTL function is near zero could be avoided. |
tol |
If the cumulative integral of the approximation is greater than or equal to 1 - tol the algorithm is stopped. |
it.max |
If the number of iterations required for the approximation process is greater than it.max, the function asks for permission to continue. Defaults to 50000 for a conditioned f.p.t. problem, and 1000000 for an unconditioned f.p.t. problem. |
For an unconditioned f.p.t. problem, this function allows to compute directly the approximate f.p.t. density from an object of class “diffproc”.
In contrast to the approximation of a conditioned f.p.t. density by using the Approx.cfpt.density
function, in this case it is not necessary for users to make
previous calls to the functions FPTL
and summary.FPTL
.
For a diffusion process with non-degenerate initial distribution
the unconditioned f.p.t. variable, through a continuous boundary
, is defined as
Its density function can be obtained by means of the numerical integration, in the range of variation of ,
of the corresponding f.p.t. densities conditioned to values of
, weighted by the initial density function.
For each conditioned problem related to an unconditioned f.p.t. problem, the Approx.fpt.density
function makes internal calls to
FPTL
and summary.fptl
functions, in order to localize each conditioned f.p.t. variable, according to the
zeroSlope
, p0.tol
and k
arguments. Then, the function makes a internall
call to Integration.Steps
function, in order to determine the suitable subintervals and
integration steps to be used to approximate the unconditioned f.p.t. density and conditioned f.p.t. densities according to the variableStep
,
from.t0
, to.T
, n
, p
and alpha
arguments.
From this information, a suitable sequence of time instants in for the approximation of the f.p.t. densities is available.
For each time instant t in such sequence, the
Approx.fpt.density
function computes the value of the f.p.t. density conditioned to
m
values of the initial distribution (equally spaced in its range of variation), and then it computes the value of the unconditioned f.p.t density.
For the approximation of each conditioned f.p.t density, the numerical procedure proposed by Buonocore et al. (1987),
based on the composite trapezoid method, has been implemented. This method has also been used in the numerical integration for obtaining
the unconditioned f.p.t. density.
The mathematical expression of the boundary S
should be a function of and may include the argument
t0
,
the name x0
, to refer to an initial value of the process, and the parameters specified in the env
argument.
The function checks if the mathematical expression shows syntax errors and if R can compute its symbolic derivative with respect to .
The env
argument is a list of tagged values in name = value
form with name
other than ,
,
and
.
To name the expression of a function
as a character string we can use
`h(u)` = value
if we want to show its dependence on , or
h = value
otherwise.
The env
argument is copied into a temporary environment for evaluating the mathematical expressions in objects dp
and S
.
R looks for the objects not found into this temporary environment in the parent.frame() environment.
By default the function does not compute the approximate f.p.t. density from the time instant , but from a more suitable time instant
provided by the First-Passage-Time Location (FPTL) function. It also uses a variable integration step.
If skip = TRUE
, for each subinterval in which it could be possible to avoid calculating all the conditioned f.p.t. densities,
the function checks the value of the approximate unconditioned f.p.t. density
at the lower end of such subinterval. If it is almost 0, the approximate unconditioned f.p.t. density
calculation is avoided in the subinterval, and it continues from the upper end of the subinterval
considering a zero value of the approximate unconditioned f.p.t. density.
Similarly, if to.T = FALSE
, the function checks the cumulative value of the integral for each upper end of the
subintervals for which it is not possible to avoid the application of the numerical algorithm for each conditioned problem.
If it is greater than or equal to 1 - tol
, the approximation procedure
is stopped. In any case, the procedure is stopped at the upper end of the last subinterval,
and if the cumulative value of the integral is less than 1 - tol
the function issues a warning.
The Approx.fpt.density
function computes and returns an object of class “fpt.density”. This object
is a three-component list:
x |
a sequence of suitable time instants in |
y |
the approximate f.p.t. density function values on the x sequence for the unconditioned or conditioned problem at hand. |
y.x0 |
NULL for a conditioned f.p.t. problem or a matrix with the values, by columns, of the approximate f.p.t.
densities conditioned to each considered value |
It also includes six additional attributes:
Call |
the unevaluated function call, substituting each object of length 1 (referred |
by name in call) by its value. | |
Steps |
matrix of subintervals and integration steps to consider for computing the |
approximate f.p.t. density. | |
cumIntegral |
vector of the values of the cumulative integral of the approximation for |
each subinterval considered. | |
skips |
a list that contains, for each subinterval, the indexes of the initial values |
for which the calculation of the approximate conditioned f.p.t. densities | |
has been avoided. | |
CPUTime |
matrix of user and system times, by columns, required to approximate |
the density for each subinterval considered, by rows. | |
summary.fptl |
the object of class “summary.fptl” that results in the internal calls to the |
summary.fptl function which is used as sfptl argument in the internal |
|
call to the Integration.Steps function. |
|
x
is the vector result of the concatenation of the sequences of equally spaced values in the suitable subintervals
determined by the Integration.Steps
function.
Patricia Román-Román, Juan J. Serrano-Pérez and Francisco Torres-Ruiz.
Buonocore, A., Nobile, A.G. and Ricciardi, L.M. (1987) A new integral equation for the evaluation of first-passage-time probability densities. Adv. Appl. Probab., 19, 784–800.
Román, P., Serrano, J. J., Torres, F. (2008) First-passage-time location function: Application to determine first-passage-time densities in diffusion processes. Comput. Stat. Data Anal., 52, 4132–4146.
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.
diffproc
about creation of class “diffproc” objects.
is.fpt.density
to test for objects of class “fpt.density”.
print.fpt.density
to show objects of class “fpt.density”.
report.fpt.density
to generate a report.
plot.fpt.density
for graphical display.
FPTL
to evaluate the FPTL function and create objects of class “fptl”.
summary.fptl
to locate the f.p.t. variable and create objects of class “summary.fptl”.
## Continuing the diffproc(.) example: ## Making an efficient approximation of the f.p.t. density ## in the case of a conditioned f.p.t. problem. (optimal ## variable integration steps and small computational cost) yyy.cp <- Approx.fpt.density(dp = Lognormal, t0 = 0, T = 18, id = 1, S = "4.5 + 4*t^2 + 7*t*sqrt(t)*sin(6*sqrt(t))", env = list(m = 0.48, sigma = 0.07)) yyy.cp ## Not run: ## Making a less efficient approximation of the f.p.t. density ## (optimal fixed integration step but high computational cost related to ## the efficient approximation) yyy1.cp <- Approx.fpt.density(dp = Lognormal, t0 = 0, T = 18, id = 1, S = "4.5 + 4*t^2 + 7*t*sqrt(t)*sin(6*sqrt(t))", env = list(m = 0.48, sigma = 0.07), variableStep = FALSE, from.t0 = TRUE, to.T = TRUE, skip = FALSE) yyy1.cp ## Making an efficient approximation of the f.p.t. density ## in the case of an unconditioned f.p.t. problem. yyy.ucp <- Approx.fpt.density(dp = Lognormal, t0 = 0, T = 18, id = list("dlnorm(x,-0.005,0.1)", "Lambda(-0.005,0.1)", "\\Lambda(-0.005,0.1)", "Lognormal(-0.005,0.1)"), S = "4.5 + 4*t^2 + 7*t*sqrt(t)*sin(6*sqrt(t))", env = list(m = 0.48, sigma = 0.07), m=25) yyy.ucp ## End(Not run)
## Continuing the diffproc(.) example: ## Making an efficient approximation of the f.p.t. density ## in the case of a conditioned f.p.t. problem. (optimal ## variable integration steps and small computational cost) yyy.cp <- Approx.fpt.density(dp = Lognormal, t0 = 0, T = 18, id = 1, S = "4.5 + 4*t^2 + 7*t*sqrt(t)*sin(6*sqrt(t))", env = list(m = 0.48, sigma = 0.07)) yyy.cp ## Not run: ## Making a less efficient approximation of the f.p.t. density ## (optimal fixed integration step but high computational cost related to ## the efficient approximation) yyy1.cp <- Approx.fpt.density(dp = Lognormal, t0 = 0, T = 18, id = 1, S = "4.5 + 4*t^2 + 7*t*sqrt(t)*sin(6*sqrt(t))", env = list(m = 0.48, sigma = 0.07), variableStep = FALSE, from.t0 = TRUE, to.T = TRUE, skip = FALSE) yyy1.cp ## Making an efficient approximation of the f.p.t. density ## in the case of an unconditioned f.p.t. problem. yyy.ucp <- Approx.fpt.density(dp = Lognormal, t0 = 0, T = 18, id = list("dlnorm(x,-0.005,0.1)", "Lambda(-0.005,0.1)", "\\Lambda(-0.005,0.1)", "Lognormal(-0.005,0.1)"), S = "4.5 + 4*t^2 + 7*t*sqrt(t)*sin(6*sqrt(t))", env = list(m = 0.48, sigma = 0.07), m=25) yyy.ucp ## End(Not run)
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, ...)
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 R object to be tested. |
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 and
,
and
, respectively.
The mathematical expressions of the transition probability density and distribution functions should be expressions in ,
,
and
,
and
, respectively.
In addition, all mathematical expressions may depend on generic parameters and functions of , or
and
,
referred by name. To name the expression of a function
we can use
`h(u)` = value
if we want to show its dependence on , or
h
otherwise.
The function checks if the mathematical expressions show syntax errors and if R can compute the symbolic derivative with respect
to 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)
## 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)
FPTL
computes values of the First-Passage-Time Location (FPTL) function of a diffusion process for a continuous boundary.
is.fptl
tests if its argument is an object of class “fptl”.
print.fptl
shows an object of class “fptl”.
FPTL(dp, t0, T, x0, S, env = NULL, n = 4000) is.fptl(obj) ## S3 method for class 'fptl' print(x, ...)
FPTL(dp, t0, T, x0, S, env = NULL, n = 4000) is.fptl(obj) ## S3 method for class 'fptl' print(x, ...)
dp |
an object of class “diffproc” defining a family of diffusion processes. |
obj |
an R object to be tested. |
x |
an object of class “fptl”, a result of a call to this function. |
t0 , T
|
lower and upper limits of the considered time interval. Must be finite. |
x0 |
fixed initial value of process in the time instant specified in the |
S |
numerical value of a constant boundary or character string with the mathematical expression of a time-dependent boundary. |
env |
a named list of objects of numeric or character type specifying the values of names which occur in
the mathematical expressions in objects |
n |
number of points at which the FPTL function is evaluated. |
... |
additional arguments potentially passed (currently none is considered). |
The FPTL function for the problem of the first-passage-time of a diffusion process ,
conditioned to
, through a continuous boundary
is defined as
where is the transition probability distribution function of the process.
Initially, the FPTL function is evaluated at a sequence of n equally spaced values from t0
to T
.
Then the FPTL
function makes an internal call to the growth.intervals
function in order to study the growth
of the evaluation vector. Finally, the FPTL function is evaluated at a more adequate sequence of values from t0
to T
according
to the abovementioned study.
The mathematical expression of the boundary S
should be a function of and may include arguments
t0
,
x0
and the parameters specified in the env
argument. The FPTL
function checks if the mathematical expression
shows syntax errors and if R can compute its symbolic derivative with respect to .
The env
argument is a list of tagged values in name = value
form with name
other than ,
,
and
.
To name the expression of a function
as a character string we can use
`h(u)` = value
if we want to show its dependence on , or
h = value
otherwise.
The env
argument is copied into a temporary environment for evaluating the mathematical expressions in objects dp
and S
.
R looks for the objects not found into this temporary environment in the parent.frame() environment.
The function FPTL
computes and returns an object of class “fptl”. It is a two-component list:
x |
a sequence of n values from |
y |
the corresponding values of the FPTL function for the |
It also includes three additional attributes:
Call |
the unevaluated function call, substituting each name in this call for its value when |
the latter has length 1. | |
dp |
the object used as dp argument in the function call. |
vars |
NULL or a list containing the values of names in the function call for those names |
with values of length greater than 1. | |
is.fptl
returns TRUE
or FALSE
depending on whether its argument is an object of class “fptl” or not.
Since n is usually large, the print.fptl
function does not display an object of class “fptl” as a list, but in its ‘basic’
structure instead. However, each component can be displayed separately in the usual way.
Patricia Román-Román, Juan J. Serrano-Pérez and Francisco Torres-Ruiz.
Román, P., Serrano, J. J., Torres, F. (2008) First-passage-time location function: Application to determine first-passage-time densities in diffusion processes. Comput. Stat. Data Anal., 52, 4132–4146.
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.
diffproc
about creation of class “diffproc” objects.
summary.fptl
for summaries and plot.fptl
for graphical display.
## Continuing the diffproc(.) examples: ## Specifying a boundary b <- "4.5 + 4*t^2 + 7*t*sqrt(t)*sin(6*sqrt(t))" ## Computing FPTL functions and creating objects of class fptl y <- FPTL(dp = Lognormal, t0 = 0, T = 18, x0 = 1, S = b, env = list(m = 0.48, sigma = 0.07)) y z <- FPTL(dp = LognormalFEx, t0 = 1, T = 10, x0 = 1, S = 15, env = list(sigma=0.1, `h(t)` = "t/4", `H(s,t)` = "(t^2-s^2)/8")) z ## Testing fptl objects is.fptl(y) is.fptl(z)
## Continuing the diffproc(.) examples: ## Specifying a boundary b <- "4.5 + 4*t^2 + 7*t*sqrt(t)*sin(6*sqrt(t))" ## Computing FPTL functions and creating objects of class fptl y <- FPTL(dp = Lognormal, t0 = 0, T = 18, x0 = 1, S = b, env = list(m = 0.48, sigma = 0.07)) y z <- FPTL(dp = LognormalFEx, t0 = 1, T = 10, x0 = 1, S = 15, env = list(sigma=0.1, `h(t)` = "t/4", `H(s,t)` = "(t^2-s^2)/8")) z ## Testing fptl objects is.fptl(y) is.fptl(z)
For the vector of values resulting from the evaluation of a function, this function determines the positions of the values between which the vector grows.
growth.intervals(x, y, zeroSlope = 0.01)
growth.intervals(x, y, zeroSlope = 0.01)
x |
a vector of values. |
y |
the vector of the corresponding values of a function for the |
zeroSlope |
maximum slope (in degrees) required to consider that a growing function is constant. |
The growth.intervals
function ignores the pairs of values between which the vector y
starts and stops growing if the slope is less than zeroSlope
.
This function returns NULL if the vector y
is not growing. Otherwise, the
function computes a matrix of indexes with two columns. The first column
contains the positions of the values from which the vector y
starts growing and the
second column those at which the vector y
stops growing.
Patricia Román-Román, Juan J. Serrano-Pérez and Francisco Torres-Ruiz.
u <- seq(0, 5, length = 200) v <- sin(u) w <- growth.intervals(u, v) w plot(u, v, type = "l", las = 1) abline(v = u[as.vector(w)]) ## Continuing the FPTL(.) examples: growth.intervals(y$x, y$y) growth.intervals(y$x, y$y, zeroSlope = 0.001)
u <- seq(0, 5, length = 200) v <- sin(u) w <- growth.intervals(u, v) w plot(u, v, type = "l", las = 1) abline(v = u[as.vector(w)]) ## Continuing the FPTL(.) examples: growth.intervals(y$x, y$y) growth.intervals(y$x, y$y, zeroSlope = 0.001)
According to the First-Passage-Time Location (FPTL) function and the arguments in the function call, this function calculates suitable subintervals and integration steps in order to approximate the first-passage-time (f.p.t.) density.
Integration.Steps(sfptl, variableStep = TRUE, from.t0 = FALSE, to.T = FALSE, n = 250, p = 0.2, alpha = 1)
Integration.Steps(sfptl, variableStep = TRUE, from.t0 = FALSE, to.T = FALSE, n = 250, p = 0.2, alpha = 1)
sfptl |
an object of class “summary.fptl”. |
variableStep |
a logical value indicating whether a variable integration step is used. |
from.t0 |
a logical value indicating whether the approximation should be calculated from the lower end of the
interval considered, |
to.T |
a logical value indicating whether the approximation should be calculated to the upper end of the
interval considered, |
n |
Number of points used to determine the integration step in subintervals |
p |
Ratio of n used to determine the integration step in subintervals |
alpha |
Parameter used to determine the integration step in subintervals
|
Based on the information provided by the FPTL function contained in the sfptl
object, this function computes and returns
suitable subintervals and integration steps in order to approximate the density
function of the f.p.t. variable according to the other arguments in the function call.
When the sfptl
object is of length greater than 1, it comes from an unconditioned f.p.t. problem. Each component is associated with
the same f.p.t. problem conditioned on different values of the initial distribution
(equally spaced in the range of the distribution). Let ,
, these values. For each initial value
let
,
and
,
,
the interesting time instants provided by the FPTL function and stored in the
instants
component of the j-th list in the sfptl
object.
Then, the time instants , where
provide a suitable partition of interval to approximate the f.p.t density
for the fixed value
of the initial distribution.
If the sfptl
object is of length 1, it comes from a conditioned f.p.t. problem. In this case we denote the interesting time
instants provided by the FPTL function and stored in the sfptl
object by ,
and
.
In what follows, is the integer part of
.
For each list in the sfptl
object the function computes
where
and
If variableStep = TRUE
, for and
, also computes
where
with
If , we then set
equal to
and
is recalculated.
where
with
when the sfptl
object is of length 1 and from.t0 = TRUE
, or the sfptl
object is of length greater than 1.
If , we then set
equal to
and
is recalculated.
where
with
when the sfptl
object is of length 1 and to.T = TRUE
, or the sfptl
object is of length greater than 1.
If , we then set
equal to
and
is recalculated.
and
are recommended; otherwise, some integration steps can be excessively large.
If the sfptl
object is of length 1 (conditioned f.p.t. problem), the suitable subintervals and integration steps that the function provides are:
If variableStep = TRUE
,
in subintervals
,
.
in subintervals
,
.
In these subintervals is possible to avoid applying the numerical algorithm to approximate the f.p.t. density provided that the
value of the approximate density at the time instant
is almost 0.
in subinterval
, if
from.t0 = TRUE
.
in subinterval
, if
to.T = TRUE
.
If variableStep = FALSE
the function computes
Then
If from.t0 = FALSE
and to.T = FALSE
, is readjusted to exactly split the interval
.
If from.t0 = TRUE
and to.T = FALSE
, is readjusted to exactly split the interval
.
If from.t0 = FALSE
and to.T = TRUE
, is readjusted to exactly split the interval
.
If from.t0 = TRUE
and to.T = TRUE
, is readjusted to exactly split the interval
.
is a suitable fixed integration step in subintervals
,
, and
,
;
in subintervals
if
from.t0 = TRUE
, and in
if
to.T = TRUE
. The endpoints of such subintervals
are readjusted according to this integration step.
If the sfptl
object is a list of length greater than 1 (unconditioned f.p.t problem), a common partition of
the interval is calculated from the suitable partitions of this interval for each
fixed value of the initial distribution.
Let, in unified form, ,
, the suitable integration steps
(calculated for each
in similar manner to the case of the
sfptl
object is of length 1) in
subintervals , with
and
,
.
Then, the ordered values of all time instants in the suitable partitions,
, provide a common suitable partition of the interval
in subintervals
,
,
where
and
.
For this partition, the function computes
, if
from.t0 = TRUE
.
, if
to.T = TRUE
.
Thus,
If variableStep = TRUE
, the suitable subintervals and integrations steps that the function provides are
in subintervals
,
.
in subinterval
, if
from.t0 = TRUE
.
in subinterval
, if
to.T = TRUE
.
Each integration step is readjusted to exactly split the corresponding subinterval.
If variableStep = FALSE
, a suitable fixed integration step for any subinterval is
In this case it is not possible to avoid applying the approximation algorithm in .
Then
If from.t0 = FALSE
and to.T = FALSE
, is readjusted to exactly split the interval
.
If from.t0 = TRUE
and to.T = FALSE
, is readjusted to exactly split the interval
.
If from.t0 = FALSE
and to.T = TRUE
, is readjusted to exactly split the interval
.
If from.t0 = TRUE
and to.T = TRUE
, is readjusted to exactly split the interval
.
is a suitable fixed integration step in subintervals
,
,
in subintervals
if
from.t0 = TRUE
, and in
if
to.T = TRUE
. The endpoints of such subintervals
are readjusted according to this integration step.
A two-component list:
H |
A matrix of subintervals and integrations steps that we must consider in order to approximate the f.p.t.
density according to the information contained in the |
skip |
A list of logical vectors indicating, for each subinterval, the values of the initial distribution for which we must check whether it is possible to avoid applying the numerical algorithm. |
Patricia Román-Román, Juan J. Serrano-Pérez and Francisco Torres-Ruiz.
Román, P., Serrano, J. J., Torres, F. (2008) First-passage-time location function: Application to determine first-passage-time densities in diffusion processes. Comput. Stat. Data Anal., 52, 4132–4146.
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.
Approx.fpt.density
to approximate f.p.t. densities from objects of class “summary.fptl” and create objects of class “fpt.density”.
summary.fptl
to locate the f.p.t. variable and create objects of class “summary.fptl” from objects of class
“fptl”.
FPTL
to evaluate the FPTL function and create objects of class “fptl”.
## Continuing the summary.fptl(.) example: Integration.Steps(yy) Integration.Steps(yy, from.t0 = TRUE) Integration.Steps(yy, to.T = TRUE, n = 100, p = 0.25) Integration.Steps(zz)
## Continuing the summary.fptl(.) example: Integration.Steps(yy) Integration.Steps(yy, from.t0 = TRUE) Integration.Steps(yy, to.T = TRUE, n = 100, p = 0.25) Integration.Steps(zz)
is.fpt.density
tests if its argument is an object of class “fpt.density”.
is.fpt.density(obj)
is.fpt.density(obj)
obj |
an R object to be tested. |
is.fpt.density
returns TRUE
or FALSE
depending on whether its argument is an object of class “fpt.density” or not.
An object of class “fpt.density” is a three-component list:
x |
a sequence of suitable time instants in |
y |
the approximate f.p.t. density function values on the x sequence for the unconditioned or conditioned problem at hand. |
y.x0 |
NULL for a conditioned f.p.t. problem or a matrix with the values, by columns, of the approximate f.p.t. densities conditioned to each considered value
|
It also includes six additional attributes. For more details, see the values of Approx.cfpt.density
and Approx.fpt.density
functions.
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.
## Testing fpt.density objects ## Continuing the Approx.cfpt.density example: is.fpt.density(yyy) ## Continuing the Approx.fpt.density example: is.fpt.density(yyy.cp) ## Not run: is.fpt.density(yyy.ucp) ## End(Not run)
## Testing fpt.density objects ## Continuing the Approx.cfpt.density example: is.fpt.density(yyy) ## Continuing the Approx.fpt.density example: is.fpt.density(yyy.cp) ## Not run: is.fpt.density(yyy.ucp) ## End(Not run)
This function creates a plot of the approximate density function for the conditioned or unconditioned f.p.t. problem at hand.
Optionally, it displays the information provided by the First-Passage-Time Location (FPTL) function for a conditioned problem.
Moreover, for an unconditioned problem creates an additional plot with all the approximate f.p.t.
densities conditioned to each value selected from the initial ditribution.
## S3 method for class 'fpt.density' plot(x, from.t0, to.T, dp.legend = TRUE, dp.legend.cex = 1, ylab = TRUE, growth.points = FALSE, instants = FALSE, ...)
## S3 method for class 'fpt.density' plot(x, from.t0, to.T, dp.legend = TRUE, dp.legend.cex = 1, ylab = TRUE, growth.points = FALSE, instants = FALSE, ...)
x |
an object of class “fpt.density”, a result of a call to |
from.t0 |
a logical value indicating whether the approximation should be plotted from the lower end of the
interval considered, |
to.T |
a logical value indicating whether the approximation should be plotted to the upper end of the
interval considered, |
dp.legend |
logical. If TRUE, adds a legend to the plot for identifying the diffusion process and boundary. |
dp.legend.cex |
the magnification to be used for legend relative to the current setting of |
ylab |
logical. If TRUE, adds a title for the y axis. |
growth.points |
logical. If TRUE, for a conditioned f.p.t. problem adds one or more vertical lines and labels to the plot of the approximate density function in order to identify the time instants from which the FPTL function starts growing. |
instants |
logical. If TRUE, for a conditioned f.p.t. problem adds vertical lines and labels to the plot of the approximate density function in order to identify the other points of interest provided by the FPTL function. |
... |
graphical parameters to set before generating the plot, see |
If from.t0
or to.T
arguments are missing the function considers the corresponding arguments used in the call to Approx.cfpt.density
or Approx.fpt.density
functions, which in turn generated the x
object.
If the approximate density functions were calculated from the lower end of the interval considered and from.t0 = FALSE
, the approximate density functions should be plotted from the lower endlimit of the first subinterval in the attribute Steps
of the x
object.
If the approximate density functions were calculated to the upper end of the interval considered and to.T = FALSE
, the approximate density functions should be plotted to the upper endlimit of last subinterval in the attribute Steps
of the x
object.
If dp.legend = TRUE
, a legend is placed in the top inside of each plot frame.
Additional graphical arguments as cex
, lwd
and ps
can be specified.
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.
FPTL
to know more about the FPTL function and objects of class “fptl”.
summary.fptl
to extract the information contained in objects of class “fptl” and create objects of class “summary.fptl”.
Approx.cfpt.density
to approximate the f.p.t. density from objects of class “summary.fptl” and create objects of class “fpt.density”.
Approx.fpt.density
to approximate the f.p.t. density from objects of class “dp” and create objects of class “fpt.density”.
## Continuing the Approx.cfpt.density(.) example: plot(yyy) plot(yyy, from.t0 = TRUE) plot(yyy, growth.points = TRUE) plot(yyy, growth.points = TRUE, instants = TRUE) plot(yyy, dp.legend = FALSE, growth.points = TRUE, instants = TRUE) plot(yyy, cex = 1.25, cex.main = 1.15) plot(yyy, cex = 1.25, cex.main = 1.15, dp.legend.cex = 0.8, growth.points = TRUE, instants = TRUE) ## Continuing the Approx.fpt.density example: plot(yyy.cp) ## Not run: plot(yyy.ucp) ## End(Not run)
## Continuing the Approx.cfpt.density(.) example: plot(yyy) plot(yyy, from.t0 = TRUE) plot(yyy, growth.points = TRUE) plot(yyy, growth.points = TRUE, instants = TRUE) plot(yyy, dp.legend = FALSE, growth.points = TRUE, instants = TRUE) plot(yyy, cex = 1.25, cex.main = 1.15) plot(yyy, cex = 1.25, cex.main = 1.15, dp.legend.cex = 0.8, growth.points = TRUE, instants = TRUE) ## Continuing the Approx.fpt.density example: plot(yyy.cp) ## Not run: plot(yyy.ucp) ## End(Not run)
This function creates a plot of the First-Passage-Time Location (FPTL) function for a first-passage-time problem, displaying the information of interest contained in an object of class “fptl” and a corresponding object of class “summary.fptl”.
## S3 method for class 'fptl' plot(x, sfptl, from.t0 = TRUE, to.T = TRUE, dp.legend = TRUE, dp.legend.cex = 1, ylab = TRUE, growth.points = TRUE, instants = TRUE, ...)
## S3 method for class 'fptl' plot(x, sfptl, from.t0 = TRUE, to.T = TRUE, dp.legend = TRUE, dp.legend.cex = 1, ylab = TRUE, growth.points = TRUE, instants = TRUE, ...)
x |
an object of class “fptl”, a result of a call to |
sfptl |
an object of class “summary.fptl”, a result of applying the |
from.t0 |
a logical value indicating whether the FPTL function should be plotted from the lower end of the
interval considered, |
to.T |
a logical value indicating whether the approximation should be plotted to the upper end of the
interval considered, |
dp.legend |
logical. If TRUE, adds a legend to the plot in order to identify the diffusion process
and boundary used in the call to |
dp.legend.cex |
the magnification to be used for legend relative to the current setting of |
ylab |
logical. If TRUE, adds a title for the y axis. |
growth.points |
logical. If TRUE, adds one or more vertical lines and labels to the plot in order to identify the time instants from which the FPTL function starts growing. |
instants |
logical. If TRUE, draws and identify the other points of interest provided by the FPTL function. |
... |
graphical parameters to set before generating the plot, see |
If the sfptl
object is missing, the function makes an internal call to the summary.fptl
function in order to identify the points of interest provided by the FPTL function.
If the FPTL function shows at least a local maximum and from.t0 = FALSE
, the FPTL function should be plotted from the first time instant from which the function starts growing.
If the FPTL function shows at least a local maximum and to.T = FALSE
, the FPTL function should be plotted to the value related to the last local maximum
if the function does not decrease subsequently, or to the local minimum following the last local maximum
if the function decreases subsequently.
If dp.legend = TRUE
, a legend is placed in the top inside of the plot frame.
Additional graphical arguments as cex
, lwd
and ps
can be specified.
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.
FPTL
to know more about the FPTL function and objects of class “fptl”.
summary.fptl
for extract the information of interest in an object of class “fptl”.
## Continuing the FPTL(.) example: plot(y) plot(y, cex.main = 1.4, growth.points = FALSE) plot(y, cex.main = 1.4, growth.points = FALSE, instants = FALSE) plot(y, cex.main = 1.4, dp.legend = FALSE, growth.points = FALSE, instants = FALSE) plot(y, cex = 1.25, cex.main = 1.25) plot(y, cex = 1.25, cex.main = 1.25, dp.legend.cex = 0.8) plot(z) plot(z, from.t0 = FALSE) plot(z, to.T = FALSE) plot(z, from.t0 = FALSE, to.T = FALSE)
## Continuing the FPTL(.) example: plot(y) plot(y, cex.main = 1.4, growth.points = FALSE) plot(y, cex.main = 1.4, growth.points = FALSE, instants = FALSE) plot(y, cex.main = 1.4, dp.legend = FALSE, growth.points = FALSE, instants = FALSE) plot(y, cex = 1.25, cex.main = 1.25) plot(y, cex = 1.25, cex.main = 1.25, dp.legend.cex = 0.8) plot(z) plot(z, from.t0 = FALSE) plot(z, to.T = FALSE) plot(z, from.t0 = FALSE, to.T = FALSE)
print.fpt.density
shows an object of class “fpt.density”.
## S3 method for class 'fpt.density' print(x, ...)
## S3 method for class 'fpt.density' print(x, ...)
x |
an object of class “fpt.density”. |
... |
Since the length of components of an object of class “fpt.density” is usually large, the print.fpt.density
function does not display such object as a list, but in its ‘basic’ structure instead. However, each component can be displayed separately in the usual way.
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.
## Continuing the Approx.cfpt.density example: yyy print(yyy, digits=10) ## Continuing the Approx.fpt.density example: yyy.cp ## Not run: yyy.ucp ## End(Not run)
## Continuing the Approx.cfpt.density example: yyy print(yyy, digits=10) ## Continuing the Approx.fpt.density example: yyy.cp ## Not run: yyy.ucp ## End(Not run)
report
is a function used to generate a report of the results of various statistical methods.
The function invokes particular ‘methods’ which depend on the ‘class’ of the first argument.
report(obj, ...)
report(obj, ...)
obj |
an object for which a report is desired. |
... |
additional arguments affecting the report generated. |
The functions report.summary.fptl
and report.fpt.density
are examples
of particular methods which report objects of class “summary.fptl” and “fpt.density”.
The form of the value returned by report
depends on the class of its argument.
Patricia Román-Román, Juan J. Serrano-Pérez and Francisco Torres-Ruiz.
A report is generated with the information contained in an object of class “fpt.density”.
## S3 method for class 'fpt.density' report(obj, report.sfptl = FALSE, tex = FALSE, digits = 8, ...)
## S3 method for class 'fpt.density' report(obj, report.sfptl = FALSE, tex = FALSE, digits = 8, ...)
obj |
an object of class “fpt.density”, a result of a call to |
report.sfptl |
logical. If TRUE, also writes a report with the information contained in the object of class “summary.fptl”
from which the |
tex |
logical, specifies whether to generate formatted LaTeX output ( |
digits |
integer indicating the significant digits to be used. |
... |
additional arguments potentially passed (currently none is considered). |
The resulting report can be recicled by copy-and-pasting into a document (if tex = FALSE
)
or directly included into a LaTeX file (if tex = TRUE
).
Send the report to the command windows.
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.
Approx.cfpt.density
to approximate the f.p.t. density from objects of class “summary.fptl” and to create objects of class “fpt.density”.
Approx.fpt.density
to approximate the f.p.t. density from objects of class “dp” and to create objects of class “fpt.density”.
is.fpt.density
to test whether an object is an object of class “fpt.density”.
## Continuing the Approx.cfpt.density(.) example: report(yyy, digits = 4) report(yyy, report.sfptl = TRUE, digits = 4) report(yyy, tex = TRUE, digits = 4) report(yyy, report.sfptl = TRUE, tex = TRUE, digits = 4) ## Continuing the Approx.fpt.density(.) example: report(yyy.cp) ## Not run: report(yyy.ucp) ## End(Not run)
## Continuing the Approx.cfpt.density(.) example: report(yyy, digits = 4) report(yyy, report.sfptl = TRUE, digits = 4) report(yyy, tex = TRUE, digits = 4) report(yyy, report.sfptl = TRUE, tex = TRUE, digits = 4) ## Continuing the Approx.fpt.density(.) example: report(yyy.cp) ## Not run: report(yyy.ucp) ## End(Not run)
A report is generated with the information contained in an object of class “summary.fptl”.
## S3 method for class 'summary.fptl' report(obj, tex = FALSE, digits = 8, heading = TRUE, ...)
## S3 method for class 'summary.fptl' report(obj, tex = FALSE, digits = 8, heading = TRUE, ...)
obj |
an object of class “summary.fptl”, a result of a call to |
tex |
logical, specifies whether to generate formatted LaTeX output ( |
digits |
integer indicating the significant digits to be used. |
heading |
logical, specifies whether to include information about the diffusion process and the boundary ( |
... |
additional arguments potentially passed (currently none is considered). |
The resulting report can be recicled by copy-and-pasting into a document (if tex = FALSE
)
or directly included into a LaTeX file (if tex = TRUE
).
Send the report to the command windows.
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.
summary.fptl
to create objects of class “summary.fptl” from objects of class
“fptl”.
Approx.fpt.density
to create objects of class “fpt.density” with the attribute summary.fptl
of class “summary.fptl”
is.summary.fptl
to test whether an object is of class “summary.fptl”.
## Continuing the summary.fptl(.) example: report(yy, digits = 4) report(yy, tex = TRUE, digits = 4) report(zz) report(zz, tex = TRUE)
## Continuing the summary.fptl(.) example: report(yy, digits = 4) report(yy, tex = TRUE, digits = 4) report(zz) report(zz, tex = TRUE)
summary.fptl
summary method for class “fptl”.
is.summary.fptl
tests if its argument is an object of class “summary.fptl”.
print.summary.fptl
shows an object of class “summary.fptl”.
## S3 method for class 'fptl' summary(object, zeroSlope = 0.01, p0.tol = 8, k = 3, ...) is.summary.fptl(obj) ## S3 method for class 'summary.fptl' print(x, ...)
## S3 method for class 'fptl' summary(object, zeroSlope = 0.01, p0.tol = 8, k = 3, ...) is.summary.fptl(obj) ## S3 method for class 'summary.fptl' print(x, ...)
object |
an object of class ‘fptl’, a result of a call to |
obj |
an R object to be tested. |
x |
an object of class ‘summary.fptl’, a result of a call to |
zeroSlope |
maximum slope required to consider that a growing function is constant. |
p0.tol |
controls where the First-Passage-Time Location function begins to increase significantly. |
k |
controls whether the First-Passage-Time Location function decreases very slowly. |
... |
other arguments passed to functions. |
The summary.fptl
function extracts the information contained in object
about the
location of the variation range of a conditioned first-passage-time (f.p.t.) variable.
It makes an internal call to growth.intervals
function in order to determine the time instants
, from which the First-Passage-Time Location (FPTL)
function starts growing, and its local maximums
. For this,
zeroSlope
argument
is considered.
If there is no growth subinterval, the execution of the function summary.fptl
is stopped and an error is reported.
Otherwise, for each of the subintervals the function determines:
The first time instant at which the function is bigger than
or equal to
where and
is the ratio of the global increase of the function in the growth subinterval
that
should be reached to consider that it begins to increase significantly.
The first time instant at which the FPTL function is
bigger than or equal to
The last time instant at which the FPTL function is bigger
than or equal to
where
and
print.summary.fptl
displays an object of class “summary.fptl” for immediate understanding of the information it contains.
The summary.fptl
function computes and returns an object of class “summary.fptl” and length 1.
An object of class “summary.fptl” is a list of length 1 for a conditioned f.p.t problem, or of the same length as the number of
values selected from the non-degenerate initial distribution for an unconditioned f.p.t problem.
Each component of the list is again a named list with two components:
instants |
a matrix whose columns correspond to |
FPTLValues |
the matrix of values of the FPTL function on |
It also includes four additional attributes:
Call |
a list of the unevaluated calls to the summary.fptl function, substituting each name |
in these calls by its value when the latter has length 1. | |
FPTLCall |
a list of the unevaluated calls to the FPTL function that resulted in the objects |
used as object argument in Call . |
|
dp |
the common object used as dp argument in the unevaluated calls to the FPTL |
function in FPTLCall . |
|
vars |
NULL or a list containing the common values of names in FPTLCall for those names |
with values of length greater than 1. | |
For an unconditioned f.p.t problem, the object includes the additional attribute id
specifying the non-degenerate initial distribution.
The attribute “summary.fptl
” of the value (of class “fpt.density”) of the Approx.fpt.density
function is
an object of class summary.fptl
of length 1 for a conditioned problem, and of length greather than 1 for an unconditioned problem.
It is created from one or successive internal calls to the summary.fptl
function.
is.summary.fptl
returns TRUE
or FALSE
depending on whether its argument is an object of class
“summary.fptl” or not.
Patricia Román-Román, Juan J. Serrano-Pérez and Francisco Torres-Ruiz.
Román, P., Serrano, J. J., Torres, F. (2008) First-passage-time location function: Application to determine first-passage-time densities in diffusion processes. Comput. Stat. Data Anal., 52, 4132–4146.
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.
Approx.cfpt.density
to approximate densities of f.p.t. variables conditioned to a fixed initial value
from objects of class “summary.fptl” and create objects of class “fpt.density”.
Approx.fpt.density
to approximate densities of conditioned or unconditioned f.p.t. variables and create objects of
class “fpt.density” from objects of class “dp”.
FPTL
to evaluate the FPTL function and create objects of class “fptl”.
report.summary.fptl
to generate a report.
growth.intervals
to study the growth of the vector of values resulting from the evaluation of a function.
## Continuing the FPTL(.) example: ## Summarizing an object of class fptl yy <- summary(y) yy print(yy, digits=10) yy1 <- summary(y, zeroSlope = 0.001) yy1 yy2 <- summary(y, zeroSlope = 0.001, p0.tol = 10) yy2 zz <- summary(z) zz ## Testing summary.fptl objects is.summary.fptl(yy) is.summary.fptl(zz)
## Continuing the FPTL(.) example: ## Summarizing an object of class fptl yy <- summary(y) yy print(yy, digits=10) yy1 <- summary(y, zeroSlope = 0.001) yy1 yy2 <- summary(y, zeroSlope = 0.001, p0.tol = 10) yy2 zz <- summary(z) zz ## Testing summary.fptl objects is.summary.fptl(yy) is.summary.fptl(zz)