Weird, I noticed an error where I wasn’t broadcasting when doing the counts of vaxxed and unvaxxed, and fixed it, now I have a different error:
@model function vaxxdecision(data)
pv ~ Beta(1.0,100.0)
punv ~ Beta(1.0,100.0)
vaxxed = sum(data.vaxxed .==true)
unvaxxed = sum(data.vaxxed .==false)
vaxxedinf = sum(data[data.vaxxed .==true,:infected])
unvaxxedinf = sum(data[data.vaxxed .==false,:infected])
vaxxedinf ~ Binomial(vaxxed,pv)
unvaxxedinf ~ Binomial(unvaxxed,punv)
end
simdata = DataFrame(vaxxed = [s.vaxdose > 0 for s in sims],
infected=[x.severity > .01 for x in sims])
chain = sample(vaxxdecision(simdata),NUTS(500,.01),1000)
julia> chain = sample(vaxxdecision(simdata),NUTS(500,.85),1000)
┌ Info: Found initial step size
└ ϵ = 0.2
Sampling 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| Time: 0:00:02
ERROR: InexactError: Int64(359.01732013963164)
Stacktrace:
[1] Int64
@ ./float.jl:812 [inlined]
[2] convert
@ ./number.jl:7 [inlined]
[3] setindex!
@ ./array.jl:877 [inlined]
[4] setindex!
@ ./subarray.jl:317 [inlined]
[5] copyto_unaliased!(deststyle::IndexCartesian, dest::SubArray{Int64, 1, Vector{Int64}, Tuple{Vector{Int64}}, false}, srcstyle::IndexLinear, src::SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true})
@ Base ./abstractarray.jl:1032
[6] copyto!
@ ./abstractarray.jl:998 [inlined]
[7] copyto!
@ ./broadcast.jl:998 [inlined]
[8] copyto!
@ ./broadcast.jl:957 [inlined]
[9] materialize!
@ ./broadcast.jl:915 [inlined]
[10] materialize!
@ ./broadcast.jl:912 [inlined]
[11] macro expansion
@ ~/.julia/packages/DynamicPPL/wf0dU/src/varinfo.jl:0 [inlined]
[12] _setindex!(metadata::NamedTuple{(:pv, :punv, :vaxxedinf, :unvaxxedinf), Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:pv, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{DynamicPPL.VarName{:pv, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:punv, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{DynamicPPL.VarName{:punv, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:vaxxedinf, Tuple{}}, Int64}, Vector{Binomial{Float64}}, Vector{DynamicPPL.VarName{:vaxxedinf, Tuple{}}}, Vector{Int64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:unvaxxedinf, Tuple{}}, Int64}, Vector{Binomial{Float64}}, Vector{DynamicPPL.VarName{:unvaxxedinf, Tuple{}}}, Vector{Int64}, Vector{Set{DynamicPPL.Selector}}}}}, val::Vector{Float64}, ranges::NamedTuple{(:pv, :punv, :vaxxedinf, :unvaxxedinf), NTuple{4, Vector{Int64}}})
@ DynamicPPL ~/.julia/packages/DynamicPPL/wf0dU/src/varinfo.jl:892
[13] setindex!(vi::DynamicPPL.TypedVarInfo{NamedTuple{(:pv, :punv, :vaxxedinf, :unvaxxedinf), Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:pv, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{DynamicPPL.VarName{:pv, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:punv, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{DynamicPPL.VarName{:punv, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:vaxxedinf, Tuple{}}, Int64}, Vector{Binomial{Float64}}, Vector{DynamicPPL.VarName{:vaxxedinf, Tuple{}}}, Vector{Int64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:unvaxxedinf, Tuple{}}, Int64}, Vector{Binomial{Float64}}, Vector{DynamicPPL.VarName{:unvaxxedinf, Tuple{}}}, Vector{Int64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, val::Vector{Float64}, spl::DynamicPPL.Sampler{NUTS{Turing.Core.ForwardDiffAD{40}, (), AdvancedHMC.DiagEuclideanMetric}})
@ DynamicPPL ~/.julia/packages/DynamicPPL/wf0dU/src/varinfo.jl:888
[14] step(rng::Random._GLOBAL_RNG, model::DynamicPPL.Model{var"#115#116", (:data,), (), (), Tuple{DataFrame}, Tuple{}}, spl::DynamicPPL.Sampler{NUTS{Turing.Core.ForwardDiffAD{40}, (), AdvancedHMC.DiagEuclideanMetric}}, state::Turing.Inference.HMCState{DynamicPPL.TypedVarInfo{NamedTuple{(:pv, :punv, :vaxxedinf, :unvaxxedinf), Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:pv, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{DynamicPPL.VarName{:pv, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:punv, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{DynamicPPL.VarName{:punv, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:vaxxedinf, Tuple{}}, Int64}, Vector{Binomial{Float64}}, Vector{DynamicPPL.VarName{:vaxxedinf, Tuple{}}}, Vector{Int64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:unvaxxedinf, Tuple{}}, Int64}, Vector{Binomial{Float64}}, Vector{DynamicPPL.VarName{:unvaxxedinf, Tuple{}}}, Vector{Int64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, AdvancedHMC.NUTS{AdvancedHMC.MultinomialTS, AdvancedHMC.GeneralisedNoUTurn, AdvancedHMC.Leapfrog{Float64}, Float64}, AdvancedHMC.Hamiltonian{AdvancedHMC.DiagEuclideanMetric{Float64, Vector{Float64}}, Turing.Inference.var"#logπ#54"{DynamicPPL.TypedVarInfo{NamedTuple{(:pv, :punv, :vaxxedinf, :unvaxxedinf), Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:pv, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{DynamicPPL.VarName{:pv, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:punv, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{DynamicPPL.VarName{:punv, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:vaxxedinf, Tuple{}}, Int64}, Vector{Binomial{Float64}}, Vector{DynamicPPL.VarName{:vaxxedinf, Tuple{}}}, Vector{Int64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:unvaxxedinf, Tuple{}}, Int64}, Vector{Binomial{Float64}}, Vector{DynamicPPL.VarName{:unvaxxedinf, Tuple{}}}, Vector{Int64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, DynamicPPL.Sampler{NUTS{Turing.Core.ForwardDiffAD{40}, (), AdvancedHMC.DiagEuclideanMetric}}, DynamicPPL.Model{var"#115#116", (:data,), (), (), Tuple{DataFrame}, Tuple{}}}, Turing.Inference.var"#∂logπ∂θ#53"{DynamicPPL.TypedVarInfo{NamedTuple{(:pv, :punv, :vaxxedinf, :unvaxxedinf), Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:pv, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{DynamicPPL.VarName{:pv, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:punv, Tuple{}}, Int64}, Vector{Beta{Float64}}, Vector{DynamicPPL.VarName{:punv, Tuple{}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:vaxxedinf, Tuple{}}, Int64}, Vector{Binomial{Float64}}, Vector{DynamicPPL.VarName{:vaxxedinf, Tuple{}}}, Vector{Int64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:unvaxxedinf, Tuple{}}, Int64}, Vector{Binomial{Float64}}, Vector{DynamicPPL.VarName{:unvaxxedinf, Tuple{}}}, Vector{Int64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, DynamicPPL.Sampler{NUTS{Turing.Core.ForwardDiffAD{40}, (), AdvancedHMC.DiagEuclideanMetric}}, DynamicPPL.Model{var"#115#116", (:data,), (), (), Tuple{DataFrame}, Tuple{}}}}, AdvancedHMC.PhasePoint{Vector{Float64}, AdvancedHMC.DualValue{Float64, Vector{Float64}}}, AdvancedHMC.Adaptation.StanHMCAdaptor{AdvancedHMC.Adaptation.WelfordVar{Float64, Vector{Float64}}, AdvancedHMC.Adaptation.NesterovDualAveraging{Float64}}}; nadapts::Int64, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Turing.Inference ~/.julia/packages/Turing/uAz5c/src/inference/hmc.jl:292
[15] macro expansion
@ ~/.julia/packages/AbstractMCMC/oou1a/src/sample.jl:108 [inlined]
[16] macro expansion
@ ~/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl:328 [inlined]
[17] (::AbstractMCMC.var"#20#21"{Bool, String, Nothing, Int64, Int64, Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:nadapts,), Tuple{Int64}}}, Random._GLOBAL_RNG, DynamicPPL.Model{var"#115#116", (:data,), (), (), Tuple{DataFrame}, Tuple{}}, DynamicPPL.Sampler{NUTS{Turing.Core.ForwardDiffAD{40}, (), AdvancedHMC.DiagEuclideanMetric}}, Int64, Int64})()
@ AbstractMCMC ~/.julia/packages/AbstractMCMC/oou1a/src/logging.jl:11
[18] with_logstate(f::Function, logstate::Any)
...