Hmm, interesting.
Mathematically I cannot see either why it wouldn’t work, so I went to try and debug. Sadly, println statements were no help for me in this case because they only gave weird objects back which I could not figure out what values were corresponding to what.
However, I did test, and it is definitely caused by \theta going above 1.0, and therefore caused by \alpha_1 + \beta_1 * t[i] somehow going above 0.0
Again, mathematically I can’t figure out why, but maybe there is some indeterminacies with really small numbers etc. causing it to underflow/overflow and what not.
@model function test_fit(y, t, ::Type{T} = Real) where {T}
n_1 = length(t)
β_1 ~ truncated(Normal(-0.01), -0.5, -0.01)
t_min = minimum(t)
α_1 ~ truncated(Normal(0), -2.0, -β_1 * t_min)
θ = Vector{T}(undef, n_1)
for i = 1:n_1
θ[i] = exp(α_1 + β_1 * t[i])
if θ[i] >= 1.0
θ[i] = 1.0
end
y[i] ~ Bernoulli(θ[i])
end
end
To figure out that that was indeed the cause, I did the above and then it gave no errors.
But I would definitely like to hear more from more experienced people as to what could be causing this? Because I just tried with really small and big numbers and taking exp in julia and that itself wasn’t causing any issues, at least none of the numbers that were that small or big can theoretically occur in the above case anyway.