Description Usage Arguments Details Value Author(s) References Examples
Draws random samples from the (truncated) firstpassage time distribution of the Wiener diffusion model with up to 7 parameters.
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
)

N 
Number of samples. Numeric value (integer). 
a 
Upper barrier. Numeric value. 
v 
Drift rate. Numeric value. 
w 
Relative starting point. Numeric value. 
t0 
Nondecision time. Numeric value. 
sv 
Intertrial variability of drift rate. Numeric value. Standard deviation of a normal distribution 
sw 
Intertrial variability of relative starting point. Numeric value. Range of uniform distribution 
st0 
Intertrial variability of nondecision time. Numeric value. Range of uniform distribution 
response 
Response boundary. Character string, either 
bound 
Boundary for the firstpassage time. Numeric value. Default is Inf. 
method 
Sampling method. Either "ars", "rs", "its", or "pars". The method "ars" stands for adaptive rejection sampling, "rs" stands for rejection sampling, "its" stands for inverse transform sampling, and "pars" stands for pseudo adaptive rejection sampling. Default is "ars". 
precision 
Optional numeric value. Precision of the infinite series approximation. Numeric value. Default is 
n.threads 
Optional numeric or logic value. Number of threads to use. If not provided ( 
ars_list 
Optional list for method "ars". For 
ARS_STORE 
Optional flag for method "ars". If 
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 logconcave. 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 firstpassage time, for which CDF(t) = u, is approximated.
"pars"
: pseudoadaptive 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 firstpassage time – relevant for the upper and
lower hull functions.
hstore_h
: vector of logdensity of change of variable A = (log(T)start)/scale
at the alpha points hstore_x
hstore_dh
: vector of partial derivative of logdensity of A with respect to alpha.
upperstore_z
: vector of alpha values at which the piecewise linear upper hull transitions from one linear segment to the next.
upperstore_slope
: same as hstore_dh
. Gives the slope of the piecewise linear functions for the upper hull.
upperstore_absc
: same as hstore_h
. Gives the evaluation of the function h() at hstore_x
, where the piecewise linear function touches h().
upperstore_center
: same as hstore_x
. Gives the alpha values, where the piecewise 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).
A list of the class Diffusion_samp
containing
q
: firstpassage 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.
Raphael Hartmann
Drugowitsch, J. (2016). Fast and accurate Monte Carlo sampling of firstpassage 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 FirstPassage Time Distribution in Wiener Diffusion Models. Journal of Mathematical Psychology.
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)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.