Okay, I’ve managed to narrow it down to the following.
If I change k
to the following:
k = [2042914, 745828, 277760, 205701, 97427, 152673]
and then generate the MAP estimate with a specific set of initial parameters:
map_estimate = optimize(model, MAP(), [0.1, 0.1, 0.01, 100])
(with everything else kept the same) I run into the previously mentioned error:
ERROR: LoadError: ArgumentError: BetaBinomial: the condition n >= zero(n) && (α >= zero(α) && β >= zero(β)) is not satisfied.
I have tried adding @info N[i], α, β
inside the model. With this, I find the following lines just before the error is called:
[...] a lot of [ Info: ] above here
[ Info: (8877887, Dual{ForwardDiff.Tag{Turing.Core.var"#f#3"{DynamicPPL.TypedVarInfo{NamedTuple{(:q, :A, :c, :ϕ), Tuple{DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:q, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:q, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:A, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:A, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:c, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:c, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:ϕ, Tuple{}}, Int64}, Vector{Exponential{Float64}}, Vector{AbstractPPL.VarName{:ϕ, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, DynamicPPL.Model{var"#24#25", (:z, :k, :N), (), (), Tuple{Vector{Int64}, Vector{Int64}, Vector{Int64}}, Tuple{}}, DynamicPPL.SampleFromPrior, Turing.OptimizationContext{DynamicPPL.DefaultContext}}, Float64}}(7.453710778999033,-1.1633888898325928,0.29162337763363744,6.945280851663119,7.417474913162984), Dual{ForwardDiff.Tag{Turing.Core.var"#f#3"{DynamicPPL.TypedVarInfo{NamedTuple{(:q, :A, :c, :ϕ), Tuple{DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:q, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:q, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:A, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:A, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:c, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:c, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:ϕ, Tuple{}}, Int64}, Vector{Exponential{Float64}}, Vector{AbstractPPL.VarName{:ϕ, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, DynamicPPL.Model{var"#24#25", (:z, :k, :N), (), (), Tuple{Vector{Int64}, Vector{Int64}, Vector{Int64}}, Tuple{}}, DynamicPPL.SampleFromPrior, Turing.OptimizationContext{DynamicPPL.DefaultContext}}, Float64}}(403.94591260649196,1.1633888898325928,-0.29162337763363744,-6.945280851663119,401.98214847232805))
[ Info: (8669401, Dual{ForwardDiff.Tag{Turing.Core.var"#f#3"{DynamicPPL.TypedVarInfo{NamedTuple{(:q, :A, :c, :ϕ), Tuple{DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:q, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:q, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:A, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:A, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:c, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:c, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:ϕ, Tuple{}}, Int64}, Vector{Exponential{Float64}}, Vector{AbstractPPL.VarName{:ϕ, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, DynamicPPL.Model{var"#24#25", (:z, :k, :N), (), (), Tuple{Vector{Int64}, Vector{Int64}, Vector{Int64}}, Tuple{}}, DynamicPPL.SampleFromPrior, Turing.OptimizationContext{DynamicPPL.DefaultContext}}, Float64}}(7.162863556540884,-0.3614415363041935,0.07248121590660006,6.945280851663119,7.128041630854146), Dual{ForwardDiff.Tag{Turing.Core.var"#f#3"{DynamicPPL.TypedVarInfo{NamedTuple{(:q, :A, :c, :ϕ), Tuple{DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:q, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:q, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:A, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:A, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:c, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:c, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:ϕ, Tuple{}}, Int64}, Vector{Exponential{Float64}}, Vector{AbstractPPL.VarName{:ϕ, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, DynamicPPL.Model{var"#24#25", (:z, :k, :N), (), (), Tuple{Vector{Int64}, Vector{Int64}, Vector{Int64}}, Tuple{}}, DynamicPPL.SampleFromPrior, Turing.OptimizationContext{DynamicPPL.DefaultContext}}, Float64}}(404.2367598289501,0.3614415363041935,-0.07248121590660006,-6.945280851663119,402.2715817546368))
[ Info: (7642688, Dual{ForwardDiff.Tag{Turing.Core.var"#f#3"{DynamicPPL.TypedVarInfo{NamedTuple{(:q, :A, :c, :ϕ), Tuple{DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:q, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:q, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:A, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:A, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:c, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:c, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:ϕ, Tuple{}}, Int64}, Vector{Exponential{Float64}}, Vector{AbstractPPL.VarName{:ϕ, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, DynamicPPL.Model{var"#24#25", (:z, :k, :N), (), (), Tuple{Vector{Int64}, Vector{Int64}, Vector{Int64}}, Tuple{}}, DynamicPPL.SampleFromPrior, Turing.OptimizationContext{DynamicPPL.DefaultContext}}, Float64}}(NaN,NaN,NaN,NaN,NaN), Dual{ForwardDiff.Tag{Turing.Core.var"#f#3"{DynamicPPL.TypedVarInfo{NamedTuple{(:q, :A, :c, :ϕ), Tuple{DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:q, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:q, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:A, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:A, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:c, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{AbstractPPL.VarName{:c, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:ϕ, Tuple{}}, Int64}, Vector{Exponential{Float64}}, Vector{AbstractPPL.VarName{:ϕ, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, DynamicPPL.Model{var"#24#25", (:z, :k, :N), (), (), Tuple{Vector{Int64}, Vector{Int64}, Vector{Int64}}, Tuple{}}, DynamicPPL.SampleFromPrior, Turing.OptimizationContext{DynamicPPL.DefaultContext}}, Float64}}(Inf,NaN,NaN,NaN,NaN))
ERROR: LoadError: ArgumentError: BetaBinomial: the condition n >= zero(n) && (α >= zero(α) && β >= zero(β)) is not satisfied.
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/Distributions/fXTVC/src/utils.jl:6 [inlined]
[2] #BetaBinomial#42
@ ~/.julia/packages/Distributions/fXTVC/src/univariate/discrete/betabinomial.jl:30 [inlined]
[3] BetaBinomial
@ ~/.julia/packages/Distributions/fXTVC/src/univariate/discrete/betabinomial.jl:30 [inlined]
[4] #24
@ ~/work/julia_metaDMG/metaDMG/fit.jl:91 [inlined]
[...] continues with long error messages here
I do not know if this error is reproducible, but I can at least recreate it now.