In general, you want to do all of your data processing outside of the Turing model, since any done inside the model will need to be repeated every time the log density is evaluated. So try something like this:
@model function vaxxdecision(vaxxed, unvaxxed, vaxxedinf, unvaxxedinf)
pv ~ Beta(1,100)
punv ~ Beta(1,100)
vaxxedinf ~ Binomial(vaxxed,pv)
unvaxxedinf ~ Binomial(unvaxxed,punv)
end
vaxxed = sum(data.vaxxed==true)
unvaxxed = sum(data.vaxxed==false)
vaxxedinf = sum(data[data.vaxxed .==true,:infected])
unvaxxedinf = sum(data[data.vaxxed .==false,:infected])
chain = sample(
vaxxdecision(vaxxed, unvaxxed, vaxxedinf, unvaxxedinf),
NUTS(500, .85),
1000,
)
As the provided example is not complete, I cannot verify that this works. But in this particular case, the posterior is known to be a Beta distribution.
Specifically, the posterior should be something like
pv ~ Beta(1 + vaxxedinf, 100 + vaxxed - vaxxedinf)
punv ~ Beta(1 + unvaxxedinf, 100 + unvaxxed - unvaxxedinf)