I a experimenting with a new MCMC software and before I delve into more complicated models I wanted to run some simple simulations. This is a very very simple simulation, so not meant to be very tricky. I am just generating some random data, and then seeing if the software can actually recover those parameters with its MCMC sampler, or conjugacy, etc.
As I was looking over very simple demos, I noticed that I could not find a wide variety of very simple demos. I could find an example of a coin flip, so the data is distributed as a Bernoulli variable that has a Beta prior. Easy enough.
The next level of sophistication would be looking at a binomial random variable, and I could not find what the suitable priors are for this model. That is my question, what are the prior distributions for a Binomial model with unknown $n, p$. Here is the setup. I have some data which is just the number of successes in $n$ trials. For my demo I had 10 trials and a probability of success of $p=0.2$. Now, I generated 100 draws from this distribution, which looks like a vector $[4, 9, 5, 7, 1, 2 ...]$.
My problem was that I could not figure out how to parameterize the prior for $n$ in this model.
$$ n \sim ? \\ p \sim Beta(1, 1)\\ data_i \sim Binomial(n, p) $$
I checked both the McElreath and Gelman et al. books but did not find a way to reason about what priors to use for $n$. I know that $n$ has to be an integer, and that the sum of $a,b$ for the Beta distribution should equal $n$. I can't use a continuous distribution, otherwise I get an error when trying to compute Binomial(n,p).
The closest I figured out was using Binomial(floor(n), p)
and then using a continuous distribution over $n$. This does work but I get a lot of numerical warnings from the sampler :). I actually obtained pretty reasonable estimates for the parameters using NUTS(0.65).
I imagine that there should be a better theory for such a simple problem. Does anyone know a better parameterization?