Diffusion Decision Model

The Diffusion Decision Model (DDM; Ratcliff et al., 2016) is a model of speeded decision-making in two-choice tasks. The DDM assumes that evidence accumulates over time, starting from a certain position, until it crosses one of two boundaries and triggers the corresponding response (Ratcliff & McKoon, 2008; Ratcliff & Rouder, 1998; Ratcliff & Smith, 2004). Like other Sequential Sampling Models, the DDM comprises psychologically interpretable parameters that collectively form a generative model for reaction time distributions of both responses.

The drift rate (ν) determines the rate at which the accumulation process approaches a decision boundary, representing the relative evidence for or against a specific response. The distance between the two decision boundaries (referred to as the evidence threshold, α) influences the amount of evidence required before executing a response. Non-decision-related components, including perceptual encoding, movement initiation, and execution, are accounted for in the DDM and reflected in the τ parameter. Lastly, the model incorporates a bias in the evidence accumulation process through the parameter z, affecting the starting point of the drift process in relation to the two boundaries. The z parameter in DDM is relative to a (i.e. it ranges from 0 to 1).

One last parameter is the within-trial variability in drift rate (σ), or the diffusion coefficient. The diffusion coefficient is the standard deviation of the evidence accumulation process within one trial. It is a scaling parameter and by convention it is kept fixed. Following Navarro & Fuss, (2009), we use the σ = 1 version.

Example

In this example, we will demonstrate how to use the DDM in a generic two alternative forced choice task.

Load Packages

The first step is to load the required packages.

using SequentialSamplingModels
using SSMPlots
using Random

Random.seed!(8741)
Random.TaskLocalRNG()

Create Model Object

In the code below, we will define parameters for the DDM and create a model object to store the parameter values.

Drift Rate

The average slope of the information accumulation process. The drift gives information about the speed and direction of the accumulation of information. Typical range: -5 < ν < 5

ν=1.0
1.0

Boundary Separation

The amount of information that is considered for a decision. Large values indicates response caution. Typical range: 0.5 < α < 2

α = 0.80
0.8

Non-Decision Time

The duration for a non-decisional processes (encoding and response execution). Typical range: 0.1 < τ < 0.5

τ = 0.30
0.3

Starting Point

An indicator of an an initial bias towards a decision. The z parameter is relative to a (i.e. it ranges from 0 to 1).

z = 0.50
0.5

DDM Constructor

Now that values have been assigned to the parameters, we will pass them to DDM to generate the model object.

dist = DDM(ν, α, τ, z)
DDM
┌───────────┬───────┐
│ Parameter │ Value │
├───────────┼───────┤
│ ν         │  1.00 │
│ α         │  0.80 │
│ τ         │  0.30 │
│ z         │  0.50 │
└───────────┴───────┘

Simulate Model

Now that the model is defined, we will generate $10,000$ choices and reaction times using rand.

 choices,rts = rand(dist, 10_000)
(choice = [1, 2, 1, 2, 1, 1, 1, 1, 2, 2  …  1, 1, 1, 1, 2, 2, 2, 2, 1, 1], rt = [0.6235206166529468, 0.4730100628894679, 0.41416830567456797, 0.45348580657591553, 0.4902964459872113, 0.35549787903564745, 0.364794969473803, 0.38132429278262064, 0.4073764822411673, 0.48604364664185495  …  0.48572158356251227, 0.6502347287703497, 0.3677126338641864, 0.34315811087205195, 0.4169393291733256, 0.3491622503481624, 0.5229021632142459, 0.3565379011907389, 0.35755435178953376, 0.32320699819949383])

Compute PDF

The PDF for each observation can be computed as follows:

pdf.(dist, choices, rts)
10000-element Vector{Float64}:
 0.514124104892007
 0.7948722232662816
 2.860504846615849
 0.9329255514317525
 1.5350142032434622
 4.189626309618437
 4.064726564953159
 3.6810990704177433
 1.3571601666217776
 0.7142306046953543
 ⋮
 0.4128668079665767
 4.006584190722666
 4.070918713820625
 1.256913648962592
 1.8811098885973885
 0.5277392004877951
 1.8790220516837353
 4.1724231063021024
 2.1188708300025136

Compute Log PDF

Similarly, the log PDF for each observation can be computed as follows:

logpdf.(dist, choices, rts)
10000-element Vector{Float64}:
 -0.6652905934649012
 -0.22957390269674277
  1.0509981290497268
 -0.06942987613984214
  0.4285396339236893
  1.4326115437081335
  1.4023464750431558
  1.3032113680302926
  0.3053944038227346
 -0.3365493930241957
  ⋮
 -0.8846302369053225
  1.3879390555488813
  1.4038687021931797
  0.2286592311168336
  0.6318619689194519
 -0.6391530557737511
  0.6307514562239512
  1.4284969476967095
  0.7508833194302779

Plot Simulation

The code below overlays the PDF on reaction time histograms for each option.

histogram(dist)
plot!(dist; t_range=range(.301, 1, length=100))

References

Navarro, D., & Fuss, I. (2009). Fast and accurate calculations for first-passage times in Wiener diffusion models. https://doi.org/10.1016/J.JMP.2009.02.003

Ratcliff, R., & McKoon, G. (2008). The Diffusion Decision Model: Theory and Data for Two-Choice Decision Tasks. Neural Computation, 20(4), 873–922. https://doi.org/10.1162/neco.2008.12-06-420

Ratcliff, R., & Rouder, J. N. (1998). Modeling Response Times for Two-Choice Decisions. Psychological Science, 9(5), 347–356. https://doi.org/10.1111/1467-9280.00067

Ratcliff, R., & Smith, P. L. (2004). A comparison of sequential sampling models for two-choice reaction time. Psychological Review, 111 2, 333–367. https://doi.org/10.1037/0033-295X.111.2.333

Ratcliff, R., Smith, P. L., Brown, S. D., & McKoon, G. (2016). Diffusion Decision Model: Current Issues and History. Trends in Cognitive Sciences, 20(4), 260–281. https://doi.org/10.1016/j.tics.2016.01.007