Great, so something like this:
@model bayes_sir(y) = begin
# Calculate number of timepoints
l = length(y)
i₀ ~ Uniform(0.0,1.0)
β = rand(Uniform(0.0,1.0))
I = i₀*1000.0
u0=[1000.0-I,I,0.0,0.0]
p=[β,10.0,0.25]
tspan = (0.0,float(l))
prob = ODEProblem(sir_ode!,
u0,
tspan,
p)
sol = solve(prob,
Tsit5(),
saveat = 1.0)
sol_C = Array(sol)[4,:] # Cumulative cases
sol_X = sol_C[2:end] - sol_C[1:(end-1)]
l = length(y)
for i in 1:l
y[i] ~ Poisson(sol_X[i])
end
end;
and then use the trick from Is there a turing alternative to pm.Deterministic from pymc3? - #3 by torfjelde to keep track of the samples from beta?
There are a couple of applications I had in mind:
-
For computational efficiency, when I know that a parameter has no influence on the likelihood.
-
When the prior was estimated using some external source that I think is more reliable than my own data. For example, say I observe deaths in patients from treatments A and B. A clinical trial reports a hazard rate ratio (hr) for the effectiveness of A vs. B. I assume the likelihood is: deaths_a ~ Poisson(lambda * hr) and deaths_b ~ Poisson(lambda). I want to run inference on lambda but I want to leave hr unchanged from its prior.