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.

Drift Rates

The drift rates control the speed with which information accumulates. Typically, there is one drift rate per option.

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

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] │
│ A         │  0.80        │
│ k         │  0.50        │
│ τ         │  0.30        │
│ σ         │  1.00        │
└───────────┴──────────────┘

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.998748234489664
 -0.004921020866104747
  0.8724774751784301
  0.9778115549150692
 -2.733560896658803
 -0.06014888997064975
  1.0004040133523309
 -0.5401428508328464
  0.9322765918003005
  ⋮
 -1.0260582192641996
  0.8169274984492697
  0.41938767554138195
  0.8686020747941336
 -0.37952593209238333
 -0.4147886259547115
  0.45332659210987875
  0.6103293124356466
  0.18956735118877371

Plot Simulation

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

# rts for option 1
rts1 = rts[choices .== 1]
# rts for option 2
rts2 = rts[choices .== 2]
# probability of choosing 1
p1 = length(rts1) / length(rts)
t_range = range(.31, 2, length=100)
# pdf for choice 1
pdf1 = pdf.(dist, (1,), t_range)
# pdf for choice 2
pdf2 = pdf.(dist, (2,), t_range)
# histogram of retrieval times
hist = histogram(layout=(2,1), leg=false, grid=false,
     xlabel="Reaction Time", ylabel="Density", xlims = (0,1.5))
histogram!(rts1, subplot=1, color=:grey, bins = 200, norm=true, title="Choice 1")
plot!(t_range, pdf1, subplot=1, color=:darkorange, linewidth=2)
histogram!(rts2, subplot=2, color=:grey, bins = 150, norm=true, title="Choice 2")
plot!(t_range, pdf2, subplot=2, color=:darkorange, linewidth=2)
# weight histogram according to choice probability
hist[1][1][:y] *= p1
hist[2][1][:y] *= (1 - p1)
hist

References

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