# VGAM fitting a betabinomial model

I have a small question, given this:

fit <- vglm(cbind(R, N-R) ~ 1, betabinomial, lirat, trace=TRUE, subset=(N > 1))


Why should I do cbind(R, N-R)? Can someone explain this simple step to me? If I leave out that part, I get an error saying that I can only fit 0, 1. But in the example here, $Y$ can contain a lot of different values.

• Although the question explicitly asks about R code, the real issue is understanding the nature of the beta binomial distribution--ie, a statistical issue. The issue & the answer would be the same for any software. This should be on topic here, IMO. – gung - Reinstate Monica Jul 16 '15 at 19:08

The binomial distribution is the distribution of the number of 'successes' out of a known, finite number of 'trials' (e.g., heads on a certain number of coin flips). With a fixed probability of success, $\pi$, and a fixed number of trials, $n$, the variance of the number of successes is fixed as well. A typical logistic regression scenario has Bernoulli data (a single coin flip) as its response, but when you have binomial data with $n>1$ per observation, you can find that the response data vary more than they ought to. In that case, the assumptions of a binomial GLiM will be violated.
The beta binomial distribution relaxes that assumption. It contains three parameters, $n, \alpha, \& \beta$, which gives it additional flexibility to address the overdispersion in the situation described above. The important point here, though, is that the overdispersion / greater variance can only exist with data that are counts of successes out of $n>1$ trials. Thus, R (or any other software) needs the data to be in that form to fit the model. SAS, for example, uses events/trials; R uses cbind(successes, failures), which is equivalent. (For what it's worth, in the documentation page you link to, I see only cbind(successes, failures) in the examples listed.)