Learn R Programming

rtdists (version 0.12-0)

RDM: The Racing Diffusion Model (RDM)

Description

Density, distribution, quantile, and random generation functions for the racing diffusion model (RDM) with any number of response alternatives.

Usage

dRDM(rt, response, A, b, t0, v, s = 1, st0 = 0, silent = FALSE)

pRDM(rt, response, A, b, t0, v, s = 1, st0 = 0, silent = FALSE)

qRDM( p, response, A, b, t0, v, s = 1, st0 = 0, silent = FALSE, interval = c(0, 10), scale_p = FALSE, scale_max = Inf )

rRDM(n, A, b, t0, v, s = 1, st0 = 0, silent = FALSE)

Value

dRDM returns the density (PDF), pRDM returns the distribution function (CDF), qRDM returns the quantile function, and

rRDM returns random response times and responses (in a

data.frame).

The density, distribution, and quantile functions are defective, that is, they are scaled by the probability of the corresponding response.

Arguments

rt

vector of RTs. Or for convenience also a data.frame with columns rt and response (see details).

response

integer vector of winning accumulators/responses corresponding to the vector of RTs/p (i.e., used for specifying the response for a given RT/probability). Will be recycled if necessary. Cannot contain values larger than the number of accumulators. First response/accumulator must receive value 1, second 2, and so forth.

A

start point interval or evidence in accumulator before beginning of decision process. Start point varies from trial to trial in the interval [0, A] (uniform distribution). Average amount of evidence before evidence accumulation across trials is A/2.

b

response threshold. (b - A/2) is a measure of "response caution".

t0

non-decision time or response time constant (in seconds). Lower bound for the duration of all non-decisional processes (encoding and response execution).

v

drift rate. Mean rate of evidence accumulation within a trial. Needs to be positive, accumulators with a negative rate never finish.

s

within-trial standard deviation of the evidence accumulation process (i.e., the diffusion constant), scales A, b, and v. Needs to be fixed to a constant in most applications. Default is 1.

st0

variability of non-decision time, such that t0 is uniformly distributed between t0 and t0 + st0. Only available in rRDM.

silent

logical. Should the number of accumulators used be suppressed? Default is FALSE which prints the number of accumulators.

p

vector of probabilities. Or for convenience also a data.frame with columns p and response.

interval

a vector containing the end-points of the interval to be searched for the desired quantiles in qRDM. Default is c(0, 10).

scale_p

logical. Should entered probabilities automatically be scaled by maximally predicted probability? Default is FALSE.

scale_max

numerical scalar. Value at which maximally predicted RT should be calculated if scale_p is TRUE.

n

desired number of observations. If `length(n) > 1`, the length is taken to be the number required (as in base R RNGs).

Details

The RDM is a race between independent diffusion processes, one per response alternative, that all start at a point drawn uniformly from [0, A] and drift towards their own threshold b at rate v with within-trial noise s. The first accumulator to reach its threshold determines both the response and the decision time, to which the non-decision time t0 is added. Unlike the LBA, the RDM has no between-trial variability in drift rate, the noise that produces both fast and slow errors is within-trial.

A, b, t0, and v can either be a single numeric vector (which will be recycled across the accumulators) or a list of numeric vectors with one element per accumulator. In the latter case, each element is recycled to the number of trials. This is the same convention as for dLBA.

The RDM is implemented as a race of Wald accumulators and shares the machinery of the LBA. dRDM, pRDM, qRDM, and rRDM are wrappers around dLBA, pLBA, qLBA, and rLBA called with distribution = "wald".

References

Tillman, G., Van Zandt, T., & Logan, G. D. (2020). Sequential sampling models without random between-trial variability: The racing diffusion model of speeded decision making. Psychonomic Bulletin & Review, 27(5), 911-936. doi:10.3758/s13423-020-01719-6

See Also

LBA for the linear ballistic accumulator and Diffusion for the Ratcliff diffusion model.

Examples

Run this code

## generate random RDM data:
rt1 <- rRDM(500, A=0.5, b=1, t0 = 0.5, v=c(2.4, 1.6))
head(rt1)
prop.table(table(rt1$response))

# original parameters have 'high' log-likelihood:
sum(log(dRDM(rt1$rt, rt1$response, A=0.5, b=1, t0 = 0.5, v=c(2.4, 1.6))))

# data can also be passed as data.frame (same is true for pRDM):
sum(log(dRDM(rt1, A=0.5, b=1, t0 = 0.5, v=c(2.4, 1.6))))

objective_fun <- function(par, rt, response) {
  d <- dRDM(rt, response, A=par["A"], b=par["b"], t0=par["t0"],
            v=c(par["v1"], par["v2"]), silent=TRUE)
  if (any(d < 0e-10)) return(1e6)
  else return(-sum(log(d)))
}

# gives same value as manual calculation above:
objective_fun(c(A=0.5, b=1, t0=0.5, v1=2.4, v2=1.6),
              rt=rt1$rt, response=rt1$response)

if (FALSE) {
# can we recover the parameters?
# should be run several times with different random values of init_par
init_par <- runif(5)
init_par[2] <- sum(init_par[1:2]) # ensures b is larger than A
init_par[3] <- runif(1, 0, min(rt1$rt)) # ensures t0 is not too large
names(init_par) <- c("A", "b", "t0", "v1", "v2")
nlminb(objective_fun, start = init_par, rt=rt1$rt, response=rt1$response, lower = 0)
}

# plot defective cdfs (2 accumulators):
curve(pRDM(x, response = 1, A=0.5, b=1, t0 = 0.5, v=c(2.4, 1.6), silent=TRUE),
      xlim = c(0, 2), ylim = c(0, 1),
      ylab = "cumulative probability", xlab = "response time",
      main = "Defective CDFs of the RDM")
curve(pRDM(x, response = 2, A=0.5, b=1, t0 = 0.5, v=c(2.4, 1.6), silent=TRUE),
      add=TRUE, lty = 2)
legend("topleft", legend=c("1", "2"), title="Response", lty=1:2)

# quantiles of the first response:
qRDM(c(0.1, 0.5, 0.9), response = 1, A=0.5, b=1, t0 = 0.5, v=c(2.4, 1.6),
     scale_p = TRUE)

Run the code above in your browser using DataLab