Author: Michael Seo and Christopher Schmid
Date: 2025-07-27

# Bayesian network meta analysis

#### Michael Seo and Christopher Schmid

#### 2025-07-27

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.001876
    #> [1] 1.001755

## 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.001934
    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.10469 0.15148 3.911e-04      0.0011412
    #> d[3,1]     -0.04661 0.11244 2.903e-04      0.0007006
    #> d[1,2]      0.00000 0.00000 0.000e+00      0.0000000
    #> d[2,2]     -0.18853 0.15439 3.986e-04      0.0011782
    #> d[3,2]     -0.27040 0.11237 2.901e-04      0.0006786
    #> sigma[1,1]  0.11456 0.05042 1.302e-04      0.0002358
    #> sigma[2,1]  0.00469 0.03450 8.908e-05      0.0001641
    #> sigma[1,2]  0.00469 0.03450 8.908e-05      0.0001641
    #> sigma[2,2]  0.11456 0.05039 1.301e-04      0.0002269
    #>
    #> 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.40209 -0.20471 -0.105431 -0.005863  0.19730
    #> d[3,1]     -0.27085 -0.11951 -0.046108  0.026726  0.17518
    #> d[1,2]      0.00000  0.00000  0.000000  0.000000  0.00000
    #> d[2,2]     -0.49715 -0.28862 -0.187281 -0.086770  0.11223
    #> d[3,2]     -0.49544 -0.34317 -0.269243 -0.196766 -0.05086
    #> sigma[1,1]  0.05201  0.08044  0.103551  0.135652  0.24242
    #> sigma[2,1] -0.06282 -0.01421  0.003933  0.022832  0.07599
    #> sigma[1,2] -0.06282 -0.01421  0.003933  0.022832  0.07599
    #> sigma[2,2]  0.05201  0.08041  0.103692  0.135799  0.24175
    #>
    #>
    #> $Treat.order
    #> 1 2 3
    #> 1 2 3
    #>
    #> $deviance
    #>     Dbar       pD      DIC
    #> 31.18510 60.49954 91.68464
    #>
    #> $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.112796
    #> [1] 1.017374
    #> [1] 1.008833
    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.29297 0.2569 0.0006632       0.003466
    #> d[1]      0.00000 0.0000 0.0000000       0.000000
    #> d[2]     -0.07055 0.2008 0.0005184       0.002536
    #> sd        0.23259 0.1979 0.0005111       0.005384
    #>
    #> 2. Quantiles for each variable:
    #>
    #>               2.5%      25%      50%      75%  97.5%
    #> beta1[1]  0.000000  0.00000  0.00000  0.00000 0.0000
    #> beta1[2] -0.868418 -0.42016 -0.26995 -0.15157 0.1835
    #> d[1]      0.000000  0.00000  0.00000  0.00000 0.0000
    #> d[2]     -0.460995 -0.17639 -0.07813  0.03093 0.3545
    #> sd        0.009663  0.08491  0.18152  0.32558 0.7365
    #>
    #>
    #> $Treat.order
    #>         1         2
    #> "Placebo"  "Statin"
    #>
    #> $deviance
    #>     Dbar       pD      DIC
    #> 42.70665 24.91847 67.62512
    #>
    #> $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.076455
    #> [1] 1.088574
    #> [1] 1.047463
    #> [1] 1.007968
    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.8829 0.1596 0.0004122       0.002508
    #> b_bl[3] -0.8829 0.1596 0.0004122       0.002508
    #> b_bl[4] -0.8829 0.1596 0.0004122       0.002508
    #> b_bl[5] -0.8829 0.1596 0.0004122       0.002508
    #> b_bl[6] -0.8829 0.1596 0.0004122       0.002508
    #> b_bl[7] -0.8829 0.1596 0.0004122       0.002508
    #> d[1]     0.0000 0.0000 0.0000000       0.000000
    #> d[2]     1.8595 0.2353 0.0006075       0.001738
    #> d[3]     2.1568 0.2076 0.0005359       0.001740
    #> d[4]     2.0727 0.4535 0.0011709       0.006111
    #> d[5]     1.6787 0.1992 0.0005144       0.001419
    #> d[6]     0.3391 0.5747 0.0014840       0.008715
    #> d[7]     2.1948 0.2740 0.0007075       0.002379
    #> sd       0.2092 0.1797 0.0004640       0.003268
    #>
    #> 2. Quantiles for each variable:
    #>
    #>             2.5%      25%     50%     75%   97.5%
    #> b_bl[1]  0.00000  0.00000  0.0000  0.0000  0.0000
    #> b_bl[2] -1.17299 -0.97609 -0.8917 -0.7992 -0.5409
    #> b_bl[3] -1.17299 -0.97609 -0.8917 -0.7992 -0.5409
    #> b_bl[4] -1.17299 -0.97609 -0.8917 -0.7992 -0.5409
    #> b_bl[5] -1.17299 -0.97609 -0.8917 -0.7992 -0.5409
    #> b_bl[6] -1.17299 -0.97609 -0.8917 -0.7992 -0.5409
    #> b_bl[7] -1.17299 -0.97609 -0.8917 -0.7992 -0.5409
    #> d[1]     0.00000  0.00000  0.0000  0.0000  0.0000
    #> d[2]     1.37976  1.74561  1.8598  1.9762  2.3234
    #> d[3]     1.77480  2.03730  2.1478  2.2662  2.5938
    #> d[4]     1.20961  1.80524  2.0608  2.3300  3.0014
    #> d[5]     1.29992  1.57164  1.6741  1.7789  2.0891
    #> d[6]    -0.84650 -0.02023  0.3565  0.7177  1.4133
    #> d[7]     1.67592  2.04439  2.1877  2.3376  2.7535
    #> sd       0.01054  0.08624  0.1670  0.2778  0.6803
    #>
    #>
    #> $Treat.order
    #>             1             2             3             4             5
    #>     "Placebo"         "CZP"  "Adalimumab"  "Etanercept"  "Infliximab"
    #>             6             7
    #>   "Rituximab" "Tocilizumab"
    #>
    #> $deviance
    #>     Dbar       pD      DIC
    #> 24.53052 20.51190 45.04241
    #>
    #> $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.007712
    #> [1] 1.003352
    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.34157 0.5802 0.0014981       0.002040
    #> d[1,3]  0.85872 0.2737 0.0007066       0.001502
    #> d[2,3] -0.05026 0.7405 0.0019119       0.003027
    #> d[1,4]  1.41827 0.8827 0.0022791       0.006852
    #> d[2,4]  0.65111 0.7351 0.0018980       0.003432
    #> d[3,4]  0.19552 0.7775 0.0020075       0.003207
    #> sd      0.92148 0.2219 0.0005729       0.002380
    #>
    #> 2. Quantiles for each variable:
    #>
    #>           2.5%      25%      50%    75% 97.5%
    #> d[1,2] -0.8062 -0.02918  0.33968 0.7111 1.501
    #> d[1,3]  0.3368  0.67976  0.85107 1.0302 1.425
    #> d[2,3] -1.5230 -0.52556 -0.04779 0.4271 1.412
    #> d[1,4] -0.2070  0.82847  1.37933 1.9609 3.275
    #> d[2,4] -0.8061  0.17965  0.64948 1.1228 2.110
    #> d[3,4] -1.3577 -0.30696  0.20362 0.7020 1.716
    #> sd      0.5794  0.76522  0.89054 1.0425 1.443
    #>
    #>
    #> $deviance
    #>     Dbar       pD      DIC
    #> 53.57804 44.96647 98.54451
    #>
    #> $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.004793
    #> [1] 1.000846

    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.001024
    #> [1] 1.001864
    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.0016841 0.03026 7.813e-05      1.863e-04
    #> d[3]         -0.1603547 0.04358 1.125e-04      3.588e-04
    #> d[4]         -0.0442588 0.04640 1.198e-04      2.422e-04
    #> d[5]         -0.1124325 0.06033 1.558e-04      4.691e-04
    #> d[6]         -0.1551090 0.07722 1.994e-04      5.723e-04
    #> d[7]         -0.4646217 0.10047 2.594e-04      5.703e-04
    #> d[8]         -0.1978226 0.22051 5.693e-04      1.272e-03
    #> d[9]          0.0037266 0.03685 9.515e-05      2.199e-04
    #> diff          1.2445111 0.42091 1.087e-03      4.067e-03
    #> direct        1.4085924 0.41636 1.075e-03      4.036e-03
    #> oneminusprob  0.0006333 0.02516 6.496e-05      8.601e-05
    #> prob          0.9993667 0.02516 6.496e-05      8.601e-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.06112 -0.02206 -0.001679  0.01875  0.057365
    #> d[3]         -0.24549 -0.18989 -0.160250 -0.13097 -0.074794
    #> d[4]         -0.13551 -0.07552 -0.044285 -0.01289  0.046531
    #> d[5]         -0.23059 -0.15303 -0.112528 -0.07177  0.006074
    #> d[6]         -0.30672 -0.20719 -0.155187 -0.10301 -0.003770
    #> d[7]         -0.66198 -0.53248 -0.464526 -0.39631 -0.269262
    #> d[8]         -0.63090 -0.34568 -0.197843 -0.04898  0.233868
    #> d[9]         -0.06808 -0.02121  0.003695  0.02851  0.076055
    #> diff          0.46209  0.95548  1.229570  1.51513  2.117237
    #> direct        0.63553  1.12252  1.394288  1.67516  2.273702
    #> 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.244511
    #>
    #> $p_value
    #> [1] 0.001266667
    #>
    #> 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.002235
    #> [1] 1.001545
    #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.7534 1.679e+00 4.335e-03      1.054e-02
    #> RR[3,1]   4.0156 4.006e+00 1.034e-02      3.096e-02
    #> RR[4,1]   1.1108 1.438e+00 3.714e-03      1.227e-02
    #> RR[5,1]   0.1915 2.526e-01 6.522e-04      1.845e-03
    #> RR[6,1]   0.3763 9.792e-01 2.528e-03      6.325e-03
    #> RR[7,1]   0.9204 1.175e+00 3.035e-03      7.845e-03
    #> RR[3,2]   8.9059 1.186e+03 3.062e+00      3.065e+00
    #> RR[4,2]   3.4289 6.031e+02 1.557e+00      1.630e+00
    #> RR[5,2]   0.1826 2.055e+00 5.306e-03      7.552e-03
    #> RR[6,2]   0.7122 2.542e+01 6.564e-02      8.145e-02
    #> RR[7,2]   1.5250 7.948e+01 2.052e-01      2.228e-01
    #> RR[4,3]  17.5095 2.483e+03 6.410e+00      1.024e+01
    #> RR[5,3]   0.8201 9.464e+01 2.444e-01      4.139e-01
    #> RR[6,3]  10.8205 2.370e+03 6.119e+00      6.256e+00
    #> RR[7,3]  23.4124 4.816e+03 1.243e+01      1.245e+01
    #> RR[5,4]   0.2433 4.323e-01 1.116e-03      1.435e-03
    #> RR[6,4]   0.7658 4.535e+01 1.171e-01      1.202e-01
    #> RR[7,4]   1.4382 2.020e+01 5.215e-02      5.306e-02
    #> RR[6,5]   2.5338 6.935e+01 1.791e-01      1.845e-01
    #> RR[7,5]   5.6435 7.306e+01 1.886e-01      2.098e-01
    #> RR[7,6] 599.3029 2.060e+05 5.319e+02      5.319e+02
    #> d[1]      0.0000 0.000e+00 0.000e+00      0.000e+00
    #> d[2]      0.3561 1.073e+00 2.771e-03      6.231e-03
    #> d[3]      1.4709 1.866e+00 4.818e-03      1.639e-02
    #> d[4]     -0.2444 1.021e+00 2.637e-03      7.569e-03
    #> d[5]     -1.9906 6.806e-01 1.757e-03      5.039e-03
    #> d[6]     -1.9902 1.481e+00 3.824e-03      9.223e-03
    #> d[7]     -0.4853 1.071e+00 2.765e-03      6.525e-03
    #> sd        0.9157 6.278e-01 1.621e-03      9.642e-03
    #>
    #> 2. Quantiles for each variable:
    #>
    #>              2.5%      25%      50%      75%   97.5%
    #> RR[2,1]  0.183375  0.85287  1.34742  2.08498  6.0152
    #> RR[3,1]  0.162299  1.31223  2.88799  5.38261 14.5393
    #> RR[4,1]  0.147854  0.47921  0.73058  1.18884  4.7139
    #> RR[5,1]  0.037471  0.10818  0.15274  0.21158  0.5605
    #> RR[6,1]  0.007693  0.06782  0.15312  0.33344  2.2020
    #> RR[7,1]  0.074545  0.39544  0.66001  1.04098  3.5640
    #> RR[3,2]  0.128385  0.94872  2.01405  4.10995 20.5052
    #> RR[4,2]  0.115399  0.35862  0.55331  0.90815  4.9047
    #> RR[5,2]  0.030299  0.08133  0.11662  0.16553  0.5214
    #> RR[6,2]  0.006389  0.05180  0.11750  0.25862  1.7893
    #> RR[7,2]  0.059369  0.29617  0.49970  0.80818  3.4154
    #> RR[4,3]  0.033820  0.13876  0.28582  0.62765  5.2436
    #> RR[5,3]  0.008401  0.02970  0.05754  0.11818  0.6824
    #> RR[6,3]  0.002391  0.02173  0.05866  0.16146  1.6617
    #> RR[7,3]  0.021058  0.11456  0.24392  0.53577  3.8046
    #> RR[5,4]  0.045021  0.14517  0.21260  0.28576  0.5910
    #> RR[6,4]  0.008991  0.09175  0.20916  0.44626  2.3167
    #> RR[7,4]  0.084873  0.51669  0.90578  1.41119  4.2481
    #> RR[6,5]  0.075440  0.48640  1.00358  2.02584 10.5760
    #> RR[7,5]  0.826065  2.91919  4.26867  6.04217 16.3203
    #> RR[7,6]  0.242366  1.88624  4.20318  9.38624 76.0451
    #> d[1]     0.000000  0.00000  0.00000  0.00000  0.0000
    #> d[2]    -1.789261 -0.17719  0.34273  0.87890  2.5755
    #> d[3]    -1.915440  0.31158  1.35466  2.50576  5.5371
    #> d[4]    -2.005063 -0.79694 -0.34691  0.19642  2.1167
    #> d[5]    -3.387234 -2.32385 -1.97734 -1.65028 -0.6339
    #> d[6]    -4.978590 -2.79761 -1.97655 -1.17875  0.9590
    #> d[7]    -2.698376 -0.99900 -0.45691  0.04523  1.6307
    #> sd       0.128291  0.50207  0.77087  1.15726  2.6075
    #>
    #>
    #> $Treat.order
    #>             1             2             3             4             5
    #>  "Adalimumab"         "CZP"  "Etanercept"  "Infliximab"     "Placebo"
    #>             6             7
    #>   "Rituximab" "Tocilizumab"
    #>
    #> $deviance
    #>     Dbar       pD      DIC
    #> 27.09097 22.62972 49.72069
    #>
    #> $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"