Thanks. I looked through the doc strings, but still have some questions about what it means to implement a model as @model. However, before I get too far into the details, I wanted to ask you about the code below. I adapted Dominique’s example for a Wald model (basically a reparameterized InverseGaussian), which is actually a subtype of UnivariateContinuousDistribution
:
julia> dist = Wald(ν = 2.0, α=1.0, θ=.3); rand(dist)
0.5196099061252006
If that was the problem (or sole problem), I would expect the code below to work. For some reason it does not. I want to bring that up to make sure we are addressing the correct issue. In addition, the same thing happens if I use InverseGaussian
directly instead of Wald
.
Wald
using Turing
using SequentialSamplingModels
using Random
using LinearAlgebra
# Generate data with different drifts for two conditions A vs. B
Random.seed!(254)
rts = rand(Wald(ν=2.0, α=0.8, θ=0.3), 10)
@model function model_wald(rts)
min_rt = minimum(rts)
ν ~ truncated(Normal(2, 1), 0.0, Inf)
α ~ truncated(Normal(0.8, 0.4), 0.0, Inf)
θ ~ Uniform(0.0, min_rt)
# Likelihood
rts ~ Wald(; ν, α, θ)
return (; rts, ν, α, θ)
end
chain = sample(model_wald(rts), Prior(), 100)
predictions = predict(model_wald(rts), chain)
Inverse Gaussian
using Turing
using Distributions
using Random
using LinearAlgebra
# Generate data with different drifts for two conditions A vs. B
Random.seed!(254)
rts = rand(InverseGaussian(1.0, 0.8,), 10)
@model function model_IG(rts)
ν ~ truncated(Normal(2, 1), 0.0, Inf)
α ~ truncated(Normal(0.8, 0.4), 0.0, Inf)
# Likelihood
rts ~ InverseGaussian(ν, α)
return (; rts, ν, α)
end
chain = sample(model_IG(rts), Prior(), 100)
predictions = predict(model_IG(rts), chain)