Bayesian network meta analysis

Michael Seo and Christopher Schmid

2022-01-03

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 statitics 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.004328
#> [1] 1.001647

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)

# 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.008054
#> [1] 1.002722
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.104225 0.15168 3.916e-04      0.0011327
#> d[3,1]     -0.045920 0.11272 2.910e-04      0.0006900
#> d[1,2]      0.000000 0.00000 0.000e+00      0.0000000
#> d[2,2]     -0.188146 0.15395 3.975e-04      0.0011471
#> d[3,2]     -0.270448 0.11216 2.896e-04      0.0006677
#> sigma[1,1]  0.114755 0.05070 1.309e-04      0.0002427
#> sigma[2,1]  0.004827 0.03451 8.911e-05      0.0001639
#> sigma[1,2]  0.004827 0.03451 8.911e-05      0.0001639
#> sigma[2,2]  0.114402 0.05019 1.296e-04      0.0002257
#> 
#> 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.40315 -0.20342 -0.104488 -0.005442  0.19796
#> d[3,1]     -0.27030 -0.11930 -0.045302  0.027717  0.17527
#> d[1,2]      0.00000  0.00000  0.000000  0.000000  0.00000
#> d[2,2]     -0.49578 -0.28848 -0.186956 -0.086888  0.11156
#> d[3,2]     -0.49454 -0.34300 -0.269755 -0.196939 -0.05078
#> sigma[1,1]  0.05183  0.08047  0.103625  0.136027  0.24301
#> sigma[2,1] -0.06311 -0.01405  0.004107  0.022958  0.07634
#> sigma[1,2] -0.06311 -0.01405  0.004107  0.022958  0.07634
#> sigma[2,2]  0.05199  0.08048  0.103513  0.135493  0.24076
#> 
#> 
#> $Treat.order
#> 1 2 3 
#> 1 2 3 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 31.20086 60.53076 91.73162 
#> 
#> $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.007003
#> [1] 1.022508
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.30050 0.2568 0.0006631       0.003446
#> d[1]      0.00000 0.0000 0.0000000       0.000000
#> d[2]     -0.06469 0.2035 0.0005254       0.002609
#> sd        0.24115 0.2001 0.0005166       0.005469
#> 
#> 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.86527 -0.43415 -0.28582 -0.15281 0.1811
#> d[1]      0.00000  0.00000  0.00000  0.00000 0.0000
#> d[2]     -0.46882 -0.17658 -0.06772  0.04271 0.3588
#> sd        0.01009  0.09478  0.19079  0.33364 0.7604
#> 
#> 
#> $Treat.order
#>         1         2 
#> "Placebo"  "Statin" 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 42.60999 25.04813 67.65812 
#> 
#> $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 exchangeable baseline risk model.

network <- with(certolizumab, network.data(Outcomes = Outcomes, Treat = Treat, Study = Study, N = N, response = "binomial", Treat.order = Treat.order, baseline = "common", baseline.risk = "exchangeable"))
result <- network.run(network)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 24
#>    Unobserved stochastic nodes: 34
#>    Total graph size: 670
#> 
#> Initializing model
#> 
#> NOTE: Stopping adaptation
#> 
#> 
#> [1] 1.029462
#> [1] 1.006027
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
#> E       -2.2811 0.2626 0.0006781       0.002883
#> b_bl[1]  0.0000 0.0000 0.0000000       0.000000
#> b_bl[2] -0.7654 0.2740 0.0007074       0.004636
#> b_bl[3] -0.7654 0.2740 0.0007074       0.004636
#> b_bl[4] -0.7654 0.2740 0.0007074       0.004636
#> b_bl[5] -0.7654 0.2740 0.0007074       0.004636
#> b_bl[6] -0.7654 0.2740 0.0007074       0.004636
#> b_bl[7] -0.7654 0.2740 0.0007074       0.004636
#> d[1]     0.0000 0.0000 0.0000000       0.000000
#> d[2]     1.8706 0.2260 0.0005834       0.001995
#> d[3]     2.1311 0.2085 0.0005384       0.002359
#> d[4]     2.0225 0.4149 0.0010712       0.005262
#> d[5]     1.6301 0.1982 0.0005118       0.002169
#> d[6]     0.3017 0.5800 0.0014976       0.009584
#> d[7]     2.1446 0.2827 0.0007300       0.002978
#> sd       0.1882 0.1638 0.0004228       0.003132
#> sdE      0.7518 0.2826 0.0007297       0.005673
#> 
#> 2. Quantiles for each variable:
#> 
#>              2.5%      25%     50%     75%   97.5%
#> E       -2.840612 -2.43328 -2.2680 -2.1141 -1.7927
#> b_bl[1]  0.000000  0.00000  0.0000  0.0000  0.0000
#> b_bl[2] -1.263821 -0.91884 -0.7819 -0.6298 -0.1671
#> b_bl[3] -1.263821 -0.91884 -0.7819 -0.6298 -0.1671
#> b_bl[4] -1.263821 -0.91884 -0.7819 -0.6298 -0.1671
#> b_bl[5] -1.263821 -0.91884 -0.7819 -0.6298 -0.1671
#> b_bl[6] -1.263821 -0.91884 -0.7819 -0.6298 -0.1671
#> b_bl[7] -1.263821 -0.91884 -0.7819 -0.6298 -0.1671
#> d[1]     0.000000  0.00000  0.0000  0.0000  0.0000
#> d[2]     1.416527  1.75593  1.8692  1.9868  2.3208
#> d[3]     1.735631  2.00949  2.1265  2.2453  2.5619
#> d[4]     1.212433  1.77338  2.0211  2.2679  2.8480
#> d[5]     1.236498  1.52209  1.6295  1.7389  2.0269
#> d[6]    -0.903825 -0.05759  0.3220  0.6912  1.3721
#> d[7]     1.598267  1.98820  2.1434  2.2947  2.7221
#> sd       0.008548  0.07374  0.1484  0.2542  0.6198
#> sdE      0.337621  0.55688  0.7061  0.8927  1.4406
#> 
#> 
#> $Treat.order
#>             1             2             3             4             5 
#>     "Placebo"         "CZP"  "Adalimumab"  "Etanercept"  "Infliximab" 
#>             6             7 
#>   "Rituximab" "Tocilizumab" 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 27.93979 18.68466 46.62445 
#> 
#> $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.010322
#> [1] 1.001706
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.34371 0.5787 0.0014941       0.002002
#> d[1,3]  0.85864 0.2737 0.0007067       0.001457
#> d[2,3] -0.05673 0.7408 0.0019127       0.002976
#> d[1,4]  1.43499 0.8824 0.0022784       0.006912
#> d[2,4]  0.64488 0.7332 0.0018932       0.003412
#> d[3,4]  0.20124 0.7808 0.0020159       0.003183
#> sd      0.92430 0.2198 0.0005674       0.002273
#> 
#> 2. Quantiles for each variable:
#> 
#>           2.5%      25%      50%    75% 97.5%
#> d[1,2] -0.7994 -0.02852  0.34124 0.7140 1.497
#> d[1,3]  0.3377  0.67816  0.85136 1.0308 1.423
#> d[2,3] -1.5259 -0.53343 -0.05749 0.4226 1.411
#> d[1,4] -0.2014  0.84400  1.39513 1.9807 3.301
#> d[2,4] -0.8010  0.17229  0.64231 1.1182 2.107
#> d[3,4] -1.3607 -0.30163  0.20792 0.7112 1.725
#> sd      0.5840  0.76803  0.89395 1.0469 1.437
#> 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 53.46735 44.97255 98.43990 
#> 
#> $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.003065
#> [1] 1.001608
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.00067
#> [1] 1.000368
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.0015571 0.03037 7.840e-05      1.888e-04
#> d[3]         -0.1606035 0.04319 1.115e-04      3.552e-04
#> d[4]         -0.0441666 0.04657 1.202e-04      2.328e-04
#> d[5]         -0.1130875 0.06029 1.557e-04      4.755e-04
#> d[6]         -0.1551007 0.07721 1.994e-04      5.715e-04
#> d[7]         -0.4641173 0.10120 2.613e-04      5.771e-04
#> d[8]         -0.1951433 0.21998 5.680e-04      1.264e-03
#> d[9]          0.0036168 0.03699 9.550e-05      2.212e-04
#> diff          1.2422874 0.41817 1.080e-03      3.941e-03
#> direct        1.4065077 0.41453 1.070e-03      3.923e-03
#> oneminusprob  0.0005733 0.02394 6.181e-05      9.202e-05
#> prob          0.9994267 0.02394 6.181e-05      9.202e-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.06111 -0.02211 -0.001576  0.01887  0.057944
#> d[3]         -0.24559 -0.18966 -0.160581 -0.13156 -0.075732
#> d[4]         -0.13540 -0.07545 -0.044002 -0.01274  0.047004
#> d[5]         -0.23200 -0.15350 -0.112982 -0.07248  0.004901
#> d[6]         -0.30635 -0.20707 -0.154769 -0.10313 -0.003385
#> d[7]         -0.66326 -0.53214 -0.463957 -0.39574 -0.266843
#> d[8]         -0.62748 -0.34357 -0.194401 -0.04733  0.235415
#> d[9]         -0.06865 -0.02132  0.003482  0.02856  0.076394
#> diff          0.45907  0.95602  1.228305  1.51572  2.103398
#> direct        0.63019  1.12262  1.391818  1.67648  2.260645
#> 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.242287
#> 
#> $p_value
#> [1] 0.001146667
#> 
#> 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.025162
#> [1] 1.006048
#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.7507 1.723e+00 4.450e-03      1.080e-02
#> RR[3,1]    3.9944 4.015e+00 1.037e-02      3.133e-02
#> RR[4,1]    1.1203 1.468e+00 3.789e-03      1.137e-02
#> RR[5,1]    0.1917 2.686e-01 6.934e-04      1.910e-03
#> RR[6,1]    0.3795 9.829e-01 2.538e-03      5.718e-03
#> RR[7,1]    0.9227 1.189e+00 3.070e-03      7.395e-03
#> RR[3,2]    9.5101 7.174e+02 1.852e+00      1.898e+00
#> RR[4,2]    8.8718 2.546e+03 6.573e+00      6.573e+00
#> RR[5,2]    0.2122 9.231e+00 2.383e-02      2.571e-02
#> RR[6,2]    1.9899 4.215e+02 1.088e+00      1.089e+00
#> RR[7,2]    7.0841 2.101e+03 5.426e+00      5.426e+00
#> RR[4,3] 1479.0082 5.670e+05 1.464e+03      1.464e+03
#> RR[5,3]   14.3087 5.285e+03 1.365e+01      1.365e+01
#> RR[6,3]   28.5992 7.266e+03 1.876e+01      1.876e+01
#> RR[7,3]  472.7112 1.706e+05 4.405e+02      4.405e+02
#> RR[5,4]    0.2444 5.290e-01 1.366e-03      1.610e-03
#> RR[6,4]    0.7632 2.922e+01 7.544e-02      7.789e-02
#> RR[7,4]    1.4878 2.347e+01 6.060e-02      6.253e-02
#> RR[6,5]    2.6180 4.949e+01 1.278e-01      1.390e-01
#> RR[7,5]    5.5338 1.427e+01 3.685e-02      4.797e-02
#> RR[7,6]  171.7327 1.782e+04 4.601e+01      5.067e+01
#> d[1]       0.0000 0.000e+00 0.000e+00      0.000e+00
#> d[2]       0.3439 1.093e+00 2.821e-03      6.561e-03
#> d[3]       1.4575 1.857e+00 4.796e-03      1.558e-02
#> d[4]      -0.2439 1.037e+00 2.678e-03      7.502e-03
#> d[5]      -1.9983 6.932e-01 1.790e-03      5.244e-03
#> d[6]      -1.9934 1.499e+00 3.871e-03      9.183e-03
#> d[7]      -0.4939 1.088e+00 2.810e-03      6.696e-03
#> sd         0.9288 6.364e-01 1.643e-03      9.242e-03
#> 
#> 2. Quantiles for each variable:
#> 
#>              2.5%      25%      50%      75%   97.5%
#> RR[2,1]  0.170082  0.83863  1.33522  2.07260  6.0600
#> RR[3,1]  0.160803  1.31330  2.83810  5.34696 14.5265
#> RR[4,1]  0.143037  0.47496  0.73093  1.19562  4.7334
#> RR[5,1]  0.035764  0.10722  0.15164  0.21063  0.5708
#> RR[6,1]  0.007601  0.06741  0.15164  0.33636  2.2616
#> RR[7,1]  0.070885  0.38976  0.65267  1.03671  3.6607
#> RR[3,2]  0.131057  0.95973  2.00932  4.09683 21.1507
#> RR[4,2]  0.115276  0.35830  0.55544  0.92975  5.0963
#> RR[5,2]  0.030008  0.08132  0.11674  0.16643  0.5301
#> RR[6,2]  0.006109  0.05209  0.11763  0.26360  1.8879
#> RR[7,2]  0.059633  0.29535  0.50019  0.80969  3.5334
#> RR[4,3]  0.033582  0.14040  0.28949  0.62244  5.2904
#> RR[5,3]  0.008336  0.02979  0.05782  0.11679  0.6819
#> RR[6,3]  0.002325  0.02192  0.05941  0.16162  1.6980
#> RR[7,3]  0.020174  0.11427  0.24638  0.53619  3.8014
#> RR[5,4]  0.043922  0.14360  0.21100  0.28591  0.6016
#> RR[6,4]  0.008392  0.09071  0.20816  0.44895  2.4600
#> RR[7,4]  0.082515  0.51151  0.89934  1.41164  4.3557
#> RR[6,5]  0.072822  0.48705  1.00085  2.06141 10.9874
#> RR[7,5]  0.813289  2.88904  4.25550  6.06306 16.8294
#> RR[7,6]  0.230996  1.84083  4.18812  9.44983 79.1262
#> d[1]     0.000000  0.00000  0.00000  0.00000  0.0000
#> d[2]    -1.863580 -0.19614  0.33189  0.87318  2.5877
#> d[3]    -1.925870  0.31424  1.32531  2.49147  5.4433
#> d[4]    -2.040157 -0.80663 -0.34546  0.20451  2.1454
#> d[5]    -3.440198 -2.33317 -1.98446 -1.65373 -0.6153
#> d[6]    -4.993788 -2.80311 -1.98612 -1.16896  0.9838
#> d[7]    -2.750253 -1.01419 -0.46910  0.04051  1.6894
#> sd       0.125804  0.50866  0.78023  1.17463  2.6307
#> 
#> 
#> $Treat.order
#>             1             2             3             4             5 
#>  "Adalimumab"         "CZP"  "Etanercept"  "Infliximab"     "Placebo" 
#>             6             7 
#>   "Rituximab" "Tocilizumab" 
#> 
#> $deviance
#>     Dbar       pD      DIC 
#> 26.97910 22.61078 49.58988 
#> 
#> $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 need 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"