I’m not really familiar with incorporating survey weights in analyses, but I don’t see a reason why this particular model couldn’t be implemented in brms
, which would save you from having to wonder whether the Stan code you come up with is correct. It seems like this would just be:
fit <- brm(y | weights(weights) + trials(...) ~ 1,
family = beta_binomial(link = "logit", link_phi = "log"),
...)
Also, just as another discussion of survey weights in Stan, this thread from the forum may have useful information for you: Survey weights in brms/stan - Simulation based on design effect, feedback sought!