netmeta (version 0.9-5)

pairwise: Transform meta-analysis data from arm-based format into contrast-based format

Description

This function transforms data that are given in an arm-based format (e.g. input format for WinBUGS) to a contrast-based format that is needed as input to R function netmeta. The function can transform data with binary, continuous, or generic outcomes as well as incidence rates from arm-based to contrast-based format.

Usage

pairwise(treat, event, n, mean, sd, TE, seTE, time,
         data=NULL, studlab,
	 incr=0.5, allincr=FALSE, addincr=FALSE, allstudies=FALSE,
	 ...)

Arguments

treat

A list or vector with treatment information for individual treatment arms (see Details).

event

A list or vector with information on number of events for individual treatment arms (see Details).

n

A list or vector with information on number of observations for individual treatment arms (see Details).

mean

A list or vector with estimated means for individual treatment arms (see Details).

sd

A list or vector with information on the standard deviation for individual treatment arms (see Details).

TE

A list or vector with estimated treatment effects for individual treatment arms (see Details).

seTE

A list or vector with standard errors of estimated treatment effect for individual treatment arms (see Details).

time

A list or vector with information on person time at risk for individual treatment arms (see Details).

data

An optional data frame containing the study information.

studlab

A vector with study labels (optional).

incr

A numerical value which is added to each cell frequency for studies with a zero cell count.

allincr

A logical indicating if incr is added to each cell frequency of all studies if at least one study has a zero cell count. If FALSE (default), incr is added only to each cell frequency of studies with a zero cell count.

addincr

A logical indicating if incr is added to each cell frequency of all studies irrespective of zero cell counts.

allstudies

A logical indicating if studies with zero or all events in two treatment arms are to be included in the meta-analysis (applies only if sm is equal to "RR" or "OR").

Additional arguments passed-through to the functions to calculate effects.

Value

A data frame with the following columns

TE

Treatment estimate comparing treatment 'treat1' and 'treat2'.

seTE

Standard error of treatment estimate.

studlab

Study labels.

treat1

First treatment in comparison.

treat2

Second treatment in comparison.

event1

Number of events for first treatment arm (for metabin and metainc).

event2

Number of events for second treatment arm (for metabin and metainc).

n1

Number of observations for first treatment arm (for metabin and metacont).

n2

Number of observations for second treatment arm (for metabin and metacont).

mean1

Estimated mean for first treatment arm (for metacont).

mean2

Estimated mean for second treatment arm (for metacont).

sd1

Standard deviation for first treatment arm (for metacont).

sd2

Standard deviation for second treatment arm (for metacont).

TE1

Estimated treatment effect for first treatment arm (for metagen).

TE2

Estimated treatment effect for second treatment arm (for metagen).

seTE1

Standard error of estimated treatment effect for first treatment arm (for metagen).

seTE2

Standard error of estimated treatment effect for second treatment arm (for metagen).

time1

Person time at risk for first treatment arm (for metainc).

time2

Person time at risk for second treatment arm (for metainc).

Details

R function netmeta expects data in a contrast-based format, where each row corresponds to a comparison of two treatments and contains a measure of the treatment effect comparing two treatments with standard error, labels for the two treatments and an optional study label. In contrast-based format, a three-arm study contributes three rows with treatment comparison and corresponding standard error for pairwise comparison A vs B, A vs C, and B vs C whereas a four-arm study contributes six rows / pairwise comparisons: A vs B, A vs C, …, C vs D.

Other programs for network meta-analysis in WinBUGS and Stata require data in an arm-based format, i.e. treatment estimate for each treatment arm instead of a difference of two treatments. This format consists of one data row per study, containing treatment and other necessary information for all study arms. For example, a four-arm study contributes one row with four treatment estimates and corresponding standard errors for treatments A, B, C, and D. Another possible arm-based format is a long format where each row corresponds to a single study arm. Accordingly, in the long format a study contributes as many rows as treatments considered in the study.

The pairwise function transforms data given in arm-based format into the contrast-based format which consists of pairwise comparisons and is needed as input to the netmeta function.

The pairwise function can transform data with binary outcomes (using the metabin function from R package meta), continuous outcomes (metacont function), incidence rates (metainc function), and generic outcomes (metagen function). Depending on the outcome, the following arguments are mandatory:

Argument treat is mandatory to identify the individual treatments. The other arguments contain outcome specific data. These arguments must be either lists (one-row-per-study) or vectors (long format, i.e. multiple-rows-per-study) of the same length.

For the one-row-per-study format, each list consists of as many vectors of the same length as the multi-arm study with the largest number of treatments. If a single multi-arm study has five arms, five vectors have to be provided for each lists. Two-arm studies have entries with NA for the third and subsequent vectors. Each list entry is a vector with information for each individual study; i.e. the length of this vector corresponds to the total number of studies incorporated in the network meta-analysis. Typically, list elements are part of a data frame (argument data, optional); see Examples. An optional vector with study labels can be provided which can be part of the data frame.

In the long format, argument studlab is mandatory to identify rows contributing to individual studies.

Additional arguments for these functions can be provided using argument '\dots'. The following is a list of some important arguments:

Argument Description R function
sm Summary measure metabin, metacont, metainc, metagen
method Meta-analysis method metabin, metainc
method.tau Estimation of between-study variance metabin, metacont, metainc, metagen

More information on these as well as other arguments is given in the help pages of R functions metabin, metacont, metainc, and metagen, respectively.

The value of pairwise is a data frame with as many rows as there are pairwise comparisons. For each study with p treatments, p*(p-1)/2 contrasts are generated. Each row contains the treatment effect (TE), its standard error (seTE), the treatments compared ((treat1), (treat2)) and the study label ((studlab)). Further columns are added according to type of data.

See Also

netmeta, metacont, metagen, metabin, metainc, netgraph

Examples

Run this code
# NOT RUN {
#
# Example using continuous outcomes (internal call of function metacont)
#
data(parkinson)
# Transform data from arm-based format to contrast-based format
p1 <- pairwise(list(Treatment1, Treatment2, Treatment3),
               n=list(n1, n2, n3),
               mean=list(y1, y2, y3),
               sd=list(sd1, sd2, sd3),
               data=parkinson, studlab=Study)
p1

# Conduct network meta-analysis
net1 <- netmeta(p1)
net1

# Draw network graphs
netgraph(net1, points=TRUE, cex.points=3, cex=1.5,
         thickness="se.fixed")
netgraph(net1, points=TRUE, cex.points=3, cex = 1.5,
         plastic=TRUE, thickness="se.fixed",
         iterate=TRUE)
netgraph(net1, points=TRUE, cex.points=3, cex = 1.5,
         plastic=TRUE, thickness="se.fixed",
         iterate=TRUE, start="eigen")


#
# Example using generic outcomes (internal call of function metagen)
#
# Calculate standard error for means y1, y2, y3
parkinson$se1 <- with(parkinson, sqrt(sd1^2/n1))
parkinson$se2 <- with(parkinson, sqrt(sd2^2/n2))
parkinson$se3 <- with(parkinson, sqrt(sd3^2/n3))
# Transform data from arm-based format to contrast-based format using
# means and standard errors (note, argument 'sm' has to be used to
# specify that argument 'TE' is a mean difference)
p2 <- pairwise(list(Treatment1, Treatment2, Treatment3),
               TE=list(y1, y2, y3),
               seTE=list(se1, se2, se3),
               data=parkinson, studlab=Study,
               sm="MD")
p2

# Compare pairwise objects p1 (based on continuous outcomes) and p2
# (based on generic outcomes)
all.equal(p1[, c("TE", "seTE", "studlab", "treat1", "treat2")],
          p2[, c("TE", "seTE", "studlab", "treat1", "treat2")])

# Same result as network meta-analysis based on continuous outcomes
# (object net1)
# }
# NOT RUN {
net2 <- netmeta(p2)
net2
# }
# NOT RUN {

#
# Example with binary data
#
data(smokingcessation)
# Transform data from arm-based format to contrast-based format
# (interal call of metabin function). Argument 'sm' has to be used for
# odds ratio as risk ratio (sm="RR") is default of metabin function.
p3 <- pairwise(list(treat1, treat2, treat3),
               list(event1, event2, event3),
               list(n1, n2, n3),
               data=smokingcessation,
               sm="OR")
p3

# Conduct network meta-analysis
net3 <- netmeta(p3)
net3

#
# Example with incidence rates
#
data(dietaryfat)

# Transform data from arm-based format to contrast-based format
p4 <- pairwise(list(treat1, treat2, treat3),
               list(d1, d2, d3),
               time=list(years1, years2, years3),
               studlab=ID,
               data=dietaryfat)
p4

# Conduct network meta-analysis using incidence rate ratios (sm="IRR").
# Note, the argument 'sm' is not necessary as this is the default in R
# function metainc called internally
net4 <- netmeta(p4, sm="IRR")
summary(net4)

#
# Example with long data format
#
data(Woods2010)

# Transform data from long arm-based format to contrast-based format
# Argument 'sm' has to be used for odds ratio as summary measure; by
# default the risk ratio is used in the metabin function called
# internally.
p5 <- pairwise(treatment, event=r, n=N,
               studlab=author, data=Woods2010, sm="OR")
p5

# Conduct network meta-analysis
net5 <- netmeta(p5)
net5
# }

Run the code above in your browser using DataCamp Workspace