mtc.data.studyrow: Convert one-study-per-row datasets

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/mtc.data.studyrow.R

Description

Converts datasets in the one-study-per-row format to one-arm-per-row format used by GeMTC

Usage

1
2
3
4
5
6
7
mtc.data.studyrow(data,
  armVars=c('treatment'='t', 'responders'='r', 'sampleSize'='n'),
  nArmsVar='na',
  studyVars=c(),
  studyNames=1:nrow(data),
  treatmentNames=NA,
  patterns=c('%s..', '%s..%d.'))

Arguments

data

Data in one-study-per-row format.

armVars

Vector of per-arm variables. The name of each component will be the column name in the resulting dataset. The column name in the source dataset is derived from the value of each component.

nArmsVar

Variable holding the number of arms for each study.

studyVars

Vector of per-study variables. The name of each component will be the column name in the resulting dataset. The column name in the source dataset is derived from the value of each component.

studyNames

Vector of study names.

treatmentNames

Vector of treatment names.

patterns

Patterns to generate column names in the source dataset. The first is for per-study variables, the second for per-arm variables.

Details

Maps the one-study-per-row format that is widely used and convenient for BUGS models to the one-arm-per-row format used by GeMTC. As the primary purpose is to input datasets from BUGS models, the defaults work for the standard BUGS data table format. In most cases, it should be possible to just copy/paste the BUGS data table (without the final 'END') and read.table it into R, then apply mtc.data.studyrow. In many cases, the resulting table can be processed directly by mtc.network.

Value

A data table with the requested columns.

Author(s)

Gert van Valkenhoef

See Also

mtc.network

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Example taken from the NICE DSU TSD series in Evidence Synthesis, #2
## Dopamine agonists for the treatment of Parkinson's

# Read the bugs-formatted data
data.src <- read.table(textConnection('
t[,1]	t[,2]	t[,3]	y[,1]	y[,2]	y[,3]	se[,1]	se[,2]	se[,3]	na[]
1	3	NA	-1.22	-1.53	NA	0.504	0.439	NA	2
1	2	NA	-0.7	-2.4	NA	0.282	0.258	NA	2
1	2	4	-0.3	-2.6	-1.2	0.505	0.510	0.478	3
3	4	NA	-0.24	-0.59	NA	0.265	0.354	NA	2
3	4	NA	-0.73	-0.18	NA	0.335	0.442	NA	2
4	5	NA	-2.2	-2.5	NA	0.197	0.190	NA	2
4	5	NA	-1.8	-2.1	NA	0.200	0.250	NA	2'), header=TRUE)

# Convert the data, setting treatment names
data <- mtc.data.studyrow(data.src,
  armVars=c('treatment'='t', 'mean'='y', 'std.err'='se'),
  treatmentNames=c('Placebo', 'DA1', 'DA2', 'DA3', 'DA4'))

# Check that the data are correct
print(data)

# Create a network
network <- mtc.network(data)

Example output

Loading required package: coda
   study treatment  mean std.err
1      1   Placebo -1.22   0.504
2      1       DA2 -1.53   0.439
3      2   Placebo -0.70   0.282
4      2       DA1 -2.40   0.258
5      3   Placebo -0.30   0.505
6      3       DA1 -2.60   0.510
7      3       DA3 -1.20   0.478
8      4       DA2 -0.24   0.265
9      4       DA3 -0.59   0.354
10     5       DA2 -0.73   0.335
11     5       DA3 -0.18   0.442
12     6       DA3 -2.20   0.197
13     6       DA4 -2.50   0.190
14     7       DA3 -1.80   0.200
15     7       DA4 -2.10   0.250

gemtc documentation built on May 15, 2021, 1:07 a.m.