SUCRA and P-Scores in R: A Worked Example
A complete netmeta workflow, from arm-level data to P-scores, SUCRA and a league table, with an optional Bayesian version in gemtc.
To get SUCRA in R, fit a network meta-analysis and then rank the treatments: in netmeta, netrank() returns P-scores, and netrank(..., method = "SUCRA") or rankogram() returns SUCRA by resampling; in gemtc, rank.probability() followed by sucra() returns Bayesian SUCRA. P-scores are the frequentist analogue of SUCRA and usually give very similar values. In every package, the setting that tells R whether low or high values are better decides whether your ranking is right or upside down.
This tutorial runs the whole workflow on a dataset that ships with netmeta, so you can copy the code and run it. We describe what each output contains rather than quoting numbers: run the code to see them.
Setup and data
The code below assumes netmeta 3.x and meta 8.x from CRAN (it was checked against the documentation for netmeta 3.7-0). Two changes in recent versions matter. Since netmeta 3.0-2, pairwise() lives in the meta package; loading netmeta attaches meta, so the call is unchanged. Since netmeta 2.8-0, small.values takes "desirable" or "undesirable" instead of the older "good" and "bad". If you are following an older tutorial, those are the two places it will break.
# install.packages(c("meta", "netmeta"))
library(netmeta) # attaches meta, which provides pairwise()
packageVersion("netmeta")
data(smokingcessation)
head(smokingcessation)
sort(unique(c(smokingcessation$treat1, smokingcessation$treat2))) # treatment codesThe smokingcessation dataset contains arm-level data from trials of interventions to help people stop smoking, taken from the NICE Decision Support Unit's work on inconsistency. Each row is a trial, with up to three arms: treat1 to treat3 hold the treatment codes, event1 to event3 the number of people who quit, and n1 to n3 the number randomised. The four treatments are coded A to D: no intervention, self-help, individual counselling and group counselling.
The outcome is quitting, which is desirable. Hold on to that, because it decides the direction of every ranking below.
From arm-level data to a network meta-analysis
netmeta works with contrasts, so the first step converts arms into pairwise comparisons. pairwise() does this, including the correct handling of multi-arm trials.
p1 <- pairwise(treat = list(treat1, treat2, treat3),
event = list(event1, event2, event3),
n = list(n1, n2, n3),
data = smokingcessation, sm = "OR")
net1 <- netmeta(p1,
common = FALSE, # report the random-effects model only
reference.group = "A", # no intervention as comparator
small.values = "undesirable")
net1The printout lists the number of studies, pairwise comparisons, treatments and designs, then the odds ratio of each treatment against the reference with its 95% confidence interval. Below that are the heterogeneity estimates (tau-squared, tau and I-squared) and tests of heterogeneity and inconsistency, split into within-design and between-design components. The between-design test is a global check of consistency; our note on inconsistency in network meta-analysis explains how to follow it up.
Next, a forest plot of each treatment against no intervention:
forest(net1, reference.group = "A",
smlab = "Odds ratio for quitting\nvs no intervention")P-scores with netrank()
netrank(net1)This prints one P-score per treatment for the random-effects model, sorted from highest to lowest by default. A P-score is the mean, over all competitors, of the probability that the treatment is better than each one, calculated from the network estimates and their standard errors without any simulation (Rücker & Schwarzer, 2015). It runs from 0 to 1, and the P-scores in any network average 0.5. Because no resampling is involved, the values are identical every time you run the code.
netrank() takes small.values from the fitted object, so the setting given to netmeta() carries through. You can override it in the call, which is useful for seeing what happens when it is wrong.
Why small.values matters
small.values tells netmeta whether small treatment effects are desirable or undesirable. "Small" means small on the scale of the summary measure, comparing each treatment with its competitors: for odds ratios, effects below 1; for mean differences, negative values.
For the smoking data, an odds ratio above 1 means more people quit, which is good, so small values are undesirable. Had we left the default ("desirable"), netmeta would have ranked the least effective intervention first. Try it:
netrank(net1, small.values = "desirable")For P-scores, reversing the direction turns every value into 1 minus its original value, so the hierarchy flips exactly. Nothing in the output warns you, and the numbers look perfectly plausible either way.
The right setting depends on both the outcome and how it is coded. Quitting smoking, response and remission are desirable events: small values are undesirable. Mortality, relapse and adverse events are undesirable events: small values are desirable. For continuous outcomes, check the sign. In the Senn2013 dataset, also in netmeta, the outcome is HbA1c, where lower is better, so small mean differences are desirable:
data(Senn2013)
net2 <- netmeta(TE, seTE, treat1.long, treat2.long, studlab,
data = Senn2013, sm = "MD", common = FALSE,
small.values = "desirable")
netrank(net2)A pain score where higher means worse behaves like HbA1c; a function score where higher means better behaves like quitting. State the setting and the reasoning in your methods.
SUCRA by resampling, and a league table
If a journal or reviewer asks for SUCRA from a frequentist analysis, netmeta can estimate it by resampling from a multivariate normal distribution centred on the network estimates. Set a seed so the result can be reproduced.
set.seed(2026)
ran1 <- rankogram(net1, nsim = 10000)
ran1 # rank probabilities for each treatment
plot(ran1) # rankograms
netrank(ran1) # SUCRA from the resampled rank probabilities
# or in one step
set.seed(2026)
netrank(net1, method = "SUCRA", nsim = 10000)The rankogram printout is a matrix with one row per treatment and one column per rank, giving the probability of each treatment taking each rank. netrank() applied to that object returns SUCRA. With enough resamples, the SUCRA values should be close to the P-scores; small differences come from simulation error and shrink as nsim increases. Our note on what SUCRA can and cannot tell you explains why neither value should be reported without the effect estimates behind it.
A league table puts those effect estimates in one place:
netleague(net1, seq = netrank(net1), digits = 2,
bracket = "(", separator = " to ")Passing the netrank() result to seq orders rows and columns by P-score. With a single fitted object, the lower triangle holds the network estimates and the upper triangle the direct estimates from pairwise comparisons. Read the help page for the direction of comparison in each triangle before writing captions: in the lower triangle the column treatment is compared with the row treatment, which is the opposite of what many readers assume. Adding path = "league.xlsx" writes the table to Excel.
These functions and their arguments are described in the netmeta paper by Balduzzi et al. (2023).
The Bayesian version with gemtc
gemtc fits Bayesian network meta-analyses through JAGS, which must be installed separately from R. The code below assumes gemtc 1.0-2. gemtc expects arm-level data in long format, with one row per arm, so we reshape the same smoking data.
library(gemtc) # requires JAGS (https://mcmc-jags.sourceforge.io/)
sc <- smokingcessation
long <- do.call(rbind, lapply(1:3, function(k) data.frame(
study = paste0("study", seq_len(nrow(sc))),
treatment = as.character(sc[[paste0("treat", k)]]),
responders = sc[[paste0("event", k)]],
sampleSize = sc[[paste0("n", k)]])))
long <- long[!is.na(long$responders), ] # drop empty third arms
network <- mtc.network(data.ab = long)
model <- mtc.model(network, likelihood = "binom", link = "logit",
linearModel = "random", n.chain = 4)
results <- mtc.run(model, n.adapt = 5000, n.iter = 20000)
summary(results)
ranks <- rank.probability(results, preferredDirection = 1)
ranks # posterior rank probabilities
plot(ranks, beside = TRUE) # rankogram
sucra(ranks) # Bayesian SUCRAMCMC results vary slightly from run to run, so save the fitted object with saveRDS() if you need to reproduce the exact numbers later. preferredDirection = 1 says higher values are preferred, which is right here because the model estimates log odds of quitting. For an outcome where lower is better, use −1. Check convergence before reading any ranking: plot(results) shows trace and density plots, and coda::gelman.diag(results$samples) gives the potential scale reduction factors.
The output of rank.probability() has the same structure as netmeta's rankogram: treatments in rows, ranks in columns. sucra() summarises each row using the definition of Salanti et al. (2011). Expect the Bayesian SUCRAs to be similar to the P-scores but not identical. The binomial likelihood and the uncertainty in the heterogeneity parameter both differ from the frequentist model, and in small networks the Bayesian intervals are usually wider, which pulls SUCRA towards 0.5.
What to report
- Package names and versions (
packageVersion()), and JAGS version for gemtc. - The ranking metric: P-score, frequentist SUCRA with
nsimand seed, or Bayesian SUCRA with chains, burn-in, iterations and convergence checks. - The direction setting (
small.valuesorpreferredDirection) and why it fits the outcome. - Rankings next to relative effects with intervals, ideally in a league table or forest plot ordered the same way.
- The full rank probability matrix in a supplement if you report SUCRA.
- Your code, or enough of it that someone else can rerun the analysis.
References
Balduzzi, S., Rücker, G., Nikolakopoulou, A., Papakonstantinou, T., Salanti, G., Efthimiou, O., & Schwarzer, G. (2023). netmeta: An R package for network meta-analysis using frequentist methods. Journal of Statistical Software, 106(2), 1–40. https://doi.org/10.18637/jss.v106.i02
Rücker, G., & Schwarzer, G. (2015). Ranking treatments in frequentist network meta-analysis works without resampling methods. BMC Medical Research Methodology, 15, 58. https://doi.org/10.1186/s12874-015-0060-8
Salanti, G., Ades, A. E., & Ioannidis, J. P. A. (2011). Graphical methods and numerical summaries for presenting results from multiple-treatment meta-analysis: An overview and tutorial. Journal of Clinical Epidemiology, 64(2), 163–171. https://doi.org/10.1016/j.jclinepi.2010.03.016
