Thanks for the prompt response. I was using one data point just to test if the code was working.
Here are some simulated data which should make the probabilistic model clearer.
fn = .2
fp = .05
n = [100] * 200
contaminated = np.random.binomial(100,.4)
not_contaminated = 100 - contaminated
true_positive = np.random.binomial(contaminated, (1-fn))
false_positive =np.random.binomial(not_contaminated,fp)
y = true_positive + false_positive
with Model() as food_model:
positives = pm.DiscreteUniform("positives", lower = 0, upper = n)
proportion_positives = pm.Deterministic("proportion_positives", positives/100.0)
true_positives = pm.Binomial("true_positives", n = positives, p = (1 - fn))
false_positives = pm.Binomial("false_positives", n = y - positives, p = fp)
model = pm.Deterministic('model', true_positives + false_positives, observed = y)
with food_model:
# Draw samples
trace = sample(1000, njobs=2)
# Plot parameter
forestplot(trace, varnames=['proportion_positives'])
print pm.stats.hpd(trace['proportion_positives'], .05)