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 Plots
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 │
│ z │ 0.30 │
│ τ │ 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 = [2, 2, 2, 1, 2, 2, 2, 1, 1, 2 … 1, 2, 2, 1, 1, 2, 2, 2, 1, 2], rt = [0.8540833743136477, 0.9172878615122555, 0.5167882086926956, 0.5619636321779704, 0.6372437543054534, 0.5187234905237433, 0.5290776286723692, 0.614469642399428, 0.6929130841909981, 0.5102443554497827 … 0.6764253513088843, 0.567697104139211, 0.5788217479547593, 0.6359702521570838, 0.6730704702512863, 0.5369607628955843, 0.56460519668186, 0.552534016007984, 0.578053863708004, 0.5450817074252159])
Compute PDF
The PDF for each observation can be computed as follows:
pdf.(dist, choices, rts)
10000-element Vector{Float64}:
0.1707570036840438
0.10157448683853935
6.176050605689833
1.9498828326430897
1.1120445858644057
6.254950207453447
5.560196242606552
2.2666992794573937
1.387715793919971
4.345154447894261
⋮
2.7012911122782364
2.2703563521558348
2.0467264610205906
1.6067755657360605
4.773632860177681
2.84352138656625
3.5215570936719485
2.282402058364405
4.0612153326284535
Compute Log PDF
Similarly, the log PDF for each observation can be computed as follows:
logpdf.(dist, choices, rts)
10000-element Vector{Float64}:
-1.7675137641891465
-2.2869628891660074
1.8206790066153677
0.6677692849463734
0.10620029022640319
1.8333731834480929
1.715633403072455
0.8183247114063541
0.32765908169488783
1.4690613042062655
⋮
0.9937298484466888
0.8199368025012795
0.7162416685465508
0.47422941660124457
1.5631076209329124
1.0450432089484079
1.2589032479561681
0.8252284227588448
1.4014822718313953
Compute Choice Probability
The choice probability $\Pr(C=c)$ is computed by passing the model and choice index to cdf
along with a large value for time as the second argument.
cdf(dist, 1, 10)
0.47765310738402006
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