sampWiener: Random sampling from the Wiener diffusion model

Description Usage Arguments Details Value Author(s) References Examples

View source: R/sampWiener.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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
)

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. (in press). Partial Derivatives for the First-Passage Time Distribution in Wiener Diffusion Models. Journal of Mathematical Psychology.

Examples

1
2
3
4
5
6
7
8
9
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)

WienR documentation built on Nov. 25, 2021, 5:06 p.m.

Related to sampWiener in WienR...