## fit a model using glmmTMB
fit <- glmmTMB::glmmTMB(y ~ Treatment + x1 + x2 + x3 + x4 + (1|Cluster),
data = trial_data, family = binomial(link="logit"),REML = TRUE)
## relative risk, average over random effects and fixed effects
m1 <- margin(fit,
x = "Treatment",
type = "ratio",
average = c("x1","x2","x3","x4"),
re = "average",
se="GLS")
summary(m1)
Run the code above in your browser using DataLab