Package 'WienR'

Title: Derivatives of the First-Passage Time Density and Cumulative Distribution Function, and Random Sampling from the (Truncated) First-Passage Time Distribution
Description: First, we provide functions to calculate the partial derivative of the first-passage time diffusion probability density function (PDF) and cumulative distribution function (CDF) with respect to the first-passage time t (only for PDF), the upper barrier a, the drift rate v, the relative starting point w, the non-decision time t0, the inter-trial variability of the drift rate sv, the inter-trial variability of the rel. starting point sw, and the inter-trial variability of the non-decision time st0. In addition the PDF and CDF themselves are also provided. Most calculations are done on the logarithmic scale to make it more stable. Since the PDF, CDF, and their derivatives are represented as infinite series, we give the user the option to control the approximation errors with the argument 'precision'. For the numerical integration we used the C library cubature by Johnson, S. G. (2005-2013) <https://github.com/stevengj/cubature>. Numerical integration is required whenever sv, sw, and/or st0 is not zero. Note that numerical integration reduces speed of the computation and the precision cannot be guaranteed anymore. Therefore, whenever numerical integration is used an estimate of the approximation error is provided in the output list. Note: The large number of contributors (ctb) is due to copying a lot of C/C++ code chunks from the GNU Scientific Library (GSL). Second, we provide methods to sample from the first-passage time distribution with or without user-defined truncation from above. The first method is a new adaptive rejection sampler building on the works of Gilks and Wild (1992; <doi:10.2307/2347565>) and Hartmann and Klauer (in press). The second method is a rejection sampler provided by Drugowitsch (2016; <doi:10.1038/srep20490>). The third method is an inverse transformation sampler. The fourth method is a "pseudo" adaptive rejection sampler that builds on the first method. For more details see the corresponding help files.
Authors: Raphael Hartmann [aut, cre], Karl C. Klauer [cph, aut, ctb, ths], Steven G. Johnson [ctb], Jean M. Linhart [ctb], Brian Gough [ctb], Gerard Jungman [ctb], Rudolf Schuerer [ctb], Przemyslaw Sliwa [ctb], Jason H. Stover [ctb]
Maintainer: Raphael Hartmann <[email protected]>
License: GPL (>= 2)
Version: 0.3-16
Built: 2025-01-20 04:55:17 UTC
Source: https://github.com/raphaelhartmann/wienr

Help Index


Partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the upper barrier

Description

Calculates the partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the upper barrier a.

Usage

daWienerCDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the CDF with respect to a,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

daWienerCDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

Partial derivative of the first-passage time probability density function of the diffusion model with respect to the upper barrier

Description

Calculates the partial derivative of the first-passage time probability density function of the diffusion model with respect to the upper barrier a.

Usage

daWienerPDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the PDF with respect to a,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

daWienerPDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

Wrapper function for the partial derivative of the first-passage time probability density function of the diffusion model

Description

Calculates the partial derivative of the first-passage time probability density function of the diffusion model with respect to one of t, a, v, w, t0, sv, sw, or st0, or calculate the gradient.

Usage

ddWDM(
  wrt,
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

wrt

partial derivative w.r.t. one of the following:

  • "t" the first-passage time,

  • "a" the upper barrier,

  • "v" the drift rate,

  • "w" the relative starting point,

  • "t0" the non-decision time,

  • "sv" the inter-trial variability of drift rate,

  • "sw" the inter-trial variability of relative starting point,

  • "st0" the inter-trial variability of non-decision time, or

  • "grad" all the above but t.

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the PDF with respect to the chosen wrt,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

ddWDM(wrt = "a", t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

Wrapper function for the partial derivative of the first-passage time cumulative distribution function of the diffusion model

Description

Calculates the partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to one of a, v, w, t0, sv, sw, or st0, or calculate the gradient.

Usage

dpWDM(
  wrt,
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

wrt

partial derivative w.r.t. one of the following:

  • "a" the upper barrier,

  • "v" the drift rate,

  • "w" the relative starting point,

  • "t0" the non-decision time,

  • "sv" the inter-trial variability of drift rate,

  • "sw" the inter-trial variability of relative starting point,

  • "st0" the inter-trial variability of non-decision time, or

  • "grad" all the above.

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the CDF with respect to the chosen wrt,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dpWDM(wrt = "a", t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

Partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the inter-trial variability of the non-decision time

Description

Calculates the partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the inter-trial variability of the non-decision time st0.

Usage

dst0WienerCDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the CDF with respect to w,

  • call: the function call,

  • err: the absolute error.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dst0WienerCDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, t0 = .3, st0 = .1)

Partial derivative of the first-passage time probability density function of the diffusion model with respect to the inter-trial variability of the non-decision time

Description

Calculates the partial derivative of the first-passage time probability density function of the diffusion model with respect to the inter-trial variability of the non-decision time st0.

Usage

dst0WienerPDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional numeric value. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the PDF with respect to a,

  • call: the function call,

  • err: the absolute error.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dst0WienerPDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, st0 = .2)

Partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the inter-trial variability of the drift rate

Description

Calculates the partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the inter-trial variability of the drift rate sv.

Usage

dsvWienerCDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the CDF with respect to w,

  • call: the function call,

  • err: the absolute error.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dsvWienerCDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, sv = .1)

Partial derivative of the first-passage time probability density function of the diffusion model with respect to the inter-trial variability of the drift rate

Description

Calculates the partial derivative of the first-passage time probability density function of the diffusion model with respect to the inter-trial variability of the drift rate sv.

Usage

dsvWienerPDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional numeric value. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the PDF with respect to a,

  • call: the function call,

  • err: the absolute error.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dsvWienerPDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, sv = .2)

Partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the inter-trial variability of the relative starting point

Description

Calculates the partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the inter-trial variability of the relative starting point sw.

Usage

dswWienerCDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the CDF with respect to w,

  • call: the function call,

  • err: the absolute error.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dswWienerCDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, sw = .1)

Partial derivative of the first-passage time probability density function of the diffusion model with respect to the inter-trial variability of the relative starting point

Description

Calculates the partial derivative of the first-passage time probability density function of the diffusion model with respect to the inter-trial variability of the relative starting point sw.

Usage

dswWienerPDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional numeric value. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the PDF with respect to a,

  • call: the function call,

  • err: the absolute error.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dswWienerPDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, sw = .2)

Partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the non-decision time

Description

Calculates the partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the non-decision time t0.

Usage

dt0WienerCDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the CDF with respect to w,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dt0WienerCDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

Partial derivative of the first-passage time probability density function of the diffusion model with respect to the non-decision time

Description

Calculates the partial derivative of the first-passage time probability density function of the diffusion model with respect to the non-decision time t0.

Usage

dt0WienerPDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the PDF with respect to w,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dt0WienerPDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6)

Partial derivative of the first-passage time probability density function of the diffusion model with respect to the first-passage time

Description

Calculates the partial derivative of the first-passage time probability density function of the diffusion model with respect to the first-passage time t.

Usage

dtWienerPDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional numeric value. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the PDF with respect to a,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dtWienerPDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

Partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the drift rate

Description

Calculates the partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the drift rate v.

Usage

dvWienerCDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the CDF with respect to v,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dvWienerCDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

Partial derivative of the first-passage time probability density function of the diffusion model with respect to the drift rate

Description

Calculates the partial derivative of the first-passage time probability density function of the diffusion model with respect to the drift rate v.

Usage

dvWienerPDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the PDF with respect to v,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dvWienerPDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

Partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the relative starting point

Description

Calculates the partial derivative of the first-passage time cumulative distribution function of the diffusion model with respect to the relative starting point w.

Usage

dwWienerCDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the CDF with respect to w,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dwWienerCDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

Partial derivative of the first-passage time probability density function of the diffusion model with respect to the relative starting point

Description

Calculates the partial derivative of the first-passage time probability density function of the diffusion model with respect to the relative starting point w.

Usage

dwWienerPDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the PDF with respect to w,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

dwWienerPDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

Gradient of the first-passage time cumulative distribution function

Description

Calculates the gradient of the first-passage time cumulative distribution function.

Usage

gradWienerCDF(
  t,
  response,
  a,
  v,
  w,
  t0,
  sv,
  sw,
  st0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the CDF with respect to a, v, w, t0, sv, sw, and st0,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

gradWienerCDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6,
              t0 = .3, sv = .1, sw = .1, st0 = .1)

Gradient of the first-passage time probability density function

Description

Calculates the gradient of the first-passage time probability density function.

Usage

gradWienerPDF(
  t,
  response,
  a,
  v,
  w,
  t0,
  sv,
  sw,
  st0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the partial derivative. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_deriv containing

  • deriv: the derivatives of the PDF with respect to a, v, w, t0, sv, sw, and st0,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

gradWienerPDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6,
              t0 = .3, sv = .1, sw = .1, st0 = .1)

Random sampling from the Wiener diffusion model

Description

Draws random samples from the (truncated) first-passage time distribution of the Wiener diffusion model with up to 7 parameters.

Usage

sampWiener(
  N,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  response = "both",
  bound = Inf,
  method = "ars",
  precision = NULL,
  n.threads = 1,
  ars_list = NULL,
  ARS_STORE = FALSE
)

rWDM(
  N,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  response = "both",
  bound = Inf,
  method = "ars",
  precision = NULL,
  n.threads = 1,
  ars_list = NULL,
  ARS_STORE = FALSE
)

Arguments

N

Number of samples. Numeric value (integer).

a

Upper barrier. Numeric value.

v

Drift rate. Numeric value.

w

Relative starting point. Numeric value.

t0

Non-decision time. Numeric value.

sv

Inter-trial variability of drift rate. Numeric value. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric value. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric value. Range of uniform distribution U(t0, t0+st0).

response

Response boundary. Character string, either "upper", "lower", or "both". Alternatively a numeric value, 2=upper, 1=lower, or 0=both. Default is "both".

bound

Boundary for the first-passage time. Numeric value. Default is Inf.

method

Sampling method. Either "ars", "rs", "its", or "p-ars". The method "ars" stands for adaptive rejection sampling, "rs" stands for rejection sampling, "its" stands for inverse transform sampling, and "p-ars" stands for pseudo adaptive rejection sampling. Default is "ars".

precision

Optional numeric value. Precision of the infinite series approximation. Numeric value. Default is NULL, which takes default value 1e-12.

n.threads

Optional numeric or logic value. Number of threads to use. If not provided (FALSE or 1) parallelization is not used. If set to TRUE then all available threads are used.

ars_list

Optional list for method "ars". For response "lower" or "upper" a list with upper hull, lower hull etc. is needed. For response "both" a list with two lists must be provided. The corresponding list is produced when using the "ars" method and the argument ARS_STORE = TRUE. Do not make the list yourself and do not mix the lists for the corresponding boundaries.

ARS_STORE

Optional flag for method "ars". If TRUE saves upper hull, lower hull and some more values, which are updated at each rejection step, as a list. The list can then be used with the "ars" method in the argument ars_list to make the new sampling faster. If the first-passage times were sampled only from one boundary then the list will contain upper hull, etc. and if they were sampled from both boundaries then the list consists of two lists, each containing upper hull, etc. for the respective boundary.

Details

The following methods can be used:

  • "ars": adaptive rejection sampling method. This method builds on Gilks and Wild (1992) as well as Hartmann and Klauer (in press). The former provides a method for an adaptive rejection sampling method which assumes that the density is log-concave. This method is fastest for cases where sv = 0. This is the only method where the integral needs to be calculated. The advantage, though, is that after each rejection the upper and lower hull functions will be adapted (or updated), which leads to fewer and fewer rejections in the proceeding sampling steps.

  • "rs": rejection sampling method by Drugowitsch (2016). This method uses different proposal distributions in different conditions.

  • "its": inverse transform (a.k.a. probability integral transform) sampling method. A random sample u is sampled from a uniform distribution and the corresponding first-passage time, for which CDF(t) = u, is approximated.

  • "p-ars": pseudo-adaptive rejection sampling. A variation of "ars". In this method the hull functions will be adapted until the current sample is drawn, but the information from this adaptation will be discarded for the next sample.

Note: The speed of the methods do not depend on t0 or st0.

ars_store, one of the returned list objects if method "ars" and ARS_STORE = TRUE, consists of twelve vectors and three scalars:

  • hstore_x: vector of alpha values – change of variable alpha = (log(t)-start)/scale, where t is the first-passage time – relevant for the upper and lower hull functions.

  • hstore_h: vector of log-density of change of variable A = (log(T)-start)/scale at the alpha points hstore_x

  • hstore_dh: vector of partial derivative of log-density of A with respect to alpha.

  • upperstore_z: vector of alpha values at which the piece-wise linear upper hull transitions from one linear segment to the next.

  • upperstore_slope: same as hstore_dh. Gives the slope of the piece-wise linear functions for the upper hull.

  • upperstore_absc: same as hstore_h. Gives the evaluation of the function h() at hstore_x, where the piece-wise linear function touches h().

  • upperstore_center: same as hstore_x. Gives the alpha values, where the piece-wise linear function touches h().

  • lowerstore_z: same as hstore_x but with an additional leading element (=-Inf) in the vector.

  • lowerstore_slope: vector of zeros since not needed.

  • lowerstore_absc: vector of zeros since not needed.

  • lowerstore_center:: vector of zeros since not needed.

  • startstore: scalar representing the "start" value for the change of variable A = (log(T)-start)/scale.

  • scalestore: scalar representing the "scale" value for the change of variable A = (log(T)-start)/scale.

  • normstore: scalar. Gives the value of h() at alpha = 0.

  • sstore: vector of values at log(s_k(hstore_x)), where s_k() is the function defined in equation 3 in Gilks and Wild (1992).

Value

A list of the class Diffusion_samp containing

  • q: first-passage time sample(s),

  • response: response(s) "lower" and/or "upper",

  • call: the function call,

  • ars_store: if ARS_STORE = TRUE is used with the method "ars" then either a list with upper hull, etc. is stored (either from the upper or lower boundary) or a list of two lists with corresponding upper hull, etc. is stored (from both boundaries) and can be used as function argument to (ars_list) for further sampling with the same parameters.

Author(s)

Raphael Hartmann

References

Drugowitsch, J. (2016). Fast and accurate Monte Carlo sampling of first-passage times from Wiener diffusion models. Scientific Reports, 6(1). doi:10.1038/srep20490

Gilks, W. R., & Wild, P. (1992). Adaptive Rejection Sampling for Gibbs Sampling. Applied Statistics, 41(2), 337. doi:10.2307/2347565

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

sample_list1 <- sampWiener(N = 100000, a = 1, v = .3, w = .5)
hist(sample_list1$q, 200)

sample_list2 <- sampWiener(N = 100000, a = 1, v = .3, w = .5, ARS_STORE = TRUE)
hist(sample_list2$q, 200)
sample_list2$ars_store

sample_list3 <- sampWiener(N = 100000, a = 1, v = .3, w = .5, ars_list = sample_list2$ars_store)
hist(sample_list3$q, 200)


sample_list1 <- rWDM(N = 100000, a = 1, v = .3, w = .5)
hist(sample_list1$q, 200)

sample_list2 <- rWDM(N = 100000, a = 1, v = .3, w = .5, ARS_STORE = TRUE)
hist(sample_list2$q, 200)
sample_list2$ars_store

sample_list3 <- rWDM(N = 100000, a = 1, v = .3, w = .5, ars_list = sample_list2$ars_store)
hist(sample_list3$q, 200)

First-passage time cumulative distribution function of the diffusion model

Description

Calculates the first-passage time cumulative distribution function of the diffusion model.

Usage

WienerCDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

pWDM(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the CDF. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_cdf containing

  • cdf: the CDF,

  • logcdf: the log-transformed CDF,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2012). Fast and accurate calculations for cumulative first-passage time distributions in Wiener diffusion models. Journal of Mathematical Psychology, 56(6), 470–475. doi:10.1016/j.jmp.2012.09.002

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and even more accurate first-passage time densities and distributions for the Wiener diffusion model. Journal of Mathematical Psychology, 60, 20–22. doi:10.1016/j.jmp.2014.05.002

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Examples

WienerCDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)
pWDM(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

First-passage time probability density function of the diffusion model

Description

Calculate the first-passage time probability density function of the diffusion model.

Usage

WienerPDF(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

dWDM(
  t,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

t

First-passage time. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the PDF. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_pdf containing

  • pdf: the PDF,

  • logpdf: the log-transformed PDF,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

References

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passage time distribution for the diffusion model with variable drift. Journal of Mathematical Psychology, 76, 7–12. doi:10.1016/j.jmp.2016.11.003

Foster, K., & Singmann, H. (2021). Another Approximation of the First-Passage Time Densities for the Ratcliff Diffusion Decision Model. arXiv preprint arXiv:2104.01902.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and even more accurate first-passage time densities and distributions for the Wiener diffusion model. Journal of Mathematical Psychology, 60, 20–22. doi:10.1016/j.jmp.2014.05.002

Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. doi:10.1016/j.jmp.2021.102550

Navarro, D. J., & Fuss, I. G. (2009). Fast and accurate calculations for first-passage times in Wiener diffusion models. Journal of Mathematical Psychology, 53(4), 222–230. doi:10.1016/j.jmp.2009.02.003

Wabersich, D., & Vandekerckhove, J. (2014). The RWiener Package: an R Package Providing Distribution Functions for the Wiener Diffusion Model. The R Journal, 6(1), 49. doi:10.32614/rj-2014-005

Examples

WienerPDF(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)
dWDM(t = 1.2, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)

First-passage time quantile function of the diffusion model

Description

Calculates the first-passage time quantile function of the diffusion model.

Usage

WienerQuant(
  p,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

qWDM(
  p,
  response,
  a,
  v,
  w,
  t0 = 0,
  sv = 0,
  sw = 0,
  st0 = 0,
  precision = NULL,
  K = NULL,
  n.threads = FALSE,
  n.evals = 6000
)

Arguments

p

Probability. Numeric vector.

response

Response boundary. Character vector with "upper" and "lower" as possible values. Alternatively a numeric vector with 1=lower and 2=upper.

a

Upper barrier. Numeric vector.

v

Drift rate. Numeric vector.

w

Relative starting point. Numeric vector.

t0

Non-decision time. Numeric vector

sv

Inter-trial variability of drift rate. Numeric vector. Standard deviation of a normal distribution N(v, sv).

sw

Inter-trial variability of relative starting point. Numeric vector. Range of uniform distribution U(w-0.5*sw, w+0.5*sw).

st0

Inter-trial variability of non-decision time. Numeric vector. Range of uniform distribution U(t0, t0+st0).

precision

Optional numeric value. Precision of the CDF. Numeric value. Default is NULL, which takes default value 1e-12.

K

Optional. Number of iterations to calculate the infinite sums. Numeric value (integer). Default is NULL.

  • precision = NULL and K = NULL: Default precision = 1e-12 used to calculate internal K.

  • precision != NULL and K = NULL: precision is used to calculate internal K,

  • precision = NULL and K != NULL: K is used as internal K,

  • precision != NULL and K != NULL: if internal K calculated through precision is smaller than K, K is used.

We recommend using either default (precision = K = NULL) or only precision.

n.threads

Optional numerical or logical value. Number of threads to use. If not provided (or 1 or FALSE) parallelization is not used. If set to TRUE then all available threads are used.

n.evals

Optional. Number of maximal function evaluations in the numeric integral if sv, sw, and/or st0 are not zero. Default is 6000 and 0 implies no limit and the numeric integration goes on until the specified precision is guaranteed.

Value

A list of the class Diffusion_cdf containing

  • q: the quantile,

  • logq: the log-transformed quantile,

  • call: the function call,

  • err: the absolute error. Only provided if sv, sw, or st0 is non-zero. If numerical integration is used, the precision cannot always be guaranteed.

Author(s)

Raphael Hartmann

Examples

WienerQuant(p = .3, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)
qWDM(p = .3, response = "upper", a = 1.1, v = 2, w = .6, precision = NULL, K = NULL)