I want to perform a bayesian logistic regression on my repeated measure data. I have a problem with specifying the formula and specifying random effects. would you please help me to fix that?
i want to have a random effect based on participant id.
yielding (0,1) is my response variable and TTA is my predictor and I want have a random effect based on parti_id
i used this formula but I get an error:
brm(data = df2,
family = binomial,
yielding ~ 1 + TTA + (1 | parti_id),
prior = c(prior(normal(0, 2), class = Intercept),
prior(normal(0, 2), class = b),
prior(normal(0, 2), class = sd)),
iter = 2500, warmup = 500, chains = 4, cores = 4,
seed = 21)

I get this error:
Warning: Using ‘binomial’ families without specifying ‘trials’ on the left-hand side of the model formula is deprecated.Only 2 levels detected so that family ‘bernoulli’ might be a more efficient choice.

do you have any idea about this? very much appreciated your response.

Welcome to the forum. That’s not an error, but a warning telling you that you might find the HMC sampling to be more efficient if you specify

brm(
data = df2,
family = bernoulli, # bernoulli instead of binomial
yielding ~ 1 + TTA + (1 | parti_id),
prior = c(
prior(normal(0, 2), class = Intercept),
prior(normal(0, 2), class = b),
prior(normal(0, 2), class = sd)
),
iter = 2500, warmup = 500, chains = 4, cores = 4,
seed = 21
)

I also recommend using more iterations for the warmup phase so that the final samples start off clean. The default of using half of samples for warmup makes sense usually.

By the way, when you want to show some code, it is much easier to read if you wrap it in three backticks, like this

@matti’s suggestion to use the Bernoulli likelihood is great. If you’d like to stay with the binomial likelihood, you can use code like this:

brm(
data = df2,
family = binomial,
yielding | trials(1) ~ 1 + TTA + (1 | parti_id),
prior = c(
prior(normal(0, 2), class = Intercept),
prior(normal(0, 2), class = b),
prior(normal(0, 2), class = sd)
),
iter = 2500, warmup = 500, chains = 4, cores = 4,
seed = 21
)

Notice the | trials(1) syntax on the left side of the model formula. That’s what the warning message was referring to with the phrase: “Using ‘binomial’ families without specifying ‘trials’ on the left-hand side of the model formula is deprecated.” With the | trials(1) syntax, you are explicitly telling brm() each row in the yielding variable corresponds to a single Bernoulli trial.