The correct code for R NMA (Network Meta-Analysis) depends on the specific package you're using in R. Here are the most common packages and their basic syntax:
1. netmeta Package (Most Popular)
# Install and load the package
install.packages("netmeta")
library(netmeta)
# Example code for a network meta-analysis
# (Assuming 'data' is a data frame with columns: TE (effect size), seTE (standard error), treat1, treat2, studlab)
nma_result <- netmeta(TE = TE,
seTE = seTE,
treat1 = treat1,
treat2 = treat2,
studlab = studlab,
data = data,
sm = "OR", # or "RR", "MD", etc.
comb.fixed = FALSE, # Use random-effects model
comb.random = TRUE)
# Summarize results
summary(nma_result)
# Forest plot
forest(nma_result)
# League table (treatment rankings)
netleague(nma_result)
2. gemtc Package (Bayesian NMA)
# Install and load the package
install.packages("gemtc")
library(gemtc)
# Example code (requires data in specific format)
network <- mtc.network(data.re = data) # 'data' should be in long format
model <- mtc.model(network, linearModel = "random")
results <- mtc.run(model)
# Summarize results
summary(results)
# Forest plot
forest(results)
3. pcnetmeta (for Pairwise and Network Meta-Analysis)
install.packages("pcnetmeta")
library(pcnetmeta)
# Example code
nma_result <- nma(data,
outcome = "TE",
se = "seTE",
treat1 = "treat1",
treat2 = "treat2",
study = "studlab",
method = "RE") # Random-effects model
# Summary and plots
summary(nma_result)
plot(nma_result)
Key Notes:
- Data Format: Ensure your data is structured correctly (usually in long format with columns for treatments, effect sizes, and study labels).
- Effect Measures: Choose the appropriate effect measure (
sm = "OR", "RR", "MD", etc.).
- Random vs. Fixed Effects: Most NMAs use a random-effects model (
comb.random = TRUE in netmeta).
Would you like help with a specific dataset or model setup? Let me know!