In R's glm() function you can fit a logistic regression (with family = binomial) by using a "column specification" of the response variable like so:
glm(cbind(success, (n - sucess)) ~ 1, family = binomial, ...)
The documentation of brmsformula (under additional response information) states, that in brm() the same can be achieved with:
brm(success | trials(n) ~ 1, family = binomial, ...)
This seems to work as can be seen from the following (admittedly rather silly) example:
set.seed(1)
n_rows = 10
success = abs(round(rnorm(n_rows), 1) * n_rows)
n = success * 2
data = data.frame(success, n)
library(brms)
model = brm(success | trials(n) ~ 1,
data = data,
family = binomial("logit"))
However, when I increase n_rows
, say to 100, I get the following error message:
Error: Family 'binomial' requires integer responses.
Can somebody make sense of why that is? In glm the data with n_rows = 100
works fine.
(Obviously my real data (where the error occurs as well) looks different. I just managed to recreate it like this.)
Any help is very welcome!