Learn R Programming

meta (version 6.5-0)

longarm: Transform data from pairwise comparisons to long arm-based format

Description

This function transforms data from pairwise comparisons to a long arm-based format, i.e., two rows for a pairwise comparison.

Usage

longarm(
  treat1,
  treat2,
  event1,
  n1,
  event2,
  n2,
  mean1,
  sd1,
  mean2,
  sd2,
  time1,
  time2,
  data = NULL,
  studlab,
  id1 = NULL,
  id2 = NULL,
  append = TRUE,
  keep.duplicated = FALSE,
  keep.internal = FALSE
)

Value

A data frame in long arm-based format.

Arguments

treat1

Either label for first treatment or a meta-analysis or pairwise object (see Details).

treat2

Label for second treatment.

event1

Number of events (first treatment).

n1

Number of observations (first treatment).

event2

Number of events (second treatment).

n2

Number of observations (second treatment)

mean1

Estimated mean (first treatment).

sd1

Standard deviation (first treatment).

mean2

Estimated mean (second treatment).

sd2

Standard deviation (second treatment).

time1

Person time at risk (first treatment)

time2

Person time at risk (second treatment)

data

An optional data frame containing the study information.

studlab

A vector with study labels (optional).

id1

Last character(s) of variable names for additional variables with group specific information for first treatment.

id2

Last character(s) of variable names for additional variables with group specific information for second treatment.

append

A logical indicating if data frame provided in argument 'data' should be returned.

keep.duplicated

A logical indicating if duplicated rows should be returned (see Details).

keep.internal

A logical indicating if variables generated internally should be returned (typically only relevant for data checking).

Details

This function transforms data given as one pairwise comparison per row to a long arm-based format with one row per treatment arm. The long arm-based format is, for example, the required input format for WinBUGS.

The function can be used to transform data with a binary, continuous or count outcome. The corresponding meta-analysis functions are metabin, metacont and metainc. Accordingly, a meta-analysis object created with one of these functions can be provided as argument treat1. It is also possible to use the longarm function with an R objected created with pairwise from R package netmeta.

Otherwise, arguments treat1 and treat2 are mandatory to identify the individual treatments and, depending on the outcome, the following additional arguments are mandatory:

  • event1, n1, event2, n2 (binary outcome);

  • n1, mean1, sd1, n2, mean2, sd2 (continuous outcome);

  • time1, n1, time2, n2 (count outcome).

Argument studlab must be provided if several pairwise comparisons come from a single study with more than two treatments.

The following variables will be returned:

studlabstudy label
treattreatment label
ngroup sample size (count outcome only if provided)
eventsnumber of events (binary or count outcome)
noneventsnumber of non-events (binary outcome)
meanestimated mean (continuous outcome)
sdstandard deviation (continuous outcome)
timeperson time at risk (count outcome)

In addition, the data set provided in argument data will be returned if argument append = TRUE (default).

Argument keep.duplicated can be used to keep duplicated rows from the data set. Duplicated rows can occur, for example, in a three-arm study comparing treatments A and B with placebo. In this situation, the placebo arm will be returned twice in the data set in long arm-based format if keep.duplicated = TRUE. By default, duplicated rows with not be kept in the data set.

See Also

metabin, metacont, metainc, pairwise

Examples

Run this code
# Artificial example with three studies
m <- metabin(1:3, 100:102, 4:6, 200:202, studlab = LETTERS[1:3])
# Transform data to long arm-based format
longarm(m)
# Keep internal variables
longarm(m, keep.internal = TRUE)

Run the code above in your browser using DataLab