Lognormal Race Model
The Lognormal Race model (LNR) assumes evidence for each option races independently and that the first passage time for each option is lognormally distributed. One way in which the LNR has been used is to provide a likelihood function for the ACT-R cognitive architecture. An example of such an application can be found in ACTRModels.jl. We will present a simplified version below.
Example
In this example, we will demonstrate how to use the LNR 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.
$\nu$
We will set $\nu [-1,-1.5]$.
ν = [-1,-1.5]
2-element Vector{Float64}:
-1.0
-1.5
$\sigma$
We will set the parameter $\sigma = [-1,-1.5]$
σ = [0.50,0.50]
2-element Vector{Float64}:
0.5
0.5
The lognormal has the following relationship to the normal distribution:
\[X \sim \mathrm{lognormal(\nu, \sigma)} \iff \log(X) \sim \mathrm{normal}(\nu, \sigma)\]
.
This means that $E[\log(X)] = \nu$ and $\mathrm{Var}[\log(X)] = \sigma^2$. Note that $\nu$ and $\sigma$ affect both the mean and variance of the lognormal distribution. See ACT-R for a possible theoretical intepretation of parameters $\nu$ and $\sigma$.
Non-Decision Time
Non-decision time is an additive constant representing encoding and motor response time.
τ = 0.30
0.3
LNR Constructor
Now that values have been asigned to the parameters, we will pass them to LNR
to generate the model object.
dist = LNR(ν, σ, τ)
LNR
┌───────────┬──────────────┐
│ Parameter │ Value │
├───────────┼──────────────┤
│ ν │ [-1.0, -1.5] │
│ σ │ [0.5, 0.5] │
│ τ │ 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 = [2, 2, 2, 2, 2, 1, 2, 2, 1, 1 … 2, 1, 2, 2, 1, 2, 2, 2, 2, 2], rt = [0.5284763207797445, 0.48267873010783957, 0.44032397928290745, 0.6437382290157518, 0.5532541679569261, 0.6121618789928376, 0.4537471611863404, 0.48120901356434786, 0.5461841032691223, 0.4901729278308987 … 0.45203066378683576, 0.5302903730855698, 0.3781620286425013, 0.4960131048155889, 0.4124525895307052, 0.5000283816472462, 0.4149261106183591, 0.4400940001768211, 0.48366631398201726, 0.5059093257359599])
Compute PDF
The PDF for each observation can be computed as follows:
pdf.(dist, choices, rts)
10000-element Vector{Float64}:
2.893933713353151
3.706240571191987
3.5983104899395717
0.8851584793472358
2.3566079596199976
0.6077189197307741
3.773027674800382
3.721402084206158
0.9906133787321555
1.0984568608062004
⋮
1.0607423671628675
1.1292158990007106
3.526837681589226
0.39093734361367666
3.4604315706050928
2.8498488628275926
3.593998733692935
3.6954823000465993
3.3551541321164993
Compute Log PDF
Similarly, the log PDF for each observation can be computed as follows:
logpdf.(dist, choices, rts)
10000-element Vector{Float64}:
1.0626167230931887
1.3100180397315186
1.2804644269523144
-0.12198857729707013
0.8572232798777513
-0.49804280698536785
1.3278777759142926
1.3141005016309444
-0.009430953233600659
0.0939063410711296
⋮
0.05896900937595628
0.1215234971782671
1.2604016285303623
-0.9392079783499512
1.2413933126800751
1.0472659622875784
1.2792654360221105
1.3071110736349603
1.2104977103867194
Compute Choice Probability
The choice probability $\Pr(C=c)$ is computed by passing the model and choice index to cdf
.
cdf(dist, 1, Inf)
NaN
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(.301, 1, length=100))
References
Heathcote, A., & Love, J. (2012). Linear deterministic accumulator models of simple choice. Frontiers in psychology, 3, 292.
Rouder, J. N., Province, J. M., Morey, R. D., Gomez, P., & Heathcote, A. (2015). The lognormal race: A cognitive-process model of choice and latency with desirable psychometric properties. Psychometrika, 80, 491-513.