sampWiener {WienR}R Documentation

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:

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:

Value

A list of the class Diffusion_samp containing

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)

[Package WienR version 0.3-15 Index]