knitr::opts_chunk$set(echo = TRUE)
We illustrate the reporoduction of the derivation of effects of all treatments versus a treatment of average performance using as an example a network of 18 antidepressants.
A brief description of the functions is given below.
nma.krahn.output: This function is a slightly modified version of nma.krahn function, which performs network meta-analysis as a two-stage meta-regression model and is embedded in netmeta package. The modification consists of inclusion of more results in the output, specifically the objects multiarm (a logical indicating whether multi arm studies exist), basics (comparisons that are used as basic parameters), direct2 (data frame with results from direct meta-analyses) and TE.dir (direct treatment effects).
alternativenma: This function takes as input an object of class netmeta and estimates the relative effects of all treatments versus a treatment of average performance and the probabilities of all treatments being better than the average treatment.
plot.alternativenma: This function takes as input an object of class alternativenma and plots a forest plot of relative effects of all treatments versus a treatment of average performance.
The packages below need to be installed, uncomment the ones you don't have.
#install.packages("plyr") #install.packages("devtools") #install.packages("ggplot2") #install.packages("grid") #install.packages("readr") #install_version("netmeta",version="0.9-5") #install.packages("ggrepel") library(devtools) library(readr) library(netmeta)
Then, we need to install the functions to perform network meta-analysis using the alternative parametrisation either by using source()
source('./R/nma.krahn.output.R') source('./R/alternativenma.R') source('./R/plot.alternativenma.R') source('./R/classifier.R') source('./R/netmetaranks_B.R') source('./R/netmetaranks_H.R')
or from GitHub
#install_github("esm-ispm-unibe-ch/alternativenma") #library(alternativenma)
The outcome data for the depression example are in the library and can be downloaded as
#depression <- read_delim("../data/depression.csv", ";", escape_double = FALSE, trim_ws = TRUE) data(depression)
and viewed
head(depression)
We first tranform the data in a pairwise format and run network meta-analysis using netmeta
p1=pairwise(treat=drug_name,event=Responders,n=Ntotal,data=depression,studlab = studyID, sm="OR") netp1=netmeta(p1)
The command alternativenma takes the following arguments: netmetaobject: An object of class netmeta random: A logical indicating whether a random effects meta-analysis should be conducted. small.values: A character string specifying whether small treatment effects indicate a "good" or "bad" effect
Then, the function estimates effects of all treatments versus a treatment of average performance and returns an object of class alternativenma.
altnetp1=alternativenma(netmetaobject=netp1,random=T, small.values = "bad")
An object of class alternativenma is produced that can be used as argument in plot.
The output of alternativenma is a list containing the following components: n: number of treatments trts: names of treatments included comparisons: comparisons with direct data studies: data per study X.alt: design matrix (Y matrix in the paper) X.obs.alt: design matrix (X^C matrix in the paper) averages: data frame with effects of each treatment versus average in an additive scale (TE), their standard errors (seTE) and their 95% confidence interval (lower and upper) and the probability of being better than the average (Pscoreaverage) TE.net.avs: network meta-analysis effects, same as those produced by netmeta
The command plot.alternativenma takes the following arguments:
altnmaobject: An object of class alternativenma eform: A logical indicating whether the exponential of effects should be drawn ordered: A logical indicating whether the effects should be drawn ordered xmin: minimum limit of x axis xmax: maximum limit of x axis treatmentplacement: The x value of treatment labels effectplacement: The x value of the effect sizes
Then, the function produces the forest plot with effects of all treatments versus a treatment of average performance.
plot.alternativenma(altnetp1, eform=T, xmin=0, xmax=2.5, treatmentplacement=0.1, effectplacement=2.2)
The command classifier takes the following arguments:
altnmaobject: An object of class alternativenma toplot: A character indicating whether "Zscores" or "Pscoreaverage" are to be drawn.
Then, the function produces the forest plot with effects of all treatments versus a treatment of average performance.
classifier(altnmaobject=altnetp1,toplot="Pscoreaverage")
We reanalyse the network by Middleton comparing four interventions for heavy menstrual bleeding.
data(Midlleton) p2=pairwise(treat=t,event=r,n=n,data=Midlleton,studlab = id, sm="OR") netp2=netmeta(p2) altnetp2=alternativenma(netmetaobject=netp2,random=T, small.values = "good") plot.alternativenma(altnetp2, eform=T, xmin=0, xmax=5, treatmentplacement=0.1, effectplacement=3.8) classifier(altnmaobject=altnetp2,toplot="Pscoreaverage")
We compute existing ranking metrics for depression and Middleton examples.
gris_ranks=round(netmetaranks_B(netp1,10000),2) middl_ranks=round(netmetaranks_H(netp2,10000),2) gris_ranks middl_ranks
We compute absolute effects for the depression example.
depression=depression[!is.na(depression$studyID),] mp=metaprop(event=Responders,n=Ntotal,data=depression) p3=pairwise(treat=drug_name,event=Responders,n=Ntotal,data=depression,studlab = studyID, sm="RR") netp3=netmeta(p3) altnetp3=alternativenma(netmetaobject=netp3,random=T, small.values = "bad") df=data.frame(treat=altnetp3$averages$treat, absolutes=round(mp$TE.random*(1/exp(altnetp3$averages$TE)),2)) df[order(df$absolutes),]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.