I am doing NMA with netmeta package. Here is the example with publicly available dataset:
library(netmeta)
data("smokingcessation", package ='netmeta')
p1 <- pairwise(treat = list(treat1, treat2, treat3), event = list(event1, event2, event3), n = list(n1, n2, n3), data = smokingcessation, sm = 'RD')
net <- netmeta(p1, common = TRUE, all.treatments = T, sm='RD', method.tau='REML')
forest(net, xlim=c(-0.1,0.1), pooled='common',
reference.group = c('A', 'B', 'C', 'D'),
drop.reference = T,
sortvar = -TE,
)
I got duplicated data on the plot. What I want is to have comparisons:
Other vs A:
Other vs B:
Other vs C:
One way is to assign an object to the plot, modify it, then use metagen
from the meta package to generate the required object which you can pass to forest
.
This is your code, which we assign to fp
:
fp <- forest(net,
xlim=c(-0.1,0.1), pooled='common',
reference.group = c('A','B','C','D'),
drop.reference = TRUE, sortvar = -TE)
It's a data frame:
fp
comparison treat labels TE seTE Pscore SUCRA k prop.direct n.trts
1 Other vs 'A' D D 0.05831001 0.019441217 NA NA 2 0.44159097 555
2 Other vs 'A' C C 0.05280589 0.005317229 NA NA 15 0.98197598 7383
3 Other vs 'A' B B 0.01043509 0.008396496 NA NA 3 0.94657991 1571
4 Other vs 'B' D D 0.04787492 0.020346129 NA NA 2 0.31528433 555
5 Other vs 'B' C C 0.04237080 0.009830423 NA NA 2 0.04175929 7383
6 Other vs 'B' A A -0.01043509 0.008396496 NA NA 3 0.94657991 7231
7 Other vs 'C' D D 0.00550412 0.019563970 NA NA 4 0.57660148 555
8 Other vs 'C' B B -0.04237080 0.009830423 NA NA 2 0.04175929 1571
9 Other vs 'C' A A -0.05280589 0.005317229 NA NA 15 0.98197598 7231
10 Other vs 'D' C C -0.00550412 0.019563970 NA NA 4 0.57660148 7383
11 Other vs 'D' B B -0.04787492 0.020346129 NA NA 2 0.31528433 1571
12 Other vs 'D' A A -0.05831001 0.019441217 NA NA 2 0.44159097 7231
We can drop the rows we don't want, make a minor edit to the labels, and create a new plot:
library(dplyr)
fp[-c(6,8:12),] |>
rowwise() |>
mutate(comparison=sub('Other', treat, comparison)) |>
metagen(TE, seTE, comparison, data=_) |>
forest() # common = FALSE, random=FALSE # omit "Weight" columns on right