This question is a technical follow-up of this question.
I have trouble understanding and replicating the model presented in Raftery (1988): Inference for the binomial $N$ parameter: a hierarchical Bayes approach in WinBUGS/OpenBUGS/JAGS. It is not only about code though so it should be on-topic here.
Background
Let $x=(x_{1},\ldots,x_{n})$ be a set of success counts from a binomial distribution with unknown $N$ and $\theta$. Further, I assume that $N$ follows a Poisson distribution with parameter $\mu$ (as discussed in the paper). Then, each $x_{i}$ has a Poisson distribution with mean $\lambda = \mu \theta$. I want to specify the priors in terms of $\lambda$ and $\theta$.
Assuming that I don't have any good prior knowledge about $N$ or $\theta$, I want to assign non-informative priors to both $\lambda$ and $\theta$. Say, my priors are $\lambda\sim \mathrm{Gamma}(0.001, 0.001)$ and $\theta\sim \mathrm{Uniform}(0, 1)$.
The author uses an improper prior of $p(N,\theta)\propto N^{-1}$ but WinBUGS does not accept improper priors.
Example
In the paper (page 226), the following success counts of observed waterbucks are provided: $53, 57, 66, 67, 72$. I want to estimate $N$, the size of the population.
Here is how I tried to work out the example in WinBUGS (updated after @Stéphane Laurent's comment):
model {
# Likelihood
for (i in 1:N) {
x[i] ~ dbin(theta, n)
}
# Priors
n ~ dpois(mu)
lambda ~ dgamma(0.001, 0.001)
theta ~ dunif(0, 1)
mu <- lambda/theta
}
# Data
list(x = c(53, 57, 66, 67, 72), N = 5)
# Initial values
list(n = 100, lambda = 100, theta = 0.5)
list(n = 1000, lambda = 1000, theta = 0.8)
list(n = 5000, lambda = 10, theta = 0.2)
The model does sill not converge nicely after 500'000 samples with 20'000 burn-in samples. Here is the output of a JAGS run:
Inference for Bugs model at "jags_model_binomial.txt", fit using jags,
5 chains, each with 5e+05 iterations (first 20000 discarded), n.thin
= 5 n.sims = 480000 iterations saved
mu.vect sd.vect 2.5% 25% 50% 75% 97.5% Rhat n.eff
lambda 63.081 5.222 53.135 59.609 62.938 66.385 73.856 1.001 480000
mu 542.917 1040.975 91.322 147.231 231.805 462.539 3484.324 1.018 300
n 542.906 1040.762 95.000 147.000 231.000 462.000 3484.000 1.018 300
theta 0.292 0.185 0.018 0.136 0.272 0.428 0.668 1.018 300
deviance 34.907 1.554 33.633 33.859 34.354 35.376 39.213 1.001 43000
Questions
Clearly, I am missing something, but I can't see what exactly. I think my formulation of the model is wrong somewhere. So my questions are:
- Why does my model and its implementation not work?
- How could the model given by Raftery (1988) be formulated and implemented correctly?
mu=lambda/theta
and replacen ~ dpois(lambda)
withn ~ dpois(mu)
$\endgroup$