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.001396
#> [1] 1.001584

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.00568
#> [1] 1.003385
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.00000 0.00000 0.000e+00      0.0000000
#> d[2,1]     -0.10476 0.15130 3.906e-04      0.0011069
#> d[3,1]     -0.04682 0.11243 2.903e-04      0.0006886
#> d[1,2]      0.00000 0.00000 0.000e+00      0.0000000
#> d[2,2]     -0.19006 0.15474 3.995e-04      0.0012112
#> d[3,2]     -0.27175 0.11222 2.897e-04      0.0006795
#> sigma[1,1]  0.11470 0.05097 1.316e-04      0.0002461
#> sigma[2,1]  0.00479 0.03438 8.876e-05      0.0001652
#> sigma[1,2]  0.00479 0.03438 8.876e-05      0.0001652
#> sigma[2,2]  0.11422 0.05021 1.296e-04      0.0002342
#> 
#> 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.40109 -0.20422 -0.105428 -0.006314  0.19647
#> d[3,1]     -0.27079 -0.11984 -0.046236  0.026412  0.17452
#> d[1,2]      0.00000  0.00000  0.000000  0.000000  0.00000
#> d[2,2]     -0.49909 -0.29100 -0.188725 -0.087639  0.11144
#> d[3,2]     -0.49629 -0.34444 -0.271048 -0.198266 -0.05157
#> sigma[1,1]  0.05206  0.08042  0.103556  0.135769  0.24309
#> sigma[2,1] -0.06242 -0.01409  0.004002  0.022791  0.07635
#> sigma[1,2] -0.06242 -0.01409  0.004002  0.022791  0.07635
#> sigma[2,2]  0.05182  0.08025  0.103363  0.135305  0.24071
#> 
#> 
#> $Treat.order
#> 1 2 3 
#> 1 2 3 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 31.15000 60.41249 91.56249 
#> 
#> $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.015913
#> [1] 1.007431
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.30600 0.2605 0.0006727       0.003593
#> d[1]      0.00000 0.0000 0.0000000       0.000000
#> d[2]     -0.06208 0.2041 0.0005269       0.002604
#> sd        0.24008 0.2008 0.0005183       0.005349
#> 
#> 2. Quantiles for each variable:
#> 
#>               2.5%     25%      50%      75%  97.5%
#> beta1[1]  0.000000  0.0000  0.00000  0.00000 0.0000
#> beta1[2] -0.890971 -0.4354 -0.28499 -0.15994 0.1823
#> d[1]      0.000000  0.0000  0.00000  0.00000 0.0000
#> d[2]     -0.463337 -0.1719 -0.07024  0.04117 0.3778
#> sd        0.008919  0.0907  0.19114  0.33564 0.7515
#> 
#> 
#> $Treat.order
#>         1         2 
#> "Placebo"  "Statin" 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 42.62775 25.05385 67.68160 
#> 
#> $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 event. 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.022539
#> [1] 1.01097
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.8734 0.1584 0.0004089       0.002428
#> b_bl[3] -0.8734 0.1584 0.0004089       0.002428
#> b_bl[4] -0.8734 0.1584 0.0004089       0.002428
#> b_bl[5] -0.8734 0.1584 0.0004089       0.002428
#> b_bl[6] -0.8734 0.1584 0.0004089       0.002428
#> b_bl[7] -0.8734 0.1584 0.0004089       0.002428
#> d[1]     0.0000 0.0000 0.0000000       0.000000
#> d[2]     1.8602 0.2236 0.0005772       0.001621
#> d[3]     2.1535 0.2016 0.0005204       0.001811
#> d[4]     2.0876 0.4540 0.0011721       0.006795
#> d[5]     1.6724 0.1909 0.0004928       0.001477
#> d[6]     0.3272 0.5750 0.0014845       0.008613
#> d[7]     2.1892 0.2628 0.0006787       0.002298
#> sd       0.1987 0.1688 0.0004359       0.003019
#> 
#> 2. Quantiles for each variable:
#> 
#>            2.5%      25%     50%     75%   97.5%
#> b_bl[1]  0.0000  0.00000  0.0000  0.0000  0.0000
#> b_bl[2] -1.1683 -0.96522 -0.8807 -0.7868 -0.5442
#> b_bl[3] -1.1683 -0.96522 -0.8807 -0.7868 -0.5442
#> b_bl[4] -1.1683 -0.96522 -0.8807 -0.7868 -0.5442
#> b_bl[5] -1.1683 -0.96522 -0.8807 -0.7868 -0.5442
#> b_bl[6] -1.1683 -0.96522 -0.8807 -0.7868 -0.5442
#> b_bl[7] -1.1683 -0.96522 -0.8807 -0.7868 -0.5442
#> d[1]     0.0000  0.00000  0.0000  0.0000  0.0000
#> d[2]     1.4023  1.75019  1.8620  1.9727  2.3055
#> d[3]     1.7818  2.03479  2.1448  2.2621  2.5813
#> d[4]     1.2382  1.81293  2.0747  2.3473  3.0169
#> d[5]     1.3068  1.56776  1.6664  1.7703  2.0734
#> d[6]    -0.8788 -0.02878  0.3513  0.7099  1.3862
#> d[7]     1.6903  2.04246  2.1842  2.3269  2.7346
#> sd       0.0084  0.07839  0.1601  0.2696  0.6361
#> 
#> 
#> $Treat.order
#>             1             2             3             4             5 
#>     "Placebo"         "CZP"  "Adalimumab"  "Etanercept"  "Infliximab" 
#>             6             7 
#>   "Rituximab" "Tocilizumab" 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 24.62439 20.30440 44.92879 
#> 
#> $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.004927
#> [1] 1.003171
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.34110 0.5781 0.0014927       0.002025
#> d[1,3]  0.86051 0.2741 0.0007078       0.001525
#> d[2,3] -0.05745 0.7456 0.0019251       0.003007
#> d[1,4]  1.42815 0.8815 0.0022761       0.006736
#> d[2,4]  0.64649 0.7349 0.0018975       0.003408
#> d[3,4]  0.19665 0.7813 0.0020172       0.003208
#> sd      0.92489 0.2220 0.0005731       0.002317
#> 
#> 2. Quantiles for each variable:
#> 
#>           2.5%      25%      50%    75% 97.5%
#> d[1,2] -0.8003 -0.02992  0.33921 0.7098 1.493
#> d[1,3]  0.3347  0.68221  0.85417 1.0312 1.426
#> d[2,3] -1.5468 -0.53541 -0.05632 0.4228 1.414
#> d[1,4] -0.2039  0.83612  1.39172 1.9746 3.277
#> d[2,4] -0.8069  0.17417  0.64081 1.1161 2.115
#> d[3,4] -1.3789 -0.30289  0.20486 0.7059 1.722
#> sd      0.5845  0.76736  0.89364 1.0465 1.445
#> 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 53.51398 45.00660 98.52058 
#> 
#> $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.002997
#> [1] 1.001382
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.000789
#> [1] 1.00106
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.000e+00
#> d[2]         -0.0015560 0.03014 7.781e-05      1.842e-04
#> d[3]         -0.1606388 0.04336 1.120e-04      3.598e-04
#> d[4]         -0.0442110 0.04637 1.197e-04      2.375e-04
#> d[5]         -0.1126021 0.06027 1.556e-04      4.721e-04
#> d[6]         -0.1553175 0.07702 1.989e-04      5.693e-04
#> d[7]         -0.4649503 0.10153 2.622e-04      5.891e-04
#> d[8]         -0.1989399 0.22008 5.682e-04      1.265e-03
#> d[9]          0.0040253 0.03675 9.489e-05      2.158e-04
#> diff          1.2414814 0.41593 1.074e-03      3.888e-03
#> direct        1.4061455 0.41217 1.064e-03      3.894e-03
#> oneminusprob  0.0006733 0.02594 6.698e-05      9.308e-05
#> prob          0.9993267 0.02594 6.698e-05      9.308e-05
#> 
#> 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.06065 -0.02203 -0.001585  0.01880  0.057566
#> d[3]         -0.24619 -0.18977 -0.160489 -0.13138 -0.076066
#> d[4]         -0.13553 -0.07557 -0.044057 -0.01279  0.046411
#> d[5]         -0.23081 -0.15329 -0.112571 -0.07203  0.005842
#> d[6]         -0.30644 -0.20727 -0.155178 -0.10347 -0.004410
#> d[7]         -0.66366 -0.53330 -0.464853 -0.39632 -0.265558
#> d[8]         -0.63043 -0.34735 -0.199089 -0.04967  0.231502
#> d[9]         -0.06807 -0.02079  0.004201  0.02877  0.075727
#> diff          0.46758  0.95839  1.226526  1.51011  2.104228
#> direct        0.63892  1.12430  1.390808  1.67165  2.261256
#> 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.241481
#> 
#> $p_value
#> [1] 0.001346667
#> 
#> 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.016069
#> [1] 1.001706
#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.7537 1.745e+00 4.507e-03      1.097e-02
#> RR[3,1]   3.9952 4.022e+00 1.038e-02      2.954e-02
#> RR[4,1]   1.1333 1.513e+00 3.907e-03      1.261e-02
#> RR[5,1]   0.1946 3.030e-01 7.824e-04      2.170e-03
#> RR[6,1]   0.3895 1.059e+00 2.735e-03      6.578e-03
#> RR[7,1]   0.9281 1.236e+00 3.191e-03      7.912e-03
#> RR[3,2]   8.4888 6.119e+02 1.580e+00      1.725e+00
#> RR[4,2]   2.7938 1.852e+02 4.782e-01      5.401e-01
#> RR[5,2]   0.2067 3.873e+00 1.000e-02      1.060e-02
#> RR[6,2]   2.0834 2.839e+02 7.329e-01      7.333e-01
#> RR[7,2]   5.0420 1.122e+03 2.896e+00      2.897e+00
#> RR[4,3]  13.0111 1.797e+03 4.640e+00      4.965e+00
#> RR[5,3]   1.3288 3.775e+02 9.747e-01      1.018e+00
#> RR[6,3]   6.5725 1.771e+03 4.573e+00      4.651e+00
#> RR[7,3] 149.9060 5.670e+04 1.464e+02      1.464e+02
#> RR[5,4]   0.2434 4.501e-01 1.162e-03      1.543e-03
#> RR[6,4]   0.6419 1.238e+01 3.196e-02      3.441e-02
#> RR[7,4]   1.4713 2.259e+01 5.832e-02      7.480e-02
#> RR[6,5]   2.6320 6.363e+01 1.643e-01      1.780e-01
#> RR[7,5]   5.5022 1.555e+01 4.015e-02      4.939e-02
#> RR[7,6] 159.5834 3.920e+04 1.012e+02      1.014e+02
#> d[1]      0.0000 0.000e+00 0.000e+00      0.000e+00
#> d[2]      0.3466 1.094e+00 2.825e-03      6.595e-03
#> d[3]      1.4564 1.870e+00 4.827e-03      1.533e-02
#> d[4]     -0.2356 1.045e+00 2.699e-03      7.916e-03
#> d[5]     -1.9940 6.961e-01 1.797e-03      5.276e-03
#> d[6]     -1.9782 1.505e+00 3.886e-03      9.130e-03
#> d[7]     -0.4918 1.090e+00 2.814e-03      6.772e-03
#> sd        0.9307 6.402e-01 1.653e-03      9.889e-03
#> 
#> 2. Quantiles for each variable:
#> 
#>              2.5%      25%      50%      75%   97.5%
#> RR[2,1]  0.173970  0.84178  1.33337  2.07198  6.0674
#> RR[3,1]  0.157523  1.29363  2.83178  5.35693 14.6061
#> RR[4,1]  0.143487  0.47563  0.73267  1.20476  4.8256
#> RR[5,1]  0.036288  0.10733  0.15174  0.21073  0.5828
#> RR[6,1]  0.007597  0.06800  0.15383  0.34149  2.2819
#> RR[7,1]  0.069954  0.39094  0.65414  1.03909  3.6744
#> RR[3,2]  0.129318  0.95456  1.98734  4.09058 20.9654
#> RR[4,2]  0.114423  0.36072  0.55811  0.93258  5.2634
#> RR[5,2]  0.030192  0.08162  0.11697  0.16669  0.5375
#> RR[6,2]  0.006384  0.05281  0.11963  0.26666  1.9257
#> RR[7,2]  0.057700  0.29549  0.50330  0.81135  3.5721
#> RR[4,3]  0.034020  0.14071  0.29155  0.64097  5.3984
#> RR[5,3]  0.008238  0.02998  0.05833  0.11861  0.6974
#> RR[6,3]  0.002316  0.02218  0.06080  0.16716  1.6765
#> RR[7,3]  0.019918  0.11522  0.24848  0.53990  3.8136
#> RR[5,4]  0.043289  0.14293  0.21091  0.28478  0.6085
#> RR[6,4]  0.008770  0.09132  0.21132  0.45551  2.3969
#> RR[7,4]  0.079027  0.50880  0.89777  1.41186  4.3792
#> RR[6,5]  0.073491  0.49128  1.01865  2.07762 10.7935
#> RR[7,5]  0.785181  2.89278  4.27465  6.06999 16.6873
#> RR[7,6]  0.226855  1.81947  4.12848  9.31154 77.7709
#> d[1]     0.000000  0.00000  0.00000  0.00000  0.0000
#> d[2]    -1.844938 -0.19225  0.33135  0.87230  2.5979
#> d[3]    -1.946613  0.29683  1.32766  2.49903  5.5064
#> d[4]    -2.041562 -0.80641 -0.34419  0.21209  2.1667
#> d[5]    -3.421571 -2.33162 -1.98457 -1.65230 -0.5918
#> d[6]    -4.985312 -2.79541 -1.97008 -1.15496  1.0013
#> d[7]    -2.766907 -1.01031 -0.46645  0.04294  1.6835
#> sd       0.136893  0.50960  0.78217  1.17436  2.6661
#> 
#> 
#> $Treat.order
#>             1             2             3             4             5 
#>  "Adalimumab"         "CZP"  "Etanercept"  "Infliximab"     "Placebo" 
#>             6             7 
#>   "Rituximab" "Tocilizumab" 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 27.00564 22.63578 49.64143 
#> 
#> $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"