SequentialSamplingModels.CDDMType
CDDM{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.DDMType
DDM{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.5
  • z: 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.ExGaussianType
ExGaussian{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.LBAType
LBA{T<:Real} <: AbstractLBA

A model object for the linear ballistic accumulator.

Parameters

  • ν: a vector of drift rates
  • A: max start point
  • k: A + k = b, where b is the decision threshold
  • τ: a encoding-response offset
  • σ: a vector of drift rate standard deviation

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.LCAType
LCA{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.LNRType
LNR{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.PoissonRaceType
PoissonRace{T<:Real} <: AbstractPoissonRace

Parameters

  • ν: gamma scale parameter
  • α: threshold
  • τ: a encoding-response offset

Constructors

PoissonRace(ν, α, τ)

PoissonRace(;ν=[.05,.06], α=[5,5], τ=.3)

Example

using SequentialSamplingModels
dist = PoissonRace(ν=[.05,.06], α=[5,5], τ=.3)
choice,rt = rand(dist, 10)
like = pdf.(dist, choice, rt)
loglike = logpdf.(dist, choice, rt)

References

LaBerge, D. A. (1962). A recruitment model of simple behavior. Psychometrika, 27, 375-395.

SequentialSamplingModels.RDMType
RDM{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 rates
  • k: k = b - A where b is the decision threshold, and A is the maximum starting point
  • A: 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.SSM1DType
SSM1D <: 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.SSM2DType
SSM2D = 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.WaldType
Wald{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.WaldMixtureType
WaldMixture{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.aDDMType
aDDM{T<:Real} <: AbstractaDDM

An object for the attentional diffusion model.

Parameters

  • ν: relative decision values (i.e., drift rates)
  • α: evidence threshold
  • z: 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 fixate(transition)
     (;mat,n,state) = transition
     w = @view 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, tmat; fixate)

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.maaDDMType
maaDDM{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 threshold
  • z: 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 = @view 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.randMethod
rand(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.randMethod
rand(dist::AbstractLCA)

Generate a random choice-rt pair for the Leaky Competing Accumulator.

Arguments

  • dist: model object for the Leaky Competing Accumulator.
Base.randMethod
rand(
    rng::AbstractRNG,
    dist::AbstractaDDM,
    n_sim::Int,
    fixate::Function, 
    args...;
    rand_state! = _rand_state!,
    Δt = .001,
    kwargs...
)

Generate n_sim simulated trials from the attention diffusion model.

Arguments

  • rng: a random number generator
  • dist: an attentional diffusion model object
  • n_sim::Int: the number of simulated trials
  • fixate: a function of the visual fixation process which returns 1 for alternative and 2 for alternative 2
  • args...: optional positional arguments for the fixate function

Keywords

rand_state! = _rand_state!: initialize first state with equal probability

  • kwargs...: optional keyword arguments for the fixate function
  • Δt = .001: time step
Base.randMethod
rand(
    rng::AbstractRNG, 
    dist::AbstractaDDM, 
    fixate::Function, args...; 
    rand_state! = _rand_state!, 
    Δt = .001,
    kwargs...
)

Generate a single simulated trial from the attentional diffusion model.

Arguments

  • rng: a random number generator
  • dist: an attentional diffusion model object
  • fixate: a function of the visual fixation process which returns 1 for alternative and 2 for alternative 2
  • args...: optional positional arguments for the fixate function

Keywords

  • kwargs...: optional keyword arguments for the fixate function
  • Δt = .001: time step
Base.randMethod
rand(dist::DDM)

Generate a random rt for the Diffusion Decision Model (negative coding)

Arguments

  • dist: model object for the Diffusion Decision Model.
Base.randMethod
rand(rng::AbstractRNG, d::SSM2D, N::Int; kwargs...)

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

Keywords

  • kwargs...: optional keyword arguments
Distributions.cdfFunction
cdf(d::SSM2D, choice::Int, ub=10)

Computes the cumulative density for a given choice. The cumulative density is based on an analytic formula, a numeric integration of pdf, or Monte Carlo simulation, depending on which is available for a given model.

Arguments

  • d::SSM2D: a 2D sequential sampling model.
  • choice::Int: the number of simulated choices and rts
  • ub=10: upper bound of integration
Distributions.cdfMethod
cdf(
    rng::AbstractRNG, 
    d::AbstractaDDM, 
    choice::Int, 
    fixate::Function, 
    ub, 
    args...; 
    n_sim=10_000, 
    kwargs...
)

Computes the approximate cumulative probability density of AbstractaDDM using Monte Carlo simulation.

Arguments

  • dist: an attentional diffusion model object
  • choice: the choice on which the cumulative density is computed
  • fixate: a function of the visual fixation process which returns 1 for alternative and 2 for alternative 2
  • ub::Int: the upper bound of the integral
  • args...: optional positional arguments for the fixate function

Keywords

  • n_sim::Int=10_000: the number of simulated trials

rand_state! = _rand_state!: initialize first state with equal probability

  • kwargs...: optional keyword arguments for the fixate function
Distributions.cdfMethod
cdf(d::SSM1D, choice::Int, ub=10)

Computes the cumulative density for a given choice. The cumulative density is based on an analytic formula, a numeric integration of pdf, or Monte Carlo simulation, depending on which is available for a given model.

Arguments

  • d::SSM1D: a 1D sequential sampling model.
  • ub: upper bound of integration
Distributions.logpdfMethod
logpdf(d::SSM2D, data::NamedTuple)

Computes the likelihood for a 2D sequential sampling model.

Arguments

  • d::SSM2D: an object for a 2D sequential sampling model
  • data::NamedTuple: a NamedTuple of data containing choice and reaction time
Distributions.pdfMethod
pdf(d::SSM2D, data::NamedTuple)

Computes the probability density for a 2D sequential sampling model.

Arguments

  • d::SSM2D: an object for a 2D sequential sampling model
  • data::NamedTuple: a NamedTuple of data containing choice and reaction time
SequentialSamplingModels.compute_choice_probsMethod
compute_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 key choice and corresponding

reaction times in key rt

Keywords

  • `choice_set: a vector of possible choices.
SequentialSamplingModels.compute_quantilesMethod
compute_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_quantilesMethod
compute_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 key choice and corresponding

reaction times in key rt

Keywords

  • percentiles=.1:.1:.90: percentiles at which to evaluate the quantiles
  • choice_set=unique(choice): a vector of possible choices.
SequentialSamplingModels.compute_quantilesMethod
compute_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_optionsMethod
n_options(dist::SSM2D)

Returns the number of choice options based on the length of the drift rate vector ν.

Arguments

  • d::SSM2D: a sub-type of SSM2D
SequentialSamplingModels.simulateMethod
simulate(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.simulateMethod
simulate(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.simulateMethod
simulate(model::AbstractPoissonRace; _...)

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.simulateMethod
simulate(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.simulateMethod
simulate(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.simulateMethod
simulate(
    rng::AbstractRNG, 
    model::AbstractaDDM; 
    fixate, 
    args=(), 
    kwargs=(), 
    Δt = .001,
    rand_state! = _rand_state!
)

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

  • rng::AbstractRNG: random number generator
  • model::AbstractaDDM: an drift diffusion model object

Keywords

  • fixate: a function of the visual fixation process which returns 1 for alternative and 2 for alternative 2
  • args=(): a set of optional positional arguments for the attend function
  • kwargs=(): a set of optional keyword arguments for the attend function
  • Δt = .001: time step

rand_state! = _rand_state!: initialize first state with equal probability

SequentialSamplingModels.simulateMethod
simulate(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.simulateMethod
simulate(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.simulateMethod
simulate(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.loglikelihoodMethod
loglikelihood(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 model
  • data::NamedTuple: a NamedTuple of data containing choice and reaction time