| Title: | Rank-Clustered Estimation for Network Meta-Analysis |
|---|---|
| Description: | An implementation of the RaCE-NMA (Rank-Clustered Estimation for Network Meta-Analysis) model for post-hoc clustering of treatments or interventions by rank in network meta-analysis data. Functions for model estimation, assessment, and displaying results are provided. For more details, see Pearce and Zhou (2025) <doi:10.1017/rsm.2025.10049>. |
| Authors: | Michael Pearce [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-9313-271X>), Shouhao Zhou [aut] (ORCID: <https://orcid.org/0000-0002-8124-5047>) |
| Maintainer: | Michael Pearce <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.3 |
| Built: | 2026-06-03 14:56:38 UTC |
| Source: | https://github.com/pearce790/race.nma |
This function applies MCMC outputs from the mcmc_RCMVN package to the gelman.diag function in the coda package.
calculate_Rhat(mcmc, names = NULL, level = 0.95, multivariate = FALSE)calculate_Rhat(mcmc, names = NULL, level = 0.95, multivariate = FALSE)
mcmc |
MCMC draws from the RaCE NMA model, in the form of the model output of the |
names |
A vector of intervention names (optional) |
level |
The |
multivariate |
The |
Gelman diagnostics for the inputted MCMC chains, in the format of the output of the gelman.diag function in the coda package.
mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) calculate_Rhat(mcmc,names=paste0("Treatment ",1:4))mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) calculate_Rhat(mcmc,names=paste0("Treatment ",1:4))
This function creates a results table of SUCRA and Median Number of Better Treatments (MNBT) based on MCMC draws from a standard NMA model or a fitted RaCE-NMA model.
calculate_SUCRA_MNBT(data = NULL, mcmc = NULL, level = 0.5, names = NULL)calculate_SUCRA_MNBT(data = NULL, mcmc = NULL, level = 0.5, names = NULL)
data |
A NxJ matrix of data, where N is the number of observations and J the number of treatments. This feature is designed to display results from a standard NMA study. |
mcmc |
MCMC draws from the RaCE NMA model, in the form of the model output of the |
level |
The |
names |
A vector of intervention names (optional) |
A table containing SUCRA and MNBT values for each treatment, ordered by descending SUCRA values.
mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) calculate_SUCRA_MNBT(mcmc=mcmc)mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) calculate_SUCRA_MNBT(mcmc=mcmc)
This function creates a posterior clustering matrix for the interventions in the form of a ggplot.
clusterplot_ranks(data = NULL, mcmc = NULL, names = NULL, label_ranks = NULL)clusterplot_ranks(data = NULL, mcmc = NULL, names = NULL, label_ranks = NULL)
data |
A NxJ matrix of data, where N is the number of observations and J the number of treatments. This feature is designed to display results from a standard NMA study. |
mcmc |
MCMC draws from the RaCE NMA model, in the form of the model output of the |
names |
A vector of intervention names (optional) |
label_ranks |
A vector containing rank levels for which posterior rank probabilities should be displayed within the clustering matrix. Only non-zero probabilities are displayed. Defaults to |
A ggplot of a posterior clustering matrix for the interventions.
data("toy_data") mcmc <- mcmc_raceNMA(posterior=toy_data,iter=500,nu_iter=2,chains=1) clusterplot_ranks(mcmc=mcmc,names=paste0("Treatment ",1:10),label_ranks=1:3)data("toy_data") mcmc <- mcmc_raceNMA(posterior=toy_data,iter=500,nu_iter=2,chains=1) clusterplot_ranks(mcmc=mcmc,names=paste0("Treatment ",1:10),label_ranks=1:3)
This function creates a cumulative ranking plot in the form of a ggplot.
cumulativeprobplot_ranks(data = NULL, mcmc = NULL, names = NULL)cumulativeprobplot_ranks(data = NULL, mcmc = NULL, names = NULL)
data |
A NxJ matrix of data, where N is the number of observations and J the number of treatments. This feature is designed to display results from a standard NMA study. |
mcmc |
MCMC draws from the RaCE NMA model, in the form of the model output of the |
names |
A vector of intervention names (optional) |
A ggplot of a cumulative ranking plot.
mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) cumulativeprobplot_ranks(mcmc=mcmc,names=paste0("Treatment ",1:4))mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) cumulativeprobplot_ranks(mcmc=mcmc,names=paste0("Treatment ",1:4))
This function fits a Bayesian RaCE-NMA model to data from a previous network meta-analysis.
fit_raceNMA( posterior = NULL, mu_hat = NULL, cov = NULL, s = NULL, mu0 = NULL, sigma0 = NULL, tau, nu0, iter, nu_iter )fit_raceNMA( posterior = NULL, mu_hat = NULL, cov = NULL, s = NULL, mu0 = NULL, sigma0 = NULL, tau, nu0, iter, nu_iter )
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 |
cov |
A variance covariance matrix of relative intervention effects based on a previous NMA. The (i,j) entry is the covariane between intervention i and j's effects. Ignored if |
s |
A vector of the estimated standard deviations of each intervention. The jth entry is the standard deviation of intervention j. Ignored if |
mu0 |
The hyperparameter mu0. If |
sigma0 |
The hyperparameter sigma_0. If |
tau |
The standard deviation of the Metropolis Hastings proposal distribution. If |
nu0 |
A numeric vector for the initialization of worth parameters, mu, in the MCMC algorithm. Default to |
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 |
A list of 4 elements: mu, a (iterxnu_iter)xJ matrix of approximate posterior draws of the intervention-specific worth parameters, mu; nu a (iterxnu_iter)xJ matrix of the unique parameter values corresponding to the jth partition cluster in posterior draw i, g a a (iterxnu_iter)xJ matrix indicating the cluster membership of object j in posterior draw i, and K a vector of the number of non-empty partition clusters in each posterior draw.
fit_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), mu0=0.5, sigma0=5, tau=0.5, nu0 = NULL, iter = 5000, nu_iter = 2)fit_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), mu0=0.5, sigma0=5, tau=0.5, nu0 = NULL, iter = 5000, nu_iter = 2)
This function creates posterior forest plots for relative treatment effect estimates from a standard or RaCE NMA study.
forestplot_muhat( data = NULL, mcmc = NULL, names = NULL, level = 0.95, order_by_average = TRUE )forestplot_muhat( data = NULL, mcmc = NULL, names = NULL, level = 0.95, order_by_average = TRUE )
data |
A NxJ matrix of data to display as a forest plot, where N is the number of observations and J the number of treatments. This feature is designed for use to display a forest plot of results from a standard NMA study. |
mcmc |
MCMC draws from the RaCE NMA model, in the form of the model output of the |
names |
A vector of intervention names (optional) |
level |
A numeric indicating the desired credible level to be displayed, as a proportion. Defaults to 0.95. |
order_by_average |
A boolean indicating if plot should order treatments by their average treatment effect. |
A ggplot of posterior forest plots for the mu parameter.
data("toy_data") forestplot_muhat(data=toy_data,names=paste0("Treatment ",1:4))data("toy_data") forestplot_muhat(data=toy_data,names=paste0("Treatment ",1:4))
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.
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, verbose = TRUE )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, verbose = TRUE )
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 |
cov |
A variance covariance matrix of relative intervention effects based on a previous NMA. The (i,j) entry is the covariane between intervention i and j's effects. Ignored if |
s |
A vector of the estimated standard deviations of each intervention. The jth entry is the standard deviation of intervention j. Ignored if |
mu0 |
The hyperparameter mu0. If |
sigma0 |
The hyperparameter sigma_0. If |
tau |
The standard deviation of the Metropolis Hastings proposal distribution. If |
nu0 |
A numeric vector for the initialization of worth parameters, mu, in the MCMC algorithm. Default to |
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 |
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 |
seed |
A numeric indicating the random seed that should be set before running the first MCMC chain. |
verbose |
A boolean indicating if the function should print progress updates as the MCMC chains run. Default to |
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.
mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) head(mcmc)mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) head(mcmc)
This function implements a reversible jump MCMC procedure for updating the parameter partition in Bayesian Rank-Clustered Estimation for Network Meta-Analysis models in the case when we assume correlation among treatment effects. For internal use only.
sample_partition_correlation( mu_hat, J, nu, g, K, mu0, sigma0, cov, tau = tau, b_g = 0.5, d_g = 0.5 )sample_partition_correlation( mu_hat, J, nu, g, K, mu0, sigma0, cov, tau = tau, b_g = 0.5, d_g = 0.5 )
mu_hat |
A vector of estimated average relative intervention effects based on a previous NMA. The jth entry is the effect of intervention j. |
J |
A numeric indicating the total number of interventions being compared. |
nu |
A vector indicating current values for nu in the Gibbs sampler. |
g |
A vector indicating current values for g in the Gibbs sampler. |
K |
A vector indicating current values for K in the Gibbs sampler. |
mu0 |
The hyperparameter mu0, usually specified as the grand mean of the average intervention effects. |
sigma0 |
The hyperparameter sigma_0, usually a large number as to be minimally informative. |
cov |
A variance covariance matrix of relative intervention effects based on a previous NMA. The (i,j) entry is the covariane between intervention i and j's effects. |
tau |
The standard deviation of the Metropolis Hastings proposal distribution. |
b_g |
The probability of "birth"ing a new partition cluster, if possible. Default is 0.5. |
d_g |
The probability of "death"ing an existing partition cluster, if possible. Default is 0.5. |
A list containing updated values for g, nu, and K.
sample_partition_correlation(mu_hat=c(1,1,1),J=3,nu=1,g=c(1,1,1),K=1,mu0=1,sigma0=1,tau=0.1)sample_partition_correlation(mu_hat=c(1,1,1),J=3,nu=1,g=c(1,1,1),K=1,mu0=1,sigma0=1,tau=0.1)
This function implements a reversible jump MCMC procedure for updating the parameter partition in Bayesian Rank-Clustered Estimation for Network Meta-Analysis models in the case when we assume independence between treatment effects. For internal use only.
sample_partition_independence( mu_hat, J, nu, g, K, mu0, sigma0, s, tau = tau, b_g = 0.5, d_g = 0.5 )sample_partition_independence( mu_hat, J, nu, g, K, mu0, sigma0, s, tau = tau, b_g = 0.5, d_g = 0.5 )
mu_hat |
A vector of estimated average relative intervention effects based on a previous NMA. The jth entry is the effect of intervention j. |
J |
A numeric indicating the total number of interventions being compared. |
nu |
A vector indicating current values for nu in the Gibbs sampler. |
g |
A vector indicating current values for g in the Gibbs sampler. |
K |
A vector indicating current values for K in the Gibbs sampler. |
mu0 |
The hyperparameter mu0, usually specified as the grand mean of the average intervention effects. |
sigma0 |
The hyperparameter sigma_0, usually a large number as to be minimally informative. |
s |
A vector of the estimated standard deviations of each intervention. The jth entry is the standard deviation of intervention j. |
tau |
The standard deviation of the Metropolis Hastings proposal distribution. |
b_g |
The probability of "birth"ing a new partition cluster, if possible. Default is 0.5. |
d_g |
The probability of "death"ing an existing partition cluster, if possible. Default is 0.5. |
A list containing updated values for g, nu, and K.
sample_partition_independence(mu_hat=c(1,1,1),J=3,nu=1,g=c(1,1,1), K=1,mu0=1,sigma0=1,s=c(1,1,1),tau=0.1)sample_partition_independence(mu_hat=c(1,1,1),J=3,nu=1,g=c(1,1,1), K=1,mu0=1,sigma0=1,s=c(1,1,1),tau=0.1)
The dataset includes relative treatment effects for 4 treatments across 10k posterior draws, as studied in Simulation Study 2 of Pearce and Zhou (2025).
toy_datatoy_data
data.frame in which the (i,j) entry is the relative treatment effect of treatment j in posterior draw i.
This function creates trace plots for the K parameter in the form of a ggplot.
traceplot_K(mcmc)traceplot_K(mcmc)
mcmc |
MCMC draws from the RaCE NMA model, in the form of the model output of the |
A ggplot of trace plots for the K parameter.
mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) traceplot_K(mcmc)mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) traceplot_K(mcmc)
This function creates trace plots for the mu parameter in the form of a ggplot.
traceplot_mu(mcmc, names = NULL)traceplot_mu(mcmc, names = NULL)
mcmc |
MCMC draws from the RaCE NMA model, in the form of the model output of the |
names |
A vector of intervention names (optional) |
A ggplot of trace plots for the mu parameter.
mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) traceplot_mu(mcmc,names=paste0("Treatment ",1:4))mcmc <- mcmc_raceNMA(mu_hat=c(0,0,1,1), s=c(.1,.1,.1,.1), seed=1) traceplot_mu(mcmc,names=paste0("Treatment ",1:4))
The dataset includes relative treatment effects for 10 non-baseline treatments across 60k posterior draws based on an NMA study by Wang et. al (2022).
wang_posteriorwang_posterior
data.frame in which the (i,j) entry is the relative treatment effect of treatment j in posterior draw i.