{ #model specification for (i in 1:observations) { #app_p:apparent prevalence y[i] ~ dbin(app_p[i], n[i]) #animal_p: animal prevalence #Se:sensitivity #Sp:specificity app_p[i] <- animal_p[i] * Seser + (1 - animal_p[i]) * (1 - Spser) #animal_lev_p: animal level prevalence #herd_not_free: (0/1) the herd is free or not animal_p[i] <- animal_lev_p[i] * herd_not_free[i] herd_not_free[i] ~ dbern(herd_p[region[i]]) animal_lev_p[i] ~ dbeta(alpha, beta) #a: indices to calculate disease freedom or disease exceeding a prespecified level (here 9.5%) for the animals within each herd. a[1, i] <- equals(animal_p[i], 0) a[2, i] <- step(0.095-animal_p[i]) } for (j in 1:regions) { #herd_p: herd prevalence #herd_lev_p: herd level prevalence #region_not_free: (0/1) the region is free or not herd_p[j] <- herd_lev_p[j] * region_not_free[j] # herd_lev_p[j] ~ dbeta(ahp, bhp) herd_lev_p[j] ~ dbeta(1, 1) #region_p: region prevalence region_not_free[j] ~ dbern(region_p) #b: indices to calculate disease freedom or disease exceeding a prespecified level (here 50%) for the herds within each region. b[1, j] <- equals(herd_p[j], 0) b[2, j] <- step(0.50 - herd_p[j]) } #region_p ~ dbeta(arp, brp) region_p ~ dbeta(1, 1) #c: indices to calculate disease freedom or disease exceeding a prespecified level (here 50%) for the regions within the country. c[1] <- equals(region_p, 0) c[2] <- step(0.5 - region_p) #priors #mu: mean prevalence in infected herds #psi: a parameter expressing the variability of prevalence among infected herds mu ~ dbeta(amu, bmu) psi ~ dgamma(apsi, bpsi) alpha <- mu * psi beta <- psi * (1 - mu) Se1 ~ dbeta(ase1, bse1) Sp1 ~ dbeta(asp1, bsp1) Se2 ~ dbeta(ase2, bse2) Sp2 ~ dbeta(asp2, bsp2) Spser<-1-(1-Sp1)*(1-Sp2) Seser<-Se1*Se2 } ##Data list(region=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,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,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