Hello everyone,
I would like to use brms to perform a meta-analysis of proportions (infection of impanted medical devices).
n_infections: number of infections per study
n_patients: number of patients per study
study: the name of the study
I expect a proportion of 7%
study <- c("study1", "study2", "study3", "study4", "study5", "study6", "study7", "study8", "study9", "study10", "study11", "study12", "study13", "study14", "study15", "study16", "study17", "study18", "study19", "study20", "study21", "study22", "study23", "study24", "study25", "study26", "study27", "study28", "study29", "study30", "study31", "study32", "study33", "study34", "study35", "study36", "study37", "study38", "study39", "study40", "study41", "study42", "study43")
n_patients <- c(432, 255, 214, 295, 440, 509, 599, 289, 476, 269, 450, 500, 286, 31, 496, 244, 9677, 201, 99, 380, 7199, 720, 74, 111, 82, 95, 227, 17035, 159, 810, 91, 10819, 55, 407, 639, 289, 133, 68, 134, 349, 245, 458, 490)
n_infections <- c(40, 18, 18, 40, 40, 25, 7, 15, 15, 5, 24, 13, 27, 1, 12, 9, 50, 5, 3, 24, 338, 44, 14, 4, 2, 8, 13, 1039, 3, 61, 5, 380, 6, 45, 32, 24, 5, 1, 0, 31, 10, 32, 25)
my_data <- data.frame (study, n_patients,n_infections)
require (brms)
# specify the prior distribution of the overall effect size μ and the between-study heterogeneity τ
priors <- c (prior (normal (7, 2), class = Intercept),
prior (cauchy (0, 1), class = sd))
# fit the model.
brm1 <- brm (n_infections | trials (n_patients) ~ (1 | study),
data = my_data,
prior = priors,
family = binomial (),
iter = 5000)
Despite, brms manual reading and internet search I am not sure how to do it.
Is it correct ?
How would you do ?
Thank you very much in advance for your help.
- Operating System: Windows 10 / RStudio 2022.07.1 Build 554
- brms Version: 2.18.0