network.data: Make a network object containing data, priors, and a JAGS...

Description Usage Arguments Value References Examples

View source: R/network.data.R

Description

This function makes a network object that can be used to run network meta-analysis using network.run. User needs to specify Outcomes, Study, Treat, N or SE, and response. Prior parameters are filled in automatically based on the data type if not specified. The input data should be arm-level so that we have observations for each treatment in each study. The input data is preprocessed to fit the format necessary to run model in JAGS.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
network.data(
  Outcomes = NULL,
  Study = NULL,
  Treat = NULL,
  N = NULL,
  SE = NULL,
  response = NULL,
  Treat.order = NULL,
  type = "random",
  rank.preference = "higher",
  baseline = "none",
  baseline.risk = "independent",
  covariate = NULL,
  covariate.type = NULL,
  covariate.model = NULL,
  mean.d = NULL,
  prec.d = NULL,
  mean.Eta = NULL,
  prec.Eta = NULL,
  hy.prior.Eta = NULL,
  mean.bl = NULL,
  prec.bl = NULL,
  hy.prior.bl = NULL,
  mean.cov = NULL,
  prec.cov = NULL,
  hy.prior.cov = NULL,
  hy.prior = NULL,
  mean.A = NULL,
  prec.A = NULL,
  Z = NULL,
  Z_bl = NULL
)

Arguments

Outcomes

Arm-level outcomes. If it is a multinomial response, the matrix would have dimensions treatment arms (row) by multinomial categories (column). If it is binomial or normal, it would be a vector.

Study

A vector of study indicator for each arm

Treat

A vector of treatment indicator for each arm

N

A vector of total number of observations in each arm. Used for binomial and multinomial responses.

SE

A vector of standard error for each arm. Used only for normal response.

response

Specification of the outcomes type. Must specify one of the following: "normal", "binomial", or "multinomial".

Treat.order

Treatment order which determines how treatments are compared. The first treatment that is specified is considered to be the baseline treatment. Default order is alphabetical. If the treatments are coded 1, 2, etc, then the treatment with a value of 1 would be assigned as a baseline treatment.

type

Type of model fitted: either "random" for random effects model or "fixed" for fixed effects model. Default is "random".

rank.preference

Set it equal to "higher" if higher values are preferred (i.e. assumes events are good). Set it equal to "lower" if lower values are preferred (i.e. assumes events are bad). Default is "higher".

baseline

Three different assumptions for treatment x baseline risk interactions (slopes): "independent", "common", or "exchangeable". Default is "none" which doesn't incorporate baseline risk.

baseline.risk

Two different assumptions for baseline risk: "independent" or "exchangeable". See Achana et al. (2012) for more information about baseline risk.

covariate

A covariate matrix with each row representing each trial and column representing each covariate. This is a study-level data, meaning that the user doesn't need to repeatedly specify covariates for each arm.

covariate.type

Should be a vector indicating the type of the covariate. Covariate can be either "continuous" or "discrete". If it continuous, covariates are centered. If the covariate is discrete it is not centered and it has to be in a dummy integer format (i.e. 0,1,2,...). The code doesn't factor the covariates for the user, so user needs to specify dummy variables if factor is needed.

covariate.model

"independent" allows covariate effects for each treatment. "common" restricts same covariate effect for all treatment. Lastly, "exchangeable" assumes that the covariate effects are different but related and strength is borrowed across them. We set "common" to be default. See Cooper et al. (2009) for more details on covariates.

mean.d

Prior mean for the relative effect

prec.d

Prior precision for the relative effect

mean.Eta

Prior mean for the study effect (baseline risk)

prec.Eta

Prior precision for the study effect (baseline risk)

hy.prior.Eta

Between treatment heterogeneity in baseline risk (for exchangeable assumption only). Format of the parameter is same as hy.prior.

mean.bl

Prior mean for the baseline slope

prec.bl

Prior precision for the baseline slope

hy.prior.bl

Between treatment heterogeneity in baseline slope (for exchangeable regression coefficient only). Format of the parameter is same as hy.prior.

mean.cov

Prior mean for the covariate effect

prec.cov

Prior precision for the covariate effect

hy.prior.cov

Between treatment heterogeneity in covariate effect (for exchangeable regression coefficient only). Format of the parameter is same as hy.prior. Default is set to be dunif(0, 5) for binary, dunif(0, 100) for normal, and wishart with identity scale matrix and (# of categories - 1) degrees of freedom for multinomial.

hy.prior

Prior for the heterogeneity parameter. Supports uniform, gamma, and half normal for normal and binomial response and wishart for multinomial response. It should be a list of length 3, where first element should be the distribution (one of dunif, dgamma, dhnorm, dwish) and the next two are the parameters associated with the distribution. For example, list("dunif", 0, 5) give uniform prior with lower bound 0 and upper bound 5 for the heterogeneity parameter. For wishart distribution, the last two parameter would be the scale matrix and the degrees of freedom.

mean.A

Mean effect of 'standard' treatment (i.e. placebo). It is in logit scale for binomial and continuous scale for normal. For binomial outcome, this additional input is used to calculate the risk difference, relative risk, or number needed to treat. This should be informed from external evidence or can be found by meta-analyzing single proportions. For number needed to treat, we assume that events are "good". Reversal of sign is needed if the events are "bad".

prec.A

Precision of 'standard' treatment. Similarly, it is in logit scale for binomial and continuous scale for normal.

Z

When calculating treatment effect on the natural scale, this is a scalar or a vector of covariates value(s) that you want to calculate treatment effect at.

Z_bl

When calculating treatment effect on the natural scale, this is a scalar of baseline risk (Eta) that you want to calculate treatment effect at.

Value

Creates list of variables that are used to run the model using network.run

data

Data combining all the input data. User can check this to insure the data is correctly specified. For modelling purposes, character valued studies or treatment variables are changed to numeric values based on alphabetical order.

nrow

Total number of arms in the meta-analysis

ncat

Number of columns in the Outcomes. Will equal 1 for binary and normal and number of categories for multinomial

nstudy

Number of study

na

Number of arms for each study

ntreat

Number of treatment

b.id

Indicator in sequence of all treatments for which treatment is base treatment in Study

t

Treat transformed into a matrix which has dimensions number of study by max number of arms in studies

r

Outcomes made into an array that is suitable for use in rjags code. For multinomial, it has 3 dimensions: number of study by max number of arms in studies by number of categories.

mx

If the continuous covariate is included, it calculates the mean of the covariates which is used to center the covariates. The numeric indicator after mx refers to column number of the covariates if there are more than one covariates included. Discrete covariates are not centered.

mx_bl

If the baseline effect is specified, it also calculates the mean baseline risk.

prior.data

Prior data created using the user inputs or default values. If no user input is specifies for the prior, it uses default values.

code

Rjags model file code that is generated using information provided by the user. To view model file inside R in a nice format, use cat(network$code).

References

S. Dias, A.J. Sutton, A.E. Ades, and N.J. Welton (2013a), A Generalized Linear Modeling Framework for Pairwise and Network Meta-analysis of Randomized Controlled Trials, Medical Decision Making 33(5):607-617. doi: 10.1177/0272989X12458724

F.A. Achana, N.J. Cooper, S. Dias, G. Lu, S.J.C. Rice, D. Kendrick, A.J. Sutton (2012), Extending methods for investigating the relationship between treatment effect and baseline risk from pairwise meta-analysis to network meta-analysis, Statistics in Medicine 32(5):752-771. doi: 10.1002/sim.5539

N.J. Cooper, A.J. Sutton, D. Morris, A.E. Ades, N.J. Welton (2009), Addressing between-study heterogeneity and inconsistency in mixed treatment comparisons: Application to stroke prevention treatments in individuals with non-rheumatic atrial fibrillation, Statistics in Medicine 28:1861-1881. doi: 10.1002/sim.3594

Examples

1
2
3
4
5
6
###Blocker data example
blocker
network <- with(blocker, {
 network.data(Outcomes, Study, Treat, N = N, response = "binomial")
})
network

Example output

$Outcomes
 [1]   3   3  14   7  11   5 127 102  27  28   6   4 152  98  48  60  37  25 188
[20] 138  52  64  47  45  16   9  45  57  31  25  38  33  12  28   6   8   3   6
[39]  40  32  43  27  39  22

$N
 [1]   39   38  116  114   93   69 1520 1533  365  355   52   59  939  945  471
[16]  632  282  278 1921 1916  583  873  266  263  293  291  883  858  147  154
[31]  213  207  122  251  154  151  134  174  218  209  364  391  674  680

$Study
 [1]  1  1  2  2  3  3  4  4  5  5  6  6  7  7  8  8  9  9 10 10 11 11 12 12 13
[26] 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22

$Treat
 [1] 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
[39] 1 2 1 2 1 2

$Outcomes
      [,1]
 [1,]    3
 [2,]    3
 [3,]   14
 [4,]    7
 [5,]   11
 [6,]    5
 [7,]  127
 [8,]  102
 [9,]   27
[10,]   28
[11,]    6
[12,]    4
[13,]  152
[14,]   98
[15,]   48
[16,]   60
[17,]   37
[18,]   25
[19,]  188
[20,]  138
[21,]   52
[22,]   64
[23,]   47
[24,]   45
[25,]   16
[26,]    9
[27,]   45
[28,]   57
[29,]   31
[30,]   25
[31,]   38
[32,]   33
[33,]   12
[34,]   28
[35,]    6
[36,]    8
[37,]    3
[38,]    6
[39,]   40
[40,]   32
[41,]   43
[42,]   27
[43,]   39
[44,]   22

$Treat
 [1] 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
[39] 1 2 1 2 1 2

$Study
 [1]  1  1  2  2  3  3  4  4  5  5  6  6  7  7  8  8  9  9 10 10 11 11 12 12 13
[26] 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22

$N
 [1]   39   38  116  114   93   69 1520 1533  365  355   52   59  939  945  471
[16]  632  282  278 1921 1916  583  873  266  263  293  291  883  858  147  154
[31]  213  207  122  251  154  151  134  174  218  209  364  391  674  680

$SE
NULL

$data
      Outcomes    N Study Treat
 [1,]        3   39     1     1
 [2,]        3   38     1     2
 [3,]       14  116     2     1
 [4,]        7  114     2     2
 [5,]       11   93     3     1
 [6,]        5   69     3     2
 [7,]      127 1520     4     1
 [8,]      102 1533     4     2
 [9,]       27  365     5     1
[10,]       28  355     5     2
[11,]        6   52     6     1
[12,]        4   59     6     2
[13,]      152  939     7     1
[14,]       98  945     7     2
[15,]       48  471     8     1
[16,]       60  632     8     2
[17,]       37  282     9     1
[18,]       25  278     9     2
[19,]      188 1921    10     1
[20,]      138 1916    10     2
[21,]       52  583    11     1
[22,]       64  873    11     2
[23,]       47  266    12     1
[24,]       45  263    12     2
[25,]       16  293    13     1
[26,]        9  291    13     2
[27,]       45  883    14     1
[28,]       57  858    14     2
[29,]       31  147    15     1
[30,]       25  154    15     2
[31,]       38  213    16     1
[32,]       33  207    16     2
[33,]       12  122    17     1
[34,]       28  251    17     2
[35,]        6  154    18     1
[36,]        8  151    18     2
[37,]        3  134    19     1
[38,]        6  174    19     2
[39,]       40  218    20     1
[40,]       32  209    20     2
[41,]       43  364    21     1
[42,]       27  391    21     2
[43,]       39  674    22     1
[44,]       22  680    22     2

$Treat.order
1 2 
1 2 

$Study.order
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 

$response
[1] "binomial"

$type
[1] "random"

$rank.preference
[1] "higher"

$baseline
[1] "none"

$baseline.risk
[1] "independent"

$covariate
NULL

$covariate.type
NULL

$covariate.model
NULL

$mean.A
NULL

$prec.A
NULL

$ncat
[1] 1

$nrow
[1] 44

$nstudy
[1] 22

$ntreat
[1] 2

$na
 [1] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

$b.id
 [1]  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
[13]  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
[25]  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
[37]  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE

$t
      [,1] [,2]
 [1,]    1    2
 [2,]    1    2
 [3,]    1    2
 [4,]    1    2
 [5,]    1    2
 [6,]    1    2
 [7,]    1    2
 [8,]    1    2
 [9,]    1    2
[10,]    1    2
[11,]    1    2
[12,]    1    2
[13,]    1    2
[14,]    1    2
[15,]    1    2
[16,]    1    2
[17,]    1    2
[18,]    1    2
[19,]    1    2
[20,]    1    2
[21,]    1    2
[22,]    1    2

$n
      [,1] [,2]
 [1,]   39   38
 [2,]  116  114
 [3,]   93   69
 [4,] 1520 1533
 [5,]  365  355
 [6,]   52   59
 [7,]  939  945
 [8,]  471  632
 [9,]  282  278
[10,] 1921 1916
[11,]  583  873
[12,]  266  263
[13,]  293  291
[14,]  883  858
[15,]  147  154
[16,]  213  207
[17,]  122  251
[18,]  154  151
[19,]  134  174
[20,]  218  209
[21,]  364  391
[22,]  674  680

$se
NULL

$r
      [,1] [,2]
 [1,]    3    3
 [2,]   14    7
 [3,]   11    5
 [4,]  127  102
 [5,]   27   28
 [6,]    6    4
 [7,]  152   98
 [8,]   48   60
 [9,]   37   25
[10,]  188  138
[11,]   52   64
[12,]   47   45
[13,]   16    9
[14,]   45   57
[15,]   31   25
[16,]   38   33
[17,]   12   28
[18,]    6    8
[19,]    3    6
[20,]   40   32
[21,]   43   27
[22,]   39   22

$hy.prior.Eta
NULL

$hy.prior.bl
NULL

$hy.prior.cov
NULL

$hy.prior
$hy.prior[[1]]
[1] "dunif"

$hy.prior[[2]]
[1] 0

$hy.prior[[3]]
[1] 5


$prior.data
$prior.data$mean.d
[1] 0

$prior.data$prec.d
[1] 1e-04

$prior.data$mean.Eta
[1] 0

$prior.data$prec.Eta
[1] 1e-04

$prior.data$hy.prior.1
[1] 0

$prior.data$hy.prior.2
[1] 5


$code
[1] "model\n{\n\tfor (i in 1:22) {\n\t\tEta[i] ~ dnorm(mean.Eta, prec.Eta)\n\t}\n\tfor (i in 1:22) {\n\t\tw[i,1] <- 0\n\t\tdelta[i,1] <- 0\n\t\tfor(k in 1:na[i]){\n\t\t\tr[i,k] ~ dbin(p[i,k],n[i,k])\n\t\t\tlogit(p[i,k]) <- Eta[i] + delta[i,k]\n\t\t\trhat[i,k] <- p[i,k] * n[i,k]\n\t\t\tdev[i,k] <- 2 * (r[i,k] * (log(r[i,k])-log(rhat[i,k])) + (n[i,k]-r[i,k])*(log(n[i,k]-r[i,k]) - log(n[i,k]-rhat[i,k])))\n\t\t}\n\t\tresdev[i] <- sum(dev[i,1:na[i]])\n\t\tfor(k in 2:na[i]){\n\t\t\tdelta[i,k] ~ dnorm(md[i,k],precd[i,k])\n\t\t\tmd[i,k] <- d[t[i,k]] - d[t[i,1]] + sw[i,k]\n\t\t\tprecd[i,k] <- prec *2*(k-1)/k\n\t\t\tw[i,k] <- (delta[i,k] - d[t[i,k]] + d[t[i,1]])\n\t\t\tsw[i,k] <- sum(w[i,1:(k-1)])/(k-1)\n\t\t}\n\t}\n\ttotresdev <- sum(resdev[])\n\td[1] <- 0\n\tfor(k in 2:2){\n\t\td[k] ~ dnorm(mean.d,prec.d)\n\t}\n\tsd ~ dunif(hy.prior.1, hy.prior.2)\n\tprec <- pow(sd,-2)\n\tlogvar <- log(pow(sd, 2))\n\trank_number <- rank(d[])\n\tfor(k in 1:2){\n\t\trk[k] <- 2 +1- rank_number[k]\n\t\tfor(h in 1:2){ prob[h,k] <- equals(rk[k],h)}\n\t}\n}"

attr(,"class")
[1] "network.data"

bnma documentation built on Jan. 3, 2022, 5:12 p.m.