Skip to content

LBA in Julia / Turing: how to specify the input as vectors  #1

@DominiqueMakowski

Description

@DominiqueMakowski

@kiante-fernandez I thought I'd first ask you as it's probably a basic issue of Turing specification.

I am testing this tutorial, and try to modify it to first make it as if I had the data stored in a dataframe. And I thought, similarly to other Turing models, to modify the input to not be a tuple of data but two vectors.

I tried the following:

using Turing
using SequentialSamplingModels
using Random
using DataFrames
using LinearAlgebra

# Generate some data
Random.seed!(254)
data1 = DataFrame(rand(LBA=[3.0, 2.0], A=0.8, k=0.2, τ=0.3), 500))
data1[!, :condition] = repeat(["A"], nrow(data1))
data2 = DataFrame(rand(LBA=[1.0, 1.5], A=0.7, k=0.2, τ=0.3), 500))
data2[!, :condition] = repeat(["B"], nrow(data2))

data = vcat(data1, data2)

# Specify model
@model model(choice, rt) = begin
    min_rt = minimum(rt)  # Get min RT
    ν ~ MvNormal(zeros(2), I * 2)
    A ~ truncated(Normal(0.8, 0.4), 0.0, Inf)
    k ~ truncated(Normal(0.2, 0.2), 0.0, Inf)
    τ ~ Uniform(0.0, min_rt)
    data ~ LBA(; ν, A, k, τ)
end


sample(model(data[!, :choice], data[!, :rt]), Prior(), 5000)
ERROR: MethodError: no method matching iterate(::LBA{Vector{Float64}, Float64, Float64, Float64})

I suspect this is because LBA() returns a tuple. But I'm not sure what to do here, I tried things like having:

(choice, rt) ~ LBA(; ν, A, k, τ) 

but it doesn't seem to be the solution. Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions