Bayesian network meta analysis

In this vignette, we describe how to run a Bayesian network meta-analysis model using this package. First, we’ll need to load the package.

#install.packages("bnma")
#or devtools::install_github("MikeJSeo/bnma")
library(bnma)

Preprocessing

It is essential to specify the input data in a correct format. We have chosen to use arm-level data with following input variable names: Outcomes, N or SE, Study, and Treat. Outcomes is the trial results. N is the number of respondents used for binary or multinomial model. SE is the standard error used for normal model. Study is the study indicator for the meta analysis. Lastly, Treat is the treatment indicator for each arm. We will use a dataset parkinsons for illustration.

parkinsons
#> $Outcomes
#>  [1] -1.22 -1.53 -0.70 -2.40 -0.30 -2.60 -1.20 -0.24 -0.59 -0.73 -0.18 -2.20
#> [13] -2.50 -1.80 -2.10
#> 
#> $SE
#>  [1] 0.504 0.439 0.282 0.258 0.505 0.510 0.478 0.265 0.354 0.335 0.442 0.197
#> [13] 0.190 0.200 0.250
#> 
#> $Treat
#>  [1] "Placebo"       "Ropinirole"    "Placebo"       "Pramipexole"  
#>  [5] "Placebo"       "Pramipexole"   "Bromocriptine" "Ropinirole"   
#>  [9] "Bromocriptine" "Ropinirole"    "Bromocriptine" "Bromocriptine"
#> [13] "Cabergoline"   "Bromocriptine" "Cabergoline"  
#> 
#> $Study
#>  [1] 1 1 2 2 3 3 3 4 4 5 5 6 6 7 7
#> 
#> $Treat.order
#> [1] "Placebo"       "Pramipexole"   "Ropinirole"    "Bromocriptine"
#> [5] "Cabergoline"

In order to run network meta-analysis in JAGS, we need to relabel study names into to a numeric sequence, i.e. 1 to total number of studies, and relabel the treatment into a numeric sequence according to treatment order specified. If the treatment order is not specified, default is to use the alphabetical order. In the example below, we set placebo as the baseline treatment followed by Pramipexole, Ropinirole, Bromocriptine, and Cabergoline as the treatment order.

network <- with(parkinsons, network.data(Outcomes = Outcomes, Study = Study, Treat = Treat, SE = SE, response = "normal", Treat.order = Treat.order))
network$Treat.order 
#>               1               2               3               4               5 
#>       "Placebo"   "Pramipexole"    "Ropinirole" "Bromocriptine"   "Cabergoline"
network$Study.order
#> 1 2 3 4 5 6 7 
#> 1 2 3 4 5 6 7

Another important preprocessing step that is done in network.data function is changing the arm-level data into study-level data. We store the study-level data of Outcomes as r, Treat as t, N or SE as n or se. We can see how Outcomes changed into a study-level matrix given below (i.e. row = study). If the Outcomes are multinomial, it will change to a 3 dimensional array.

network$r
#>       [,1]  [,2] [,3]
#> [1,] -1.22 -1.53   NA
#> [2,] -0.70 -2.40   NA
#> [3,] -0.30 -2.60 -1.2
#> [4,] -0.24 -0.59   NA
#> [5,] -0.73 -0.18   NA
#> [6,] -2.20 -2.50   NA
#> [7,] -1.80 -2.10   NA

Datasets

Here are all the datasets available in the package for testing.

#blocker (binomial)
#cardiovascular (multinomial)
#certolizumab (binomial with a covariate)
#parkinsons (normal)
#parkinsons_contrast (normal- for contrast model)
#smoking (binomial)
#statins (binomial with a covariate)
#thrombolytic (binomial)

Priors

Priors can be set in the network.data function. If left unspecified, default values are used. For heterogeneity parameters of the random effects model, we follow the data format from a similar Bayesian network meta-analysis R package gemtc. It should be a list of length 3 where the first element should be the distribution (one of dunif, dgamma, dhnorm, dwish) and the next two are the parameters associated with the distribution. Here is an example of assigning a half-normal distribution with mean 0 and standard deviation 5.

network <- with(smoking, network.data(Outcomes = Outcomes, Study = Study, Treat = Treat, N = N, response = "binomial", mean.d = 0.1, hy.prior = list("dhnorm", 0, 5)))

Running the model

Now to run the model, we use the function network.run. The most important parameter is n.run which determines the number of final samples the user wants. Gelman-Rubin statistics is checked automatically every setsize number of iterations and once the series have converged we store the last half of the sequence. If the number of iteration is less than the number of final samples (n.runs), it will sample more to fill the requirement. One of the nice features of this package is that it checks for convergence automatically and will give an error if the sequence has not converged. The parameters tested for convergence are the relative treatment effects, baseline effect, and heterogeneity parameter. The number that is printed during the running of the model is the point estimate of the Gelman-Rubin statistics used to test convergence.

result <- network.run(network, n.run = 30000)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 50
#>    Unobserved stochastic nodes: 54
#>    Total graph size: 1129
#> 
#> Initializing model
#> 
#> NOTE: Stopping adaptation
#> 
#> 
#> [1] 1.001992
#> [1] 1.001527

Model Summary

Package includes many summary tools that can be used. One useful summary might be the forest plot.

network.forest.plot(result, label.margin = 15)
#> Warning in geom_text(aes(label = "Median [95% Crl]"), y = xlim.range[2] + : All aesthetics have length 1, but the data has 6 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#>   a single row.

# relative.effects.table(result)
# draw.network.graph(network)
# network.gelman.plot(result)
# network.autocorr.diag(result)
# network.autocorr.plot(result)
# network.rank.tx.plot(result)
# network.cumrank.tx.plot(result)
# sucra(result)
# network.deviance.plot(result)
# network.leverage.plot(result)

Multinomial model

Another nice addition of this package is that multinomial outcome dataset can be analyzed. Here is an example.

network <- with(cardiovascular, network.data(Outcomes, Study, Treat, N, response = "multinomial"))
result <- network.run(network)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 34
#>    Unobserved stochastic nodes: 37
#>    Total graph size: 1301
#> 
#> Initializing model
#> 
#> NOTE: Stopping adaptation
#> 
#> 
#> [1] 1.003335
#> [1] 1.004378
summary(result)
#> $summary.samples
#> 
#> Iterations = 1:50000
#> Thinning interval = 1 
#> Number of chains = 3 
#> Sample size per chain = 50000 
#> 
#> 1. Empirical mean and standard deviation for each variable,
#>    plus standard error of the mean:
#> 
#>                 Mean      SD  Naive SE Time-series SE
#> d[1,1]      0.000000 0.00000 0.000e+00      0.0000000
#> d[2,1]     -0.105135 0.15104 3.900e-04      0.0010917
#> d[3,1]     -0.046013 0.11266 2.909e-04      0.0007208
#> d[1,2]      0.000000 0.00000 0.000e+00      0.0000000
#> d[2,2]     -0.189634 0.15427 3.983e-04      0.0011598
#> d[3,2]     -0.271209 0.11261 2.908e-04      0.0006815
#> sigma[1,1]  0.114499 0.05057 1.306e-04      0.0002414
#> sigma[2,1]  0.004707 0.03446 8.898e-05      0.0001629
#> sigma[1,2]  0.004707 0.03446 8.898e-05      0.0001629
#> sigma[2,2]  0.114514 0.05035 1.300e-04      0.0002248
#> 
#> 2. Quantiles for each variable:
#> 
#>                2.5%      25%       50%       75%    97.5%
#> d[1,1]      0.00000  0.00000  0.000000  0.000000  0.00000
#> d[2,1]     -0.40135 -0.20417 -0.105257 -0.006781  0.19547
#> d[3,1]     -0.27105 -0.11901 -0.045366  0.027657  0.17479
#> d[1,2]      0.00000  0.00000  0.000000  0.000000  0.00000
#> d[2,2]     -0.49701 -0.29025 -0.188654 -0.088021  0.11263
#> d[3,2]     -0.49617 -0.34414 -0.270393 -0.197647 -0.05153
#> sigma[1,1]  0.05187  0.08041  0.103534  0.135547  0.24181
#> sigma[2,1] -0.06309 -0.01412  0.004012  0.022790  0.07672
#> sigma[1,2] -0.06309 -0.01412  0.004012  0.022790  0.07672
#> sigma[2,2]  0.05185  0.08056  0.103546  0.135755  0.24140
#> 
#> 
#> $Treat.order
#> 1 2 3 
#> 1 2 3 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 31.21009 60.54423 91.75433 
#> 
#> $total_n
#> [1] 34
#> 
#> attr(,"class")
#> [1] "summary.network.result"

Adding covariates

We can add continuous or discrete covariates to fit a network meta-regression. If the covariate is continuous, it is centered. Discrete variables need to be 0-1 dummy format. There are three different assumptions for covariate effect: “common”, “independent”, and “exchangeable”.

network <- with(statins, network.data(Outcomes, Study, Treat, N=N, response = "binomial", Treat.order = c("Placebo", "Statin"), covariate = covariate, covariate.type = "discrete", covariate.model = "common"))
result <- network.run(network)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 38
#>    Unobserved stochastic nodes: 41
#>    Total graph size: 877
#> 
#> Initializing model
#> 
#> NOTE: Stopping adaptation
#> 
#> 
#> [1] 1.058982
#> [1] 1.003099
#> [1] 1.012318
summary(result)
#> $summary.samples
#> 
#> Iterations = 1:50000
#> Thinning interval = 1 
#> Number of chains = 3 
#> Sample size per chain = 50000 
#> 
#> 1. Empirical mean and standard deviation for each variable,
#>    plus standard error of the mean:
#> 
#>              Mean     SD  Naive SE Time-series SE
#> beta1[1]  0.00000 0.0000 0.0000000       0.000000
#> beta1[2] -0.29920 0.2603 0.0006721       0.003572
#> d[1]      0.00000 0.0000 0.0000000       0.000000
#> d[2]     -0.06588 0.2047 0.0005286       0.002587
#> sd        0.24544 0.2030 0.0005242       0.005534
#> 
#> 2. Quantiles for each variable:
#> 
#>              2.5%      25%      50%      75%  97.5%
#> beta1[1]  0.00000  0.00000  0.00000  0.00000 0.0000
#> beta1[2] -0.88358 -0.43081 -0.28010 -0.14933 0.1932
#> d[1]      0.00000  0.00000  0.00000  0.00000 0.0000
#> d[2]     -0.48175 -0.17873 -0.07123  0.04098 0.3713
#> sd        0.01114  0.09221  0.19472  0.34595 0.7653
#> 
#> 
#> $Treat.order
#>         1         2 
#> "Placebo"  "Statin" 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 42.52735 25.08665 67.61400 
#> 
#> $total_n
#> [1] 38
#> 
#> attr(,"class")
#> [1] "summary.network.result"

Covariate plot shows you how the relative treatment effect changes as the covariate varies.

network.covariate.plot(result, base.treatment = "Placebo", comparison.treatment = "Statin")

Baseline risk

Another useful addition of this network package is the ability to model baseline risk. We can have “common”, “independent”, or “exchangeable” assumption on the baseline slopes and “independent” and “exchangeable” assumption on the baseline risk. Here we demonstrate a common baseline slope and independent baseline risk model.

Note that Abe 2006 study is problematic in the certolizumab dataset because it has 0 events. If we specify an informative prior on the baseline risk (i.e. prec.Eta), this helps with the convergence of the model.

network <- with(certolizumab, network.data(Outcomes = Outcomes, Treat = Treat, Study = Study, N = N, response = "binomial", Treat.order = Treat.order, baseline = "common", baseline.risk = "independent", prec.Eta = 0.1))
result <- network.run(network)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 24
#>    Unobserved stochastic nodes: 32
#>    Total graph size: 665
#> 
#> Initializing model
#> 
#> NOTE: Stopping adaptation
#> 
#> 
#> [1] 1.063147
#> [1] 1.050961
#> [1] 1.013655
#> [1] 1.013973
summary(result)
#> $summary.samples
#> 
#> Iterations = 1:50000
#> Thinning interval = 1 
#> Number of chains = 3 
#> Sample size per chain = 50000 
#> 
#> 1. Empirical mean and standard deviation for each variable,
#>    plus standard error of the mean:
#> 
#>            Mean     SD  Naive SE Time-series SE
#> b_bl[1]  0.0000 0.0000 0.0000000       0.000000
#> b_bl[2] -0.8779 0.1577 0.0004073       0.002461
#> b_bl[3] -0.8779 0.1577 0.0004073       0.002461
#> b_bl[4] -0.8779 0.1577 0.0004073       0.002461
#> b_bl[5] -0.8779 0.1577 0.0004073       0.002461
#> b_bl[6] -0.8779 0.1577 0.0004073       0.002461
#> b_bl[7] -0.8779 0.1577 0.0004073       0.002461
#> d[1]     0.0000 0.0000 0.0000000       0.000000
#> d[2]     1.8616 0.2312 0.0005970       0.001856
#> d[3]     2.1549 0.2052 0.0005298       0.001796
#> d[4]     2.0857 0.4523 0.0011679       0.006372
#> d[5]     1.6790 0.1956 0.0005051       0.001441
#> d[6]     0.3339 0.5808 0.0014997       0.009207
#> d[7]     2.1905 0.2705 0.0006985       0.002426
#> sd       0.2014 0.1803 0.0004656       0.003630
#> 
#> 2. Quantiles for each variable:
#> 
#>              2.5%      25%     50%     75%   97.5%
#> b_bl[1]  0.000000  0.00000  0.0000  0.0000  0.0000
#> b_bl[2] -1.173025 -0.96879 -0.8859 -0.7925 -0.5470
#> b_bl[3] -1.173025 -0.96879 -0.8859 -0.7925 -0.5470
#> b_bl[4] -1.173025 -0.96879 -0.8859 -0.7925 -0.5470
#> b_bl[5] -1.173025 -0.96879 -0.8859 -0.7925 -0.5470
#> b_bl[6] -1.173025 -0.96879 -0.8859 -0.7925 -0.5470
#> b_bl[7] -1.173025 -0.96879 -0.8859 -0.7925 -0.5470
#> d[1]     0.000000  0.00000  0.0000  0.0000  0.0000
#> d[2]     1.397946  1.74902  1.8621  1.9771  2.3128
#> d[3]     1.781590  2.03712  2.1469  2.2630  2.5794
#> d[4]     1.238235  1.81746  2.0752  2.3426  3.0015
#> d[5]     1.311731  1.57671  1.6741  1.7751  2.0802
#> d[6]    -0.858999 -0.03832  0.3583  0.7215  1.3999
#> d[7]     1.686498  2.04246  2.1828  2.3296  2.7439
#> sd       0.006538  0.07906  0.1614  0.2709  0.6428
#> 
#> 
#> $Treat.order
#>             1             2             3             4             5 
#>     "Placebo"         "CZP"  "Adalimumab"  "Etanercept"  "Infliximab" 
#>             6             7 
#>   "Rituximab" "Tocilizumab" 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 24.58019 20.43393 45.01411 
#> 
#> $total_n
#> [1] 24
#> 
#> attr(,"class")
#> [1] "summary.network.result"

Unrelated Means Model

Unrelated mean effects (UME) model estimates separate, unrelated basic parameters. We do not assume consistency in this model. We can compare this model with the standard consistency model. If the parameter estimates are similar for both models, and there is considerable overlap in the 95% credible interval, we can conclude that there is no evidence of inconsistency in the network.

# fit an inconsistency model (UME)
network2 <- with(smoking, {
  ume.network.data(Outcomes, Study, Treat, N = N, response = "binomial", type = "random")
})
result2 <- ume.network.run(network2)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 50
#>    Unobserved stochastic nodes: 57
#>    Total graph size: 1020
#> 
#> Initializing model
#> 
#> NOTE: Stopping adaptation
#> 
#> 
#> [1] 1.008957
#> [1] 1.002706
summary(result2)
#> $summary.samples
#> 
#> Iterations = 1:50000
#> Thinning interval = 1 
#> Number of chains = 3 
#> Sample size per chain = 50000 
#> 
#> 1. Empirical mean and standard deviation for each variable,
#>    plus standard error of the mean:
#> 
#>            Mean     SD  Naive SE Time-series SE
#> d[1,2]  0.33575 0.5803 0.0014984       0.002053
#> d[1,3]  0.86059 0.2717 0.0007015       0.001482
#> d[2,3] -0.05948 0.7406 0.0019121       0.002995
#> d[1,4]  1.42839 0.8778 0.0022664       0.006784
#> d[2,4]  0.64491 0.7320 0.0018900       0.003427
#> d[3,4]  0.20183 0.7793 0.0020123       0.003251
#> sd      0.92234 0.2201 0.0005683       0.002288
#> 
#> 2. Quantiles for each variable:
#> 
#>           2.5%      25%      50%    75% 97.5%
#> d[1,2] -0.8114 -0.03432  0.33424 0.7054 1.490
#> d[1,3]  0.3438  0.68218  0.85309 1.0306 1.421
#> d[2,3] -1.5330 -0.53723 -0.05581 0.4200 1.398
#> d[1,4] -0.2009  0.84151  1.38846 1.9774 3.268
#> d[2,4] -0.8007  0.17297  0.64212 1.1143 2.101
#> d[3,4] -1.3637 -0.29722  0.20807 0.7085 1.728
#> sd      0.5818  0.76635  0.89211 1.0444 1.439
#> 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 53.49415 44.96777 98.46192 
#> 
#> $total_n
#> [1] 50
#> 
#> attr(,"class")
#> [1] "summary.ume.network.result"

# fit a consistency model and compare posterior mean deviance in the consistency model and inconsistency model
network1 <- with(smoking, {
  network.data(Outcomes, Study, Treat, N = N, response = "binomial", type = "random")
})
result1 <- network.run(network1)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 50
#>    Unobserved stochastic nodes: 54
#>    Total graph size: 1129
#> 
#> Initializing model
#> 
#> NOTE: Stopping adaptation
#> 
#> 
#> [1] 1.003457
#> [1] 1.001044
network.inconsistency.plot(result1, result2)

Inconsistency model

We included another inconsistency model that can be used to test consistency assumption. Here we can specify a pair where we want to nodesplit and test the inconsistency assumptions. For instance if we specify treatment pair = c(3, 9), we are finding the difference in the direct and indirect evidence of treatment 3 and 9. Inconsistency estimate and the corresponding p-value are reported in the summary. If the p-value is small, it means that we can reject the null hypothesis that direct and indirect evidence agree. We can repeat for all the pairs in the network and identify pairs that might be inconsistent. Refer to Dias et al. 2010 (i.e. Checking consistency in mixed treatment comparison meta-analysis) for more details.

network <- with(thrombolytic, nodesplit.network.data(Outcomes, Study, Treat, N, response = "binomial", pair = c(3,9), type = "fixed"))
result <- nodesplit.network.run(network)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 102
#>    Unobserved stochastic nodes: 59
#>    Total graph size: 2263
#> 
#> Initializing model
#> 
#> NOTE: Stopping adaptation
#> 
#> 
#> [1] 1.002817
#> [1] 1.001062
summary(result)
#> $summary.samples
#> 
#> Iterations = 1:50000
#> Thinning interval = 1 
#> Number of chains = 3 
#> Sample size per chain = 50000 
#> 
#> 1. Empirical mean and standard deviation for each variable,
#>    plus standard error of the mean:
#> 
#>                    Mean      SD  Naive SE Time-series SE
#> d[1]          0.0000000 0.00000 0.000e+00      0.0000000
#> d[2]         -0.0018395 0.03011 7.773e-05      0.0001880
#> d[3]         -0.1598616 0.04300 1.110e-04      0.0003475
#> d[4]         -0.0436420 0.04627 1.195e-04      0.0002316
#> d[5]         -0.1122133 0.05960 1.539e-04      0.0004530
#> d[6]         -0.1546764 0.07686 1.985e-04      0.0005735
#> d[7]         -0.4645171 0.10088 2.605e-04      0.0005638
#> d[8]         -0.1967625 0.22045 5.692e-04      0.0012652
#> d[9]          0.0036995 0.03690 9.528e-05      0.0002199
#> diff          1.2449712 0.42519 1.098e-03      0.0041011
#> direct        1.4085323 0.42110 1.087e-03      0.0040748
#> oneminusprob  0.0007133 0.02670 6.894e-05      0.0001077
#> prob          0.9992867 0.02670 6.894e-05      0.0001077
#> 
#> 2. Quantiles for each variable:
#> 
#>                  2.5%      25%       50%      75%     97.5%
#> d[1]          0.00000  0.00000  0.000000  0.00000  0.000000
#> d[2]         -0.06088 -0.02218 -0.001892  0.01849  0.057099
#> d[3]         -0.24450 -0.18884 -0.159621 -0.13094 -0.075799
#> d[4]         -0.13472 -0.07470 -0.043678 -0.01263  0.046900
#> d[5]         -0.22966 -0.15235 -0.112265 -0.07205  0.004502
#> d[6]         -0.30481 -0.20652 -0.154625 -0.10272 -0.004037
#> d[7]         -0.66212 -0.53261 -0.464582 -0.39620 -0.266770
#> d[8]         -0.63120 -0.34537 -0.196104 -0.04841  0.235325
#> d[9]         -0.06894 -0.02126  0.003924  0.02868  0.075695
#> diff          0.45640  0.95147  1.229052  1.52198  2.123771
#> direct        0.63000  1.11614  1.392595  1.68271  2.279347
#> oneminusprob  0.00000  0.00000  0.000000  0.00000  0.000000
#> prob          1.00000  1.00000  1.000000  1.00000  1.000000
#> 
#> 
#> $deviance
#> NULL
#> 
#> $`Inconsistency estimate`
#> [1] 1.244971
#> 
#> $p_value
#> [1] 0.001426667
#> 
#> attr(,"class")
#> [1] "summary.nodesplit.network.result"

Finding risk difference, relative risk, and number needed to treat with Binomial outcomes

Default summary measure when analyzing binary outcomes is the odds ratio. We have added an option to calculate risk difference, relative risk, and number needed to treat by incorporating external baseline risk in treatment A (i.e. placebo).

#Using metaprop function from meta package, we meta-analyze placebo event proportion.
#library(meta)
#placebo_index <- which(certolizumab$Treat == "Placebo")
#meta.pla <- metaprop(event = certolizumab$Outcomes[placebo_index], n = certolizumab$N[placebo_index], method = "GLMM", sm = "PLOGIT")
#mean.A = meta.pla$TE.random; prec.A = 1/meta.pla$tau^2

network <- with(certolizumab, network.data(Outcomes = Outcomes, Treat = Treat, Study = Study, N = N, response = "binomial", mean.A = -2.27, prec.A = 2.53))
result <- network.run(network)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 24
#>    Unobserved stochastic nodes: 32
#>    Total graph size: 698
#> 
#> Initializing model
#> 
#> NOTE: Stopping adaptation
#> 
#> 
#> [1] 1.005534
#> [1] 1.007849
#summary(result, extra.pars = c("RD", "RR", "NNT"))
summary(result, extra.pars = c("RR"))
#> $summary.samples
#> 
#> Iterations = 1:50000
#> Thinning interval = 1 
#> Number of chains = 3 
#> Sample size per chain = 50000 
#> 
#> 1. Empirical mean and standard deviation for each variable,
#>    plus standard error of the mean:
#> 
#>             Mean        SD  Naive SE Time-series SE
#> RR[2,1]   1.7489 1.727e+00 4.460e-03      1.073e-02
#> RR[3,1]   3.9939 3.976e+00 1.027e-02      3.002e-02
#> RR[4,1]   1.1119 1.437e+00 3.709e-03      1.191e-02
#> RR[5,1]   0.1927 2.820e-01 7.282e-04      1.971e-03
#> RR[6,1]   0.3764 1.023e+00 2.640e-03      6.304e-03
#> RR[7,1]   0.9215 1.189e+00 3.069e-03      7.417e-03
#> RR[3,2]  10.6552 8.164e+02 2.108e+00      2.190e+00
#> RR[4,2]   7.5677 1.844e+03 4.761e+00      4.761e+00
#> RR[5,2]   0.2470 1.653e+01 4.267e-02      4.531e-02
#> RR[6,2]   1.2386 1.074e+02 2.772e-01      3.012e-01
#> RR[7,2]   1.5097 5.362e+01 1.385e-01      1.823e-01
#> RR[4,3]  23.3008 4.827e+03 1.246e+01      1.246e+01
#> RR[5,3]   0.5471 5.026e+01 1.298e-01      1.343e-01
#> RR[6,3]   3.0142 3.723e+02 9.614e-01      9.614e-01
#> RR[7,3]  33.1263 9.098e+03 2.349e+01      2.349e+01
#> RR[5,4]   0.2458 4.961e-01 1.281e-03      1.615e-03
#> RR[6,4]   0.7913 4.140e+01 1.069e-01      1.424e-01
#> RR[7,4]   1.4633 1.704e+01 4.401e-02      5.212e-02
#> RR[6,5]   2.6154 6.566e+01 1.695e-01      2.438e-01
#> RR[7,5]   5.5183 1.511e+01 3.901e-02      5.690e-02
#> RR[7,6] 351.0695 7.566e+04 1.954e+02      1.957e+02
#> d[1]      0.0000 0.000e+00 0.000e+00      0.000e+00
#> d[2]      0.3459 1.097e+00 2.831e-03      6.567e-03
#> d[3]      1.4625 1.870e+00 4.827e-03      1.620e-02
#> d[4]     -0.2499 1.034e+00 2.670e-03      7.556e-03
#> d[5]     -1.9973 6.967e-01 1.799e-03      5.319e-03
#> d[6]     -2.0098 1.506e+00 3.888e-03      9.156e-03
#> d[7]     -0.4920 1.086e+00 2.803e-03      6.651e-03
#> sd        0.9239 6.412e-01 1.656e-03      9.766e-03
#> 
#> 2. Quantiles for each variable:
#> 
#>              2.5%      25%      50%      75%   97.5%
#> RR[2,1]  0.172533  0.84457  1.33741  2.06855  6.1076
#> RR[3,1]  0.160600  1.32329  2.84433  5.35011 14.3774
#> RR[4,1]  0.140073  0.47556  0.73019  1.19223  4.7384
#> RR[5,1]  0.035408  0.10742  0.15180  0.21069  0.5700
#> RR[6,1]  0.007520  0.06662  0.14949  0.32728  2.2158
#> RR[7,1]  0.070354  0.39185  0.65886  1.04044  3.6154
#> RR[3,2]  0.131323  0.96538  2.00352  4.09669 20.9927
#> RR[4,2]  0.112479  0.35875  0.55455  0.92203  5.1266
#> RR[5,2]  0.030137  0.08165  0.11694  0.16579  0.5331
#> RR[6,2]  0.006232  0.05166  0.11553  0.25541  1.8142
#> RR[7,2]  0.058581  0.29744  0.50405  0.80862  3.5261
#> RR[4,3]  0.032939  0.13978  0.28642  0.62509  5.3696
#> RR[5,3]  0.008316  0.02980  0.05780  0.11692  0.6869
#> RR[6,3]  0.002318  0.02157  0.05814  0.15869  1.6595
#> RR[7,3]  0.020369  0.11509  0.24631  0.53709  3.7412
#> RR[5,4]  0.044192  0.14454  0.21184  0.28595  0.6090
#> RR[6,4]  0.008857  0.09073  0.20535  0.43868  2.3318
#> RR[7,4]  0.081324  0.51586  0.90396  1.41912  4.2915
#> RR[6,5]  0.071191  0.47906  0.98947  2.00588 10.4647
#> RR[7,5]  0.810612  2.91002  4.28504  6.06771 16.4780
#> RR[7,6]  0.238572  1.89614  4.28585  9.50184 78.2897
#> d[1]     0.000000  0.00000  0.00000  0.00000  0.0000
#> d[2]    -1.849130 -0.18755  0.33514  0.86837  2.5991
#> d[3]    -1.925794  0.32222  1.33377  2.49909  5.5391
#> d[4]    -2.064597 -0.80438 -0.34701  0.20029  2.1222
#> d[5]    -3.446348 -2.33207 -1.98439 -1.65532 -0.6188
#> d[6]    -5.001257 -2.81611 -2.00164 -1.19860  0.9657
#> d[7]    -2.758975 -1.00764 -0.45921  0.04453  1.6591
#> sd       0.121943  0.50224  0.77316  1.16611  2.6519
#> 
#> 
#> $Treat.order
#>             1             2             3             4             5 
#>  "Adalimumab"         "CZP"  "Etanercept"  "Infliximab"     "Placebo" 
#>             6             7 
#>   "Rituximab" "Tocilizumab" 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 27.07159 22.63840 49.70998 
#> 
#> $total_n
#> [1] 24
#> 
#> attr(,"class")
#> [1] "summary.network.result"

Generating reproducible results: initializing the random number generators

Generating reproducible results requires to set two set of seed values. First, the set.seed() function is used to allow bnma to generate reproducible initial values. Second, there is the JAGS RNG seed that needs to be set. Setting the JAGS RNG seed is not necessary in bnma as the program assigns default JAGS RNG seeds. However, users can specify their own seed if needed.

set.seed(1234) # seed for generating reproducible initial values
network <- with(blocker, network.data(Outcomes = Outcomes, Treat = Treat, Study = Study, N = N, response = "binomial"))

# JAGS RNG list of initial values
jags_inits <- list(
  list(".RNG.name"="base::Wichmann-Hill", ".RNG.seed" = 94387),
  list(".RNG.name"="base::Wichmann-Hill", ".RNG.seed" = 24507),
  list(".RNG.name"="base::Wichmann-Hill", ".RNG.seed" = 39483)
)
result <- network.run(network, n.chains=3, RNG.inits=jags_inits)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 44
#>    Unobserved stochastic nodes: 46
#>    Total graph size: 971
#> 
#> Initializing model
#> 
#> NOTE: Stopping adaptation
#> 
#> 
#> [1] 1.016791
#> [1] 1.018379

# bnma initial values now contain initial values for the parameters and the JAGS RNG initial values
str(result$inits)
#> List of 3
#>  $ :List of 6
#>   ..$ Eta      : num [1:22] -3.02 -1.88 -1.63 -2.61 -2.43 ...
#>   ..$ d        : num [1:2] NA -0.126
#>   ..$ sd       : num 0.271
#>   ..$ delta    : num [1:22, 1:2] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ .RNG.name: chr "base::Wichmann-Hill"
#>   ..$ .RNG.seed: num 94387
#>  $ :List of 6
#>   ..$ Eta      : num [1:22] -2.59 -1.83 -2.19 -2.53 -2.4 ...
#>   ..$ d        : num [1:2] NA -0.103
#>   ..$ sd       : num 0.283
#>   ..$ delta    : num [1:22, 1:2] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ .RNG.name: chr "base::Wichmann-Hill"
#>   ..$ .RNG.seed: num 24507
#>  $ :List of 6
#>   ..$ Eta      : num [1:22] -2.9 -2.23 -2.32 -2.51 -2.61 ...
#>   ..$ d        : num [1:2] NA -0.208
#>   ..$ sd       : num 0.297
#>   ..$ delta    : num [1:22, 1:2] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ .RNG.name: chr "base::Wichmann-Hill"
#>   ..$ .RNG.seed: num 39483

# reproducible results
summary(result)
#> $summary.samples
#> 
#> Iterations = 1:50000
#> Thinning interval = 1 
#> Number of chains = 3 
#> Sample size per chain = 50000 
#> 
#> 1. Empirical mean and standard deviation for each variable,
#>    plus standard error of the mean:
#> 
#>         Mean      SD  Naive SE Time-series SE
#> d[1]  0.0000 0.00000 0.0000000      0.0000000
#> d[2] -0.2489 0.06537 0.0001688      0.0007305
#> sd    0.1353 0.08160 0.0002107      0.0017319
#> 
#> 2. Quantiles for each variable:
#> 
#>           2.5%      25%     50%     75%   97.5%
#> d[1]  0.000000  0.00000  0.0000  0.0000  0.0000
#> d[2] -0.373586 -0.29239 -0.2502 -0.2068 -0.1169
#> sd    0.008369  0.07367  0.1283  0.1864  0.3149
#> 
#> 
#> $Treat.order
#> 1 2 
#> 1 2 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 41.75576 28.16711 69.92287 
#> 
#> $total_n
#> [1] 44
#> 
#> attr(,"class")
#> [1] "summary.network.result"