Plot_comparisons() works for fixed effects model but produces a "non-negative integer" error for my mixed effects model

UPDATE … I needed to pass the trials parameter in the conditions argument, for some reason the comparisons weren’t made on the datagrid numbers

Summary

Hello,

I am having trouble plotting conditional comparisons (plot_comparisons) for my mixed effects binomial model (BRMS , marginaleffects). For some background context, I am trying to analyze results from an AB Test (variants = treatment, control | new_feature = yes, no) where the treatment group has a small subset of users who actually use the new feature.

I have tried numerous combinations and found out that when I add random efects into my model, I get an error with plot_comparisons() “Error: number of trials must be non-negative”. When I use this method with a model of only fixed effects, this works.

Here are the options I’m thinking are likely. Hoping you have some thoughts/input:

  • the random intercept effect is too large, and giving a large negative value that the link function cannot transform to a probability scale
  • the plot_comparisons() is finding a difference between the treatment and control, and then applying a transformation function after which does not accept negative numbers
  • because there is no data in the control group for the new_feature, the comparisons method isn’t getting compared to its respective group. Although I don’t this is likely…
formula 1 ~ variant * new_feature + user_type + (1 | user_type)
formula 2 ~ variant + new_feature + user_type
---
plot_comparisons(m_fe, variables = 'variant', condition = c('user_type', 'new_feature'))
plot_comparisons(m_me, variables = 'variant', condition = c('user_type', 'new_feature'))

If possible, add also code to simulate data or attach a (subset of) the dataset you work with.

Please also provide the following information in addition to your question:

  • Operating System: Mac OS Sonoma
  • brms Version: