Estimation of herd-level prevalence: 1 test, multiple populations
WinBUGS 1.4 code to accompany the paper entitled "Branscum AJ, Gardner IA, Johnson WO. Bayesian modeling of animal- and herd-level prevalences. Prev Vet Med. 2004 Dec 15;66(1-4):101-112".
Code prepared by Adam Branscum, November 18, 2003
branscum@ms.uky.edu
Departments of Biostatistics and Statistics
University of Kentucky
Example from section 3.2.1.
Estimation of the herd-level prevalence (tau) and prevalence distribution of Johne's disease in California based on screening with IDEXX ELISA.
model;
{
Se ~ dbeta(58.8, 174.5) ## Mode=0.25; 95% sure < 0.30
Sp ~ dbeta(272.4, 6.5) ## Mode=0.98, 95% sure > 0.96
tau ~ dbeta(4.8, 3.6) ## Mode=0.60, 95% sure < 0.827
alpha <- mu*psi
beta <- psi*(1-mu)
mu ~ dbeta(3.283, 17.744) ## Mode=0.12, 95% sure < 0.30.
psi ~ dgamma(4.524, 0.387) ## Uses Median of 95th percentile of prevalence
## distribution=0.30 and 99% sure this number is < 0.50
for(i in 1:k)
{
prob.tpos[i] <- pi[i]*Se + (1-pi[i])*(1-Sp)
y[i] ~ dbin(prob.tpos[i], n)
inf[i] ~ dbern(tau)
pi.star[i] ~ dbeta(alpha,beta)
pi[i] <- pi.star[i] * inf[i]
}
Z30 ~ dbern(tau)
pistar30 ~ dbeta(alpha,beta)
pi30 <- Z30*pistar30
a1 <- 1-step(pi30 - 0.05)
a2 <- 1-step(pi30-0.5)
a3 <- equals(pi30,0)
b1 <- step(tau-0.50)
}
list(k=29, n=60, y=c(2,1,2,2,3,6,0,6,3,13,2,3,1,7,2,2,0,4,1,2,6,1,4,0,5,4,2,0,13))
list(Se=0.25, Sp=0.98, mu=0.12, psi=11.69, tau=0.60,
pi.star=c(0.05, 0.05,0.05,0.05,0.05,0.05, 0.05,0.05,0.05,0.05,0.05, 0.05,0.05,0.05,0.05,0.05, 0.05,0.05,0.05,0.05,0.05, 0.05,0.05,0.05,0.05,0.05, 0.05,0.05,0.05),
inf=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), Z30=0, pistar30=0.05)
node |
mean |
sd |
MC error |
2.50% |
median |
97.50% |
start |
sample |
Se |
0.2642 |
0.02716 |
2.03E-04 |
0.2133 |
0.2634 |
0.3188 |
5001 |
50000 |
Sp |
0.9756 |
0.00618 |
6.57E-05 |
0.9629 |
0.9758 |
0.987 |
5001 |
50000 |
a1 |
0.5146 |
0.4998 |
0.002515 |
0 |
1 |
1 |
5001 |
50000 |
a2 |
0.9702 |
0.1701 |
8.35E-04 |
0 |
1 |
1 |
5001 |
50000 |
a3 |
0.4201 |
0.4936 |
0.002906 |
0 |
0 |
1 |
5001 |
50000 |
alpha |
1.758 |
1.155 |
0.02111 |
0.4283 |
1.47 |
4.756 |
5001 |
50000 |
b1 |
0.7001 |
0.4582 |
0.005842 |
0 |
1 |
1 |
5001 |
50000 |
beta |
6.462 |
3.168 |
0.04273 |
2.081 |
5.863 |
14.25 |
5001 |
50000 |
mu |
0.2084 |
0.06054 |
0.001253 |
0.1068 |
0.2026 |
0.3428 |
5001 |
50000 |
pi30 |
0.1175 |
0.1551 |
8.69E-04 |
0 |
0.04166 |
0.5196 |
5001 |
50000 |
psi |
8.22 |
4.128 |
0.06068 |
2.638 |
7.415 |
18.43 |
5001 |
50000 |
tau |
0.5792 |
0.1428 |
0.002234 |
0.3005 |
0.5792 |
0.847 |
5001 |
50000 |