@GreyMerchant Sir/madam- please copy and paste the following table save as all_es.csv in the desktop and use that with the following code:
| study |
year |
test |
n_controls |
n_patients |
age_controls |
age_patients |
mean_controls |
mean_patients |
sd_controls |
sd_patients |
yi |
vi |
| Caraquez |
1998 |
n-back |
12 |
15 |
39.1 |
23.4 |
1.01 |
15.4 |
31.1 |
0.9 |
-0.67601411442671 |
0.158462871905632 |
| Caraquez |
1998 |
n-back |
12 |
15 |
39.1 |
23.4 |
1.01 |
54 |
2.1 |
7 |
-9.47933975490664 |
1.81403485535099 |
| Franzen |
2012 |
n-back |
65 |
56 |
67.1 |
66.9 |
10 |
47 |
91.1 |
5 |
-0.549607753881664 |
0.03448997594063 |
| Franzen |
2012 |
n-back |
65 |
56 |
67.1 |
66.9 |
50 |
67 |
4.1 |
2 |
-5.11910608650243 |
0.141527903385833 |
| Franzen |
2012 |
n-back |
65 |
56 |
67.1 |
66.9 |
50 |
67 |
6.1 |
2 |
-3.61295800630745 |
0.087181698553085 |
| Lieu |
2012 |
digit_span |
102 |
99 |
21.1 |
23.4 |
24 |
10 |
21.5 |
5 |
0.887578672128736 |
0.021864622961224 |
| Lieu |
2012 |
digit_span |
102 |
99 |
21.1 |
23.4 |
12 |
20 |
1.5 |
5 |
-2.17285011427459 |
0.031649403358949 |
| Lieu |
2012 |
digit_span |
102 |
99 |
21.1 |
23.4 |
12 |
20 |
1.9 |
9 |
-1.23386292200698 |
0.023692040401736 |
| McMullin |
1990 |
n-back |
10 |
10 |
35.6 |
25.1 |
1.02 |
111 |
0.29 |
0.29 |
-363.179151876099 |
3297.67740893607 |
| McMullin |
1990 |
n-back |
10 |
10 |
35.6 |
25.1 |
1.02 |
131 |
0.5 |
0.29 |
-304.549916872949 |
2318.966296683 |
| McMullin |
1990 |
n-back |
10 |
10 |
35.6 |
25.1 |
1.02 |
1 |
2.5 |
0.29 |
0.01076236528614 |
0.200002895712664 |
| Meyer |
1992 |
digit_span |
75 |
80 |
22.2 |
54.5 |
56 |
61 |
0.9 |
6.8 |
-1.00999884488257 |
0.029123970967734 |
| Meyer |
1992 |
digit_span |
75 |
80 |
22.2 |
54.5 |
56 |
61 |
0.9 |
6.8 |
-1.00999884488257 |
0.029123970967734 |
Code:
library(RCurl)
library(bitops)
library(metafor)
library(Formula)
library(dplyr)
library(ggforestplot)
all_csv <- read.csv("~/Desktop/all_es.csv")
Bacteria <- unique(all_csv$Bacteria)
single_bacteria <- all_csv %>% count(Bacteria, sort = TRUE) %>%
filter(n == 1) %>% select(Bacteria) %>% .$Bacteria
single_bacteria
[1] "Adlercreutzia" "Asaccharobacter" "Atopobium"
# Keep only those bacteria that have >1 studies without having to type each bacteria out
final_csv <- all_csv[which(!all_csv$Bacteria %in% single_bacteria), ]
# Our usual code, except now all_csv is replaced with final_csv
bacteria_names <- unique(final_csv$Bacteria)
df <- data.frame(matrix(NA, ncol = 7, nrow = length(bacteria_names)))
df[, 1] <- bacteria_names
names(df) <- c("Bacteria", "estimate", "se", "zval", "pval", "ci.lb", "ci.ub")
df
ma_model <- list()
for(i in 1:length(bacteria_names)){
ma_model[[i]] <- rma.mv(yi, vi, data = final_csv, subset = (Bacteria == bacteria_names[i]))
re_table <- coef(summary(ma_model))
df[i, -1] <- re_table
}
ma_model
I think it will help you to work with my problem.
Thanks,
DC7