Learn R Programming

gemtc (version 0.3)

mtc.network: Create an mtc.network

Description

Creates an object of class mtc.network

Usage

mtc.network(data, treatments, description, data.re)
read.mtc.network(file)
write.mtc.network(network, file)

Arguments

data
Arm-level data. A data frame defining the arms of each study, containing the columns `study' and `treatment', where `treatment' must refer to an existing treatment ID if treatments were specified. To specify a network with dichotomous data, the number of
data.re
Relative effect data. A data frame defining the arms of each study, containing the columns `study' and `treatment', where `treatment' must refer to an existing treatment ID if treatments were specified. The column `diff' specifies the mean difference betw
treatments
Optional. A data frame with columns `id' and `description' defining the treatments or a vector giving the treatment IDs.
description
Optional. Short description of the network.
network
An object of the S3 class mtc.network.
file
Path to the file to read (read.mtc.network) or write (write.mtc.network). For write.mtc.network, if file="", the output is printed to standard output. If it is file="|cmd", the output is pi

Value

  • For mtc.network and read.mtc.network, an object of the class mtc.network which is a list containing:
  • descriptionA short description of the network
  • treatmentsA data frame describing the treatments
  • dataA data frame containing the network data (arm-level)
  • data.reA data frame containing the network data (relative effects)
  • These are cleaned up and standardized versions of the arguments provided, or generated defaults for `treatments' if the argument was omitted.

encoding

utf8

Details

One-arm trials are automatically removed, which results in a warning.

See Also

read.mtc.network

Examples

Run this code
# Create a new network by specifying all information.
treatments <- read.table(textConnection('
  id  description
  A   "Treatment A"
  B   "Treatment B"
  C   "Treatment C"'), header=TRUE)
data <- read.table(textConnection('
  study  treatment  responders  sampleSize
  01     A          2           100
  01     B          5           100
  02     B          6           110
  02     C          1           110
  03     A          3           60
  03     C          4           80
  03     B          7           80'), header=TRUE)
network <- mtc.network(data, description="Example", treatments=treatments)
plot(network)

# Create a new network by specifying only the data.
data <- read.table(textConnection('
  study  treatment  mean   std.dev  sampleSize
  01     A          -1.12  0.6      15
  01     B          -1.55  0.5      16
  02     A          -0.8   0.7      33
  02     B          -1.1   0.5      31'), header=TRUE)
network <- mtc.network(data)

# Print the network
print(network)
## MTC dataset: Network
##   study treatment  mean std.dev sampleSize
## 1     1         A -1.12     0.6         15
## 2     1         B -1.55     0.5         16
## 3     2         A -0.80     0.7         33
## 4     2         B -1.10     0.5         31

# Read an example GeMTC XML file
file <- system.file("extdata/luades-smoking.gemtc", package="gemtc")
network <- read.mtc.network(file)

# Summarize the network (generate some interesting network properties)
summary(network)
## $Description
## [1] "MTC dataset: Smoking cessation rates"
## 
## $`Studies per treatment`
##  A  B  C  D 
## 19  6 19  6 
## 
## $`Number of n-arm studies`
## 2-arm 3-arm 
##    22     2 

# Write the network to a temporary file in the GeMTC XML format
tmp <- tempfile()
write.mtc.network(network, file=tmp)

Run the code above in your browser using DataLab