Linear Ballistic Accumulator

The Linear Ballistic Accumulator (LBA; Brown & Heathcote, 2008) is a sequential sampling model in which evidence for options races independently. The LBA makes an additional simplification that evidence accumulates in a linear and ballistic fashion, meaning there is no intra-trial noise. Instead, evidence accumulates deterministically and linearly until it hits the threshold.

Example

In this example, we will demonstrate how to use the LBA 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 LBA and create a model object to store the parameter values.

Mean Drift Rates

The drift rates control the speed with which evidence accumulates for each option. In the standard LBA, drift rates vary across trials according to a normal distribution with mean $\nu$:

ν = [2.75,1.75]
2-element Vector{Float64}:
 2.75
 1.75

Standard Deviation of Drift Rates

The standard deviation of the drift rate distribution is given by $\sigma$, which is commonly fixed to 1 for each accumulator.

σ = [1.0,1.0]
2-element Vector{Float64}:
 1.0
 1.0

Maximum Starting Point

The starting point of each accumulator is sampled uniformly between $[0,A]$.

A = 0.80
0.8

Threshold - Maximum Starting Point

Evidence accumulates until accumulator reaches a threshold $\alpha = k +A$. The threshold is parameterized this way to faciliate parameter estimation and to ensure that $A \le \alpha$.

k = 0.50
0.5

Non-Decision Time

Non-decision time is an additive constant representing encoding and motor response time.

τ = 0.30
0.3

LBA Constructor

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

dist = LBA(; ν, A, k, τ)
LBA
┌───────────┬──────────────┐
│ Parameter │ Value        │
├───────────┼──────────────┤
│ ν         │ [2.75, 1.75] │
│ σ         │ [1.0, 1.0]   │
│ A         │  0.80        │
│ k         │  0.50        │
│ τ         │  0.30        │
└───────────┴──────────────┘

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, 1, 2, 1, 1, 2, 2, 1, 1, 1  …  2, 1, 1, 1, 1, 2, 1, 1, 1, 1], rt = [0.46901081359730046, 0.5382866317379926, 0.5680330833450193, 0.6026843913170301, 0.5693248772513073, 0.9735648559773147, 0.5322274806898473, 0.5493609964658215, 0.785941116807848, 0.5869078648348688  …  0.6065484757277073, 0.8402820811198233, 0.48671312915228715, 0.45481878731935993, 0.603574654182435, 0.6674503107854755, 0.772047819452796, 0.6707045956238078, 0.4665734019291022, 0.44462994269424955])

Compute PDF

The PDF for each observation can be computed as follows:

pdf.(dist, choices, rts)
10000-element Vector{Float64}:
 1.9008127700569433
 2.7148813057913315
 0.9950910675198821
 2.3928316972602506
 2.6586316015402276
 0.06498746351690506
 0.9416243247285896
 2.719380272491228
 0.5826650122464005
 2.5402857934325507
 ⋮
 0.3584169808986535
 2.263534429353977
 1.5210299065979027
 2.383576461836077
 0.6841856828175026
 0.6604798742540893
 1.573538007702545
 1.8410375755335038
 1.2087265304167183

Compute Log PDF

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

logpdf.(dist, choices, rts)
10000-element Vector{Float64}:
  0.6422815684174846
  0.9987482344896638
 -0.004921020866104823
  0.8724774751784299
  0.9778115549150694
 -2.7335608966588034
 -0.06014888997064968
  1.000404013352331
 -0.5401428508328466
  0.9322765918003005
  ⋮
 -1.0260582192641994
  0.8169274984492697
  0.41938767554138184
  0.8686020747941338
 -0.37952593209238344
 -0.41478862595471155
  0.45332659210987886
  0.6103293124356465
  0.18956735118877374

Compute Choice Probability

The choice probability $\Pr(C=c)$ is computed by passing the model and choice index to cdf.

cdf(dist, 1)
0.7266707569586401

To compute the joint probability of choosing $c$ within $t$ seconds, i.e., $\Pr(T \leq t \wedge C=c)$, pass a third argument for $t$.

Plot Simulation

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

histogram(dist)
plot!(dist; t_range=range(.3,2.5, length=100), xlims=(0, 2.5))
Example block output

References

Brown, S. D., & Heathcote, A. (2008). The simplest complete model of choice response time: Linear ballistic accumulation. Cognitive psychology, 57(3), 153-178.