SequentialSamplingModels.AbstractLBA
— TypeAbstractLBA <: SSM2D
An abstract type for the linear ballistic accumulator model.
SequentialSamplingModels.AbstractLCA
— TypeAbstractLCA <: SSM2D
An abstract type for the leaky competing accumulator model
SequentialSamplingModels.AbstractLNR
— TypeAbstractLNR <: SSM2D
An abstract type for the lognormal race model
SequentialSamplingModels.AbstractRDM
— TypeAbstractRDM <: SSM2D
An abstract type for the racing diffusion model.
SequentialSamplingModels.AbstractWald
— TypeAbstractWald <: SSM1D
An abstract type for the Wald model.
SequentialSamplingModels.AbstractaDDM
— TypeAbstractaDDM <: SSM2D
An abstract type for the drift diffusion model.
SequentialSamplingModels.CDDM
— TypeCDDM{T<:Real} <: AbstractCDDM
A circular drift diffusion model (CDDM) for continous responding. CCDM is typically applied to continous report of color in visual working memory tasks. Currently supports the 2D case.
Parameters
ν
: a vector drift rates. ν₁ is the mean drift rate along the x-axis; ν₂ is the mean drift rate along the y-axis.η
: a vector across-trial standard deviations of drift rates. η₁ is the standard deviation of drift rate along the x-axis; ν₂ is the standard deviation of drift rate along the y-axisσ
: intra-trial drift rate variabilityα
: response boundary as measured by the radious of a circleτ
: mean non-decision time
Constructors
CDDM(ν, η, σ, α, τ)
CDDMν=[1,.5], η=[1,1], σ=1, α=1.5, τ=0.30)
Example
using SequentialSamplingModels
dist = CDDM(;ν=[1,.5], η=[1,1], σ=1, α=1.5, τ=0.30)
data = rand(dist, 10)
like = pdf(dist, data)
loglike = logpdf(dist, data)
References
Smith, P. L. (2016). Diffusion theory of decision making in continuous report. Psychological Review, 123(4), 425.
Smith, P. L., Garrett, P. M., & Zhou, J. (2023). Obtaining Stable Predicted Distributions of Response Times and Decision Outcomes for the Circular Diffusion Model. Computational Brain & Behavior, 1-13.
SequentialSamplingModels.ContinuousMultivariateSSM
— TypeContinuousMultivariateSSM <: ContinuousMultivariateDistribution
An abstract type for continuous multivariate sequential sampling models e.g., a circular drift diffusion model.
SequentialSamplingModels.DDM
— TypeDDM{T<:Real} <: SSM2D
Model object for the standard Drift Diffusion Model.
Parameters
ν
: drift rate. 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α
: boundary threshold separation. The amount of information that is considered for a decision. Typical range: 0.5 < α < 2τ
: non-decision time. The duration for a non-decisional processes (encoding and response execution). Typical range: 0.1 < τ < 0.5z
: starting point. Indicator of an an initial bias towards a decision. The z parameter is relative to a (i.e. it ranges from 0 to 1).
Constructors
DDM(ν, α, τ, z)
DDM(; ν = 1.0,
α = 0.8,
τ = 0.3
z = 0.25)
Example
using SequentialSamplingModels
dist = DDM(ν = 1.0, α = 0.8, τ = 0.3, z = 0.25)
choice,rt = rand(dist, 10)
like = pdf.(dist, choice, rt)
loglike = logpdf.(dist, choice, rt)
References
Ratcliff, R., & McKoon, G. (2008). The Diffusion Decision Model: Theory and Data for Two-Choice Decision Tasks. Neural Computation, 20(4), 873–922.
SequentialSamplingModels.ExGaussian
— TypeExGaussian{T<:Real} <: SSM1D
The Ex-Gaussian is a convolution of the Gaussian and exponential distribution sometimes used to model reaction time distributions. Note that this is not technically a sequential sampling model.
Parameters
μ
: mean of Gaussian componentσ
: standard deviation of Gaussian componentτ
: mean of exponential component
Constructors
ExGaussian(μ, σ, τ)
ExGaussian(;μ=.5, σ=.20, τ=.20)
Example
using SequentialSamplingModels
dist = ExGaussian(;μ=.5, σ=.20, τ=.20)
rt = rand(dist, 10)
like = pdf.(dist, rt)
loglike = logpdf.(dist, rt)
References
Matzke, D., & Wagenmakers, E. J. (2009). Psychological interpretation of the ex-Gaussian and shifted Wald parameters: A diffusion model analysis. Psychonomic bulletin & review, 16, 798-817.
SequentialSamplingModels.LBA
— TypeLBA{T<:Real} <: AbstractLBA
A model object for the linear ballistic accumulator.
Parameters
ν
: a vector of drift ratesA
: max start pointk
: A + k = b, where b is the decision thresholdσ
: a vector of drift rate standard deviationτ
: a encoding-response offset
Constructors
LBA(ν, A, k, τ, σ)
LBA(;τ=.3, A=.8, k=.5, ν=[2.0,1.75], σ=[1.0,1.0])
Example
using SequentialSamplingModels
dist = LBA(ν=[3.0,2.0], A = .8, k = .2, τ = .3)
choice,rt = rand(dist, 10)
like = pdf.(dist, choice, rt)
loglike = logpdf.(dist, choice, rt)
References
Brown, S. D., & Heathcote, A. (2008). The simplest complete model of choice response time: Linear ballistic accumulation. Cognitive psychology, 57(3), 153-178.
SequentialSamplingModels.LCA
— TypeLCA{T<:Real} <: AbstractLCA
A model type for the Leaky Competing Accumulator.
Parameters
ν
: drift ratesα
: evidence thresholdβ
: lateral inhabitionλ
: leak rateτ
: non-decision timeσ
: diffusion noiseΔt
: time step
Constructors
LCA(ν, α, β, λ, τ, σ, Δt)
LCA(;ν = [2.5,2.0],
α = 1.5,
β = .20,
λ = .10,
τ = .30,
σ = 1.0,
Δt = .001)
Example
using SequentialSamplingModels
ν = [2.5,2.0]
α = 1.5
β = 0.20
λ = 0.10
σ = 1.0
τ = 0.30
Δt = .001
dist = LCA(; ν, α, β, λ, τ, σ, Δt)
choices,rts = rand(dist, 500)
References
Usher, M., & McClelland, J. L. (2001). The time course of perceptual choice: The leaky, competing accumulator model. Psychological Review, 108 3, 550–592. https://doi.org/10.1037/0033-295X.108.3.550
SequentialSamplingModels.LNR
— TypeLNR{T<:Real} <: AbstractLNR
Parameters
ν
: a vector of means in log-spaceσ
: a vector of standard deviation parameter in log-spaceτ
: a encoding-response offset
Constructors
LNR(ν, σ, τ)
LNR(;ν=[-1,-2], σ=[1.0,1.0], τ=.20)
Example
using SequentialSamplingModels
dist = LNR(ν=[-2,-3], σ=[1.0,1.0], τ=.3)
choice,rt = rand(dist, 10)
like = pdf.(dist, choice, rt)
loglike = logpdf.(dist, choice, rt)
References
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(2), 491-513.
SequentialSamplingModels.RDM
— TypeRDM{T<:Real} <: AbstractRDM
An object for the racing diffusion model.
Constructors
RDM(ν, k, A, τ)
RDM(;ν=[1,2], k=.3, A=.7, τ=.2)
Parameters
ν
: a vector of drift ratesk
: k = b - A where b is the decision threshold, and A is the maximum starting pointA
: the maximum starting point diffusion process, sampled from Uniform distributionτ
: a encoding-motor time offset
Example
using SequentialSamplingModels
dist = RDM(;ν=[1,2], k=.3, A=.7, τ=.2)
choice,rt = rand(dist, 10)
like = pdf.(dist, choice, rt)
loglike = logpdf.(dist, choice, rt)
References
Tillman, G., Van Zandt, T., & Logan, G. D. (2020). Sequential sampling models without random between-trial variability: The racing diffusion model of speeded decision making. Psychonomic Bulletin & Review, 27, 911-936.
SequentialSamplingModels.SSM1D
— TypeSSM1D <: ContinuousUnivariateDistribution
An abstract type for sequential sampling models characterized by a single choice reaction time distribution. Sub-types of SSM1D
output a vector of reaction times.
SequentialSamplingModels.SSM2D
— TypeSSM2D = Distribution{Multivariate, Mixed}
An abstract type for sequential sampling models characterized by a multivariate choice-reaction time distribution. Sub-types of SSM2D
output a NamedTuple
consisting of a vector of choices and reaction times.
SequentialSamplingModels.Wald
— TypeWald{T<:Real} <: AbstractWald
A model object for the Wald model, also known as the inverse Gaussian model.
Parameters
ν
: drift rateα
: decision thresholdτ
: a encoding-response offset
Constructors
Wald(ν, α, τ)
Wald(;ν=1.5, α=.50, τ=0.20)
Example
using SequentialSamplingModels
dist = Wald(ν=3.0, α=.5, τ=.130)
rt = rand(dist, 10)
like = pdf.(dist, rt)
loglike = logpdf.(dist, rt)
References
Anders, R., Alario, F., & Van Maanen, L. (2016). The shifted Wald distribution for response time data analysis. Psychological methods, 21(3), 309.
Folks, J. L., & Chhikara, R. S. (1978). The inverse Gaussian distribution and its statistical application—a review. Journal of the Royal Statistical Society Series B: Statistical Methodology, 40(3), 263-275.
SequentialSamplingModels.WaldMixture
— TypeWaldMixture{T<:Real} <: AbstractWald
Parameters
υ
: drift rateη
: standard deviation of drift rateα
: decision thresholdτ
: a encoding-response offset
Constructors
WaldMixture(ν, η, α, τ)
WaldMixture(;ν=3.0, η=.2, α=.5, τ=.130)
Example
using SequentialSamplingModels
dist = WaldMixture(;ν=3.0, η=.2, α=.5, τ=.130)
rt = rand(dist, 10)
like = pdf.(dist, rt)
loglike = logpdf.(dist, rt)
References
Steingroever, H., Wabersich, D., & Wagenmakers, E. J. (2020). Modeling across-trial variability in the Wald drift rate parameter. Behavior Research Methods, 1-17.
SequentialSamplingModels.aDDM
— TypeaDDM{T<:Real} <: AbstractaDDM
An object for the attentional diffusion model.
Parameters
ν
: relative decision values (i.e., drift rates)α
: evidence thresholdz
: initial evidenceθ
: bias towards attended alternative (lower indicates more bias)σ
: standard deviation of noise in evidence accumulationΔ
: constant of evidence accumulation speed (evidence per ms)τ
: non-decision time
Constructors
aDDM(ν, α, z, θ, σ, Δ, τ)
aDDM(;ν=[5.0,4.0], α=1.0, z=α*.5, θ=.3, σ=.02, Δ=.0004, τ=0.0)
Example
using SequentialSamplingModels
using StatsBase
mutable struct Transition
state::Int
n::Int
mat::Array{Float64,2}
end
function Transition(mat)
n = size(mat,1)
state = rand(1:n)
return Transition(state, n, mat)
end
function attend(transition)
(;mat,n,state) = transition
w = mat[state,:]
next_state = sample(1:n, Weights(w))
transition.state = next_state
return next_state
end
model = aDDM()
tmat = Transition([.98 .015 .005;
.015 .98 .005;
.45 .45 .1])
choices,rts = rand(model, 100, attend, tmat)
References
Krajbich, I., Armel, C., & Rangel, A. (2010). Visual fixations and the computation and comparison of value in simple choice. Nature neuroscience, 13(10), 1292-1298.
SequentialSamplingModels.maaDDM
— TypemaaDDM{T<:Real} <: AbstractaDDM
An object for the multi-attribute attentional drift diffusion model.
Constructors
maaDDM(ν, α, z, θ, ϕ, ω, σ, Δ, τ)
maaDDM(;
ν = [4.0 5.0; 5.0 4.0],
α = 1.0,
z = 0.0,
θ = .3,
ϕ = .50,
ω = .70,
σ = .02,
Δ = .0004,
τ = 0.0)
Constructor for multialternative attentional diffusion model object.
In this version of the model, the non-attended attribute of the non-attended alternative is doubly discounted. For example, the mean drift rate for the attribute 1 of alternative 1 is given by:
Δ * (ω * (ν[1,1] - θ * ν[2,1]) + (1 - ω) * ϕ * (ν[1,2] - θ * ν[2,2]))
Keywords
ν
: drift rates where rows are alternatives and columns are attributesα
: evidence thresholdz
: initial evidenceθ
: bias away from unattended alternative (lower indicates more bias)ϕ
: bias away from unattended attributeω
: attribute weightσ
: standard deviation of noise in evidence accumulationΔ
: constant of evidence accumulation speed (evidence per ms)τ
: non-decision time
Example
using SequentialSamplingModels
using StatsBase
mutable struct Transition
state::Int
n::Int
mat::Array{Float64,2}
end
function Transition(mat)
n = size(mat,1)
state = rand(1:n)
return Transition(state, n, mat)
end
function attend(transition)
(;mat,n,state) = transition
w = mat[state,:]
next_state = sample(1:n, Weights(w))
transition.state = next_state
return next_state
end
ν = [4.0 5.0; 5.0 4.0]
α = 1.0
z = 0.0
θ = .3
ϕ = .50
ω = .70
σ = .02
Δ = .0004
τ = 0.0
dist = maaDDM(; ν, α, z, θ, ϕ, ω, σ, Δ, τ)
tmat = Transition([.98 .015 .0025 .0025;
.015 .98 .0025 .0025;
.0025 .0025 .98 .015;
.0025 .0025 .015 .98])
choices,rts = rand(dist, 100, attend, tmat)
References
Yang, X., & Krajbich, I. (2023). A dynamic computational model of gaze and choice in multi-attribute decisions. Psychological Review, 130(1), 52.
Base.rand
— Methodrand(dist::AbstractLCA, n_sim::Int)
Generate n_sim
random choice-rt pairs for the Leaky Competing Accumulator.
Arguments
dist
: model object for the Leaky Competing Accumulator.n_sim::Int
: the number of simulated choice-rt pairs
Base.rand
— Methodrand(dist::AbstractLCA)
Generate a random choice-rt pair for the Leaky Competing Accumulator.
Arguments
dist
: model object for the Leaky Competing Accumulator.
Base.rand
— Methodrand(rng::AbstractRNG, dist::AbstractaDDM, fixation, args...; kwargs...)
Generate a single simulated trial from the attention diffusion model.
Arguments
rng
: a random number generatordist
: an attentional diffusion model objectfixation
: a function of the visual fixation process which returns 1 for alternative and 2 for alternative 2args...
: optional positional arguments for thefixation
function
Keywords
kwargs...
: optional keyword arguments for thefixation
function
Base.rand
— Methodrand(rng::AbstractRNG, dist::AbstractaDDM, n_sim::Int, fixation, args...; rand_state! = _rand_state!, kwargs...)
Generate n_sim
simulated trials from the attention diffusion model.
Arguments
rng
: a random number generatordist
: an attentional diffusion model objectn_sim::Int
: the number of simulated trialsfixation
: a function of the visual fixation process which returns 1 for alternative and 2 for alternative 2args...
: optional positional arguments for thefixation
function
Keywords
rand_state! = _rand_state!
: initialize first state with equal probability
kwargs...
: optional keyword arguments for thefixation
function
Base.rand
— Methodrand(dist::DDM)
Generate a random rt for the Diffusion Decision Model (negative coding)
Arguments
dist
: model object for the Diffusion Decision Model.
Base.rand
— Methodrand(rng::AbstractRNG, d::SSM2D, N::Int)
Default method for Generating n_sim
random choice-rt pairs from a sequential sampling model with more than one choice option.
Arguments
d::SSM2D
: a 2D sequential sampling model.n_sim::Int
: the number of simulated choices and rts
Distributions.logpdf
— Methodlogpdf(d::SSM2D, data::NamedTuple)
Computes the likelihood for a 2D sequential sampling model.
Arguments
d::SSM2D
: an object for a 2D sequential sampling modeldata::NamedTuple
: a NamedTuple of data containing choice and reaction time
Distributions.pdf
— Methodpdf(d::SSM2D, data::NamedTuple)
Computes the probability density for a 2D sequential sampling model.
Arguments
d::SSM2D
: an object for a 2D sequential sampling modeldata::NamedTuple
: a NamedTuple of data containing choice and reaction time
SequentialSamplingModels.compute_choice_probs
— Methodcompute_choice_probs(data::NamedTuple; choice_set=unique(data.choice))
Returns the choice probabilities for a 2D SSM.
Arguments
data::NamedTuple
: a data structure containing discrete choices in the keychoice
and corresponding
reaction times in key rt
Keywords
- `choice_set: a vector of possible choices.
SequentialSamplingModels.compute_quantiles
— Methodcompute_quantiles(data::Array{<:Real,2}; percentiles=.1:.1:.90)
Returns the marginal quantiles for a continous multivariate SSM.
data::Array{<:Real,2}
: an array of continous observations
Keywords
percentiles=.1:.1:.90
: percentiles at which to evaluate the quantiles
SequentialSamplingModels.compute_quantiles
— Methodcompute_quantiles(data::NamedTuple; choice_set=unique(data.choice), percentiles=.1:.1:.90)
Returns the quantiles for each choice of a 2D SSM. Note there is a chance that a given choice will have no observations, and thus no quantiles. Such cases will need to be removed or handled in post processing.
Arguments
data::NamedTuple
: a data structure containing discrete choices in the keychoice
and corresponding
reaction times in key rt
Keywords
percentiles=.1:.1:.90
: percentiles at which to evaluate the quantileschoice_set=unique(choice)
: a vector of possible choices.
SequentialSamplingModels.compute_quantiles
— Methodcompute_quantiles(data::Vector{<:Real}; percentiles=.1:.1:.90)
Returns the quantiles associated with a vector of reaction times for a single choice SSM.
data::Vector{<:Real}
: a vector of reaction times
Keywords
percentiles=.1:.1:.90
: percentiles at which to evaluate the quantiles
SequentialSamplingModels.n_options
— Methodn_options(dist::DDM)
Returns 2 for the number of choice options
Arguments
d::DDM
: a model object for the drift diffusion model
SequentialSamplingModels.n_options
— Methodn_options(dist::SSM2D)
Returns the number of choice options based on the length of the drift rate vector ν
.
Arguments
d::SSM2D
: a sub-type ofSSM2D
SequentialSamplingModels.n_options
— Methodn_options(dist::SSM1D)
Returns 1 for the number of choice options
Arguments
d::SSM1D
: a sub-type ofSSM1D
SequentialSamplingModels.simulate
— Methodsimulate(model::AbstractCDDM; Δt=.001)
Returns a matrix containing evidence samples of the racing diffusion model decision process. In the matrix, rows represent samples of evidence per time step and columns represent different accumulators.
Arguments
model::AbstractCDDM;
: a circular drift diffusion model object
Keywords
Δt=.001
: size of time step of decision process in seconds
SequentialSamplingModels.simulate
— Methodsimulate(model::AbstractLBA; n_steps=100)
Returns a matrix containing evidence samples of the LBA decision process. In the matrix, rows represent samples of evidence per time step and columns represent different accumulators.
Arguments
model::AbstractLBA
: a subtype of AbstractLBA
Keywords
n_steps=100
: number of time steps at which evidence is recorded
SequentialSamplingModels.simulate
— Methodsimulate(model::AbstractLCA; _...)
Returns a matrix containing evidence samples of the LCA decision process. In the matrix, rows represent samples of evidence per time step and columns represent different accumulators.
Arguments
model::AbstrctLCA
: an LCA model object
SequentialSamplingModels.simulate
— Methodsimulate(model::AbstractRDM)
Returns a matrix containing evidence samples of the racing diffusion model decision process. In the matrix, rows represent samples of evidence per time step and columns represent different accumulators.
Arguments
model::AbstractRDM
: an racing diffusion model object
Keywords
Δt=.001
: size of time step of decision process in seconds
SequentialSamplingModels.simulate
— Methodsimulate(model::AbstractaDDM; fixation, m_args=(), m_kwargs=())
Returns a matrix containing evidence samples from a subtype of an attentional drift diffusion model decision process. In the matrix, rows represent samples of evidence per time step and columns represent different accumulators.
Arguments
model::AbstractaDDM
: an drift diffusion model object
Keywords
attend
: a function of the visual fixation process which returns 1 for alternative and 2 for alternative 2args=()
: a set of optional positional arguments for theattend
functionkwargs=()
: a set of optional keyword arguments for theattend
function
rand_state! = _rand_state!
: initialize first state with equal probability
SequentialSamplingModels.simulate
— Methodsimulate(model::DDM; Δt=.001)
Returns a matrix containing evidence samples of the drift diffusion model decision process. In the matrix, rows represent samples of evidence per time step and columns represent different accumulators.
Arguments
model::DDM
: an drift diffusion model object
Keywords
Δt=.001
: size of time step of decision process in seconds
SequentialSamplingModels.simulate
— Methodsimulate(model::WaldMixture; Δt=.001)
Returns a matrix containing evidence samples of the Wald mixture decision process. In the matrix, rows represent samples of evidence per time step and columns represent different accumulators.
Arguments
model::Wald
: an Wald mixture model object
Keywords
Δt=.001
: size of time step of decision process in seconds
SequentialSamplingModels.simulate
— Methodsimulate(model::Wald; Δt=.001)
Returns a matrix containing evidence samples of the Wald decision process. In the matrix, rows represent samples of evidence per time step and columns represent different accumulators.
Arguments
model::Wald
: an Wald model object
Keywords
Δt=.001
: size of time step of decision process in seconds
StatsAPI.loglikelihood
— Methodloglikelihood(d::SSM2D, data::NamedTuple)
Computes the summed log likelihood for a 2D sequential sampling model.
Arguments
d::SSM2D
: an object for a 2D sequential sampling modeldata::NamedTuple
: a NamedTuple of data containing choice and reaction time