This function fits a Bayesian RaCE-NMA model to data from a previous network meta-analysis. The function has input parameters to permit drawing multiple MCMC chains, as well as chain thinning and burn-in. Chains are independent and may be drawn in parallel across multiple CPU cores via the cores argument.

mcmc_raceNMA(
  posterior = NULL,
  mu_hat = NULL,
  cov = NULL,
  s = NULL,
  mu0 = NULL,
  sigma0 = NULL,
  tau = NULL,
  nu0 = NULL,
  iter = 4000,
  nu_iter = 5,
  chains = 2,
  burn_prop = 0.5,
  thin = 1,
  seed = NULL,
  cores = 1,
  verbose = TRUE
)

Arguments

posterior

A matrix of posterior draws of relative intervention effects based on a previous NMA. The (i,j) is the ith draw of the effect of intervention j.

mu_hat

A vector of estimated average relative intervention effects based on a previous NMA. The jth entry is the effect of intervention j. Ignored if posterior is supplied.

cov

A variance covariance matrix of relative intervention effects based on a previous NMA. The (i,j) entry is the covariance between intervention i and j's effects. Ignored if posterior is supplied.

s

A vector of the estimated standard deviations of each intervention. The jth entry is the standard deviation of intervention j. Ignored if posterior is supplied.

mu0

The hyperparameter mu0. If NULL, set to mean(mu_hat).

sigma0

The hyperparameter sigma_0. If NULL, set to sqrt(10*var(mu_hat)) which aims to be minimally informative.

tau

The standard deviation of the Metropolis Hastings proposal distribution. If NULL, set to min(|mu_hat_i-mu_hat_j|).

nu0

A numeric vector for the initialization of worth parameters, mu, in the MCMC algorithm. Default to NULL, indicating random initialization.

iter

A numeric indicating the total number of outer MCMC iterations (i.e., the number of times the partition is updated in the Gibbs sampler).

nu_iter

A numeric indicating the number of times each worth parameter is drawn per update of the parameter partition. There will be a total of iterxnu_iter samples from the posterior.

chains

A numeric indicating the total number of independent MCMC chains to be run.

burn_prop

A numeric between 0 and 1 indicating the proportion of MCMC samples in each chain to be removed as burn-in.

thin

A numeric indicating that only every thin-th sample should be retained, to save computational memory.

seed

A numeric indicating the random seed used to generate the per-chain random number streams.

cores

A numeric indicating how many CPU cores to use when drawing chains. The default, 1, draws chains sequentially. Values above 1 draw chains in parallel; cores is silently capped at chains. Results do not depend on cores.

verbose

A boolean indicating if the function should print progress updates as the MCMC chains run. Default to TRUE.

Value

A (chainsxiter/thin)x(3J+3) matrix of posterior draws, one row per posterior sample of mu, nu, and g, with additional columns indicating the MCMC chain index, iteration index, and number of non-empty partition clusters K of each posterior sample.

Details

Each chain is assigned its own L'Ecuyer-CMRG random number stream, derived deterministically from seed. Chain i therefore produces the same draws whether it was run sequentially or on a parallel worker, so cores affects only run time.

Examples

mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1)
#> Estimating chain 1 of 2.
#> Estimating chain 2 of 2.
head(mcmc)
#>   chain iteration K          mu1          mu2       mu3       mu4          nu1
#> 1     1     10001 2  0.075197682  0.075197682 0.9385154 0.9385154  0.075197682
#> 2     1     10002 2  0.018772248  0.018772248 0.9385450 0.9385450  0.018772248
#> 3     1     10003 2  0.008448015  0.008448015 1.0139063 1.0139063  0.008448015
#> 4     1     10004 2 -0.068008085 -0.068008085 1.0373898 1.0373898 -0.068008085
#> 5     1     10005 2 -0.003893541 -0.003893541 1.0908622 1.0908622 -0.003893541
#> 6     1     10006 2 -0.076898554 -0.076898554 1.0297054 1.0297054 -0.076898554
#>         nu2 nu3 nu4 G1 G2 G3 G4
#> 1 0.9385154  NA  NA  1  1  2  2
#> 2 0.9385450  NA  NA  1  1  2  2
#> 3 1.0139063  NA  NA  1  1  2  2
#> 4 1.0373898  NA  NA  1  1  2  2
#> 5 1.0908622  NA  NA  1  1  2  2
#> 6 1.0297054  NA  NA  1  1  2  2