Logistic regression with fractional outcome in rstanarm / brms

Hi everyone,

in base R it is possible to specify a two-column matrix as outcome in a binomial glm, where the first column is a fraction and the second indicates the total counts, like so:

glm(cbind(frac, counts) ~ x, data=dat, family=binomial)

I tried that in rstanarm but that doesn’t seem to be supported: Error: All outcome values must be counts for binomial models.

Does somebody know a workaround or if/how to specify something like that in brms?

Thanks!

I don’t use rstanarm very often, but I was able to find this resource on fitting binomial models that talks about how to specify the cbind(..., ...) outcome.

From that information, it seems like the expected inputs for the outcome are cbind(number of successes, number of failures), so I think that to make it work you’ll need to convert the fraction back to the raw number of correct responses. The syntax they use should make that the only change you need to make since then failures can be entered as trials - successes (or, in your case something like cbind(success, counts - success)).

The same setup, I believe, is also going to be true with brms. Whenever I run binomial regressions in brms, I write the outcome as bf(success | trials(counts) ~ X). So, seems like both will require conversion of that fraction into the whole number of successes.

2 Likes

Thanks, that is exactly what I was looking for!