bayes_nmr: Fit Bayesian Network Meta-Regression Models

View source: R/BayesNMR.R

bayes_nmrR Documentation

Fit Bayesian Network Meta-Regression Models

Description

This is a function the fits the model introduced in Bayesian Network Meta-Regression Models Using Heavy-Tailed Multivariate Random Effects with Covariate-Dependent Variances. The first seven arguments are required except ZCovariate. If not provided, ZCovariate will be assigned a vector of ones, rep(1, length(Outcome)). ZCovariate is the centerpiece of the modeling of variances and the heavy-tailed random effects distribution.

Usage

bayes_nmr(
  Outcome,
  SD,
  XCovariate,
  ZCovariate,
  Treat,
  Trial,
  Npt,
  prior = list(),
  mcmc = list(),
  control = list(),
  init = list(),
  Treat_order = NULL,
  Trial_order = NULL,
  scale_x = FALSE,
  verbose = FALSE
)

Arguments

Outcome

the aggregate mean of the responses for each arm of every study.

SD

the standard deviation of the responses for each arm of every study.

XCovariate

the aggregate covariates for the fixed effects.

ZCovariate

the aggregate covariates associated with the variance of the random effects.

Treat

the treatment identifiers for trial arm. This is equivalent to the arm labels in each study. The elements within will be coerced to consecutive integers

Trial

the study/trial identifiers. The elements within will be coerced to consecutive integers.

Npt

the number of observations/participants for a unique (k,t), or each arm of every trial.

prior

(Optional) a list of hyperparameters. The hyperparameters include df, c01, c02, a4, b4, a5, and b5. df indicates the degrees of freedom whose value is 20. The hyperparameters a* and b* will take effect only if sample_df=TRUE. See control.

mcmc

(Optional) a list of MCMC specification. ndiscard is the number of burn-in iterations. nskip configures the thinning of the MCMC. For instance, if nskip=5, bayes_nmr will save the posterior sample every 5 iterations. nkeep is the size of the posterior sample. The total number of iterations will be ndiscard + nskip * nkeep.

control

(Optional) a list of parameters for the Metropolis-Hastings algorithm. lambda, phi, and Rho are sampled through the localized Metropolis algorithm. *_stepsize with the asterisk replaced with one of the names above specifies the stepsize for determining the sample evaluation points in the localized Metropolis algorithm. sample_Rho can be set to FALSE to suppress the sampling of Rho. When sample_Rho is FALSE, Rho will be fixed using the value given by the init argument, which defaults to an equicorrelation matrix of 0.5*I + 0.5*11' where 1 is the vector of ones. When sample_df is TRUE, df will be sampled.

init

(Optional) a list of initial values for the parameters to be sampled: theta, phi, sig2, and Rho.

Treat_order

(Optional) a vector of unique treatments to be used for renumbering the Treat vector. The first element will be assigned treatment zero, potentially indicating placebo. If not provided, the numbering will default to an alphabetical/numerical order.

Trial_order

(Optional) a vector unique trials. The first element will be assigned trial zero. If not provided, the numbering will default to an alphabetical/numerical order.

scale_x

(Optional) a logical variable indicating whether XCovariate should be scaled/standardized. The effect of setting this to TRUE is not limited to merely standardizing XCovariate. The following generic functions will scale the posterior sample of theta back to its original unit: plot, fitted, summary, and print. That is theta[j] <- theta[j] / sd(XCovariate[,j]).

verbose

(Optional) a logical value indicating whether to print the progress bar during the MCMC sampling.

Value

bayes_nmr returns an object of class "bayesnmr". The functions summary or print are used to obtain and print a summary of the results. The generic accessor function fitted extracts the posterior mean, posterior standard deviation, and the interval estimates of the value returned by bayes_nmr.

An object of class bayesnmr is a list containing the following components:

  • Outcome - the aggregate response used in the function call.

  • SD - the standard deviation used in the function call.

  • Npt - the number of participants for (k,t) used in the function call.

  • XCovariate - the aggregate design matrix for fixed effects used in the function call. Depending on scale_x, this may differ from the matrix provided at function call.

  • ZCovariate - the aggregate design matrix for random effects. bayes_nmr will assign rep(1, length(Outcome)) if it was not provided at function call.

  • Trial - the renumbered trial indicators. Depending on Trial_order, it may differ from the vector provided at function call.

  • Treat - the renumbered treatment indicators. Depending on Treat_order, it may differ from the vector provided at function call.

  • TrtLabels - the vector of treatment labels corresponding to the renumbered Treat. This is equivalent to Treat_order if it was given at function call.

  • TrialLabels - the vector of trial labels corresponding to the renumbered Trial. This is equivalent to Trial_order if it was given at function call.

  • K - the total number of trials.

  • nT - the total number of treatments.

  • scale_x - a Boolean indicating whether XCovariate has been scaled/standardized.

  • prior - the list of hyperparameters used in the function call.

  • control - the list of tuning parameters used for MCMC in the function call.

  • mcmctime - the elapsed time for the MCMC algorithm in the function call. This does not include all the other preprocessing and post-processing outside of MCMC.

  • mcmc - the list of MCMC specification used in the function call.

  • mcmc.draws - the list containing the MCMC draws. The posterior sample will be accessible here.

Author(s)

Daeyoung Lim, daeyoung.lim@uconn.edu

References

Li, H., Chen, M. H., Ibrahim, J. G., Kim, S., Shah, A. K., Lin, J., & Tershakovec, A. M. (2019). Bayesian inference for network meta-regression using multivariate random effects with applications to cholesterol lowering drugs. Biostatistics, 20(3), 499-516.

Li, H., Lim, D., Chen, M. H., Ibrahim, J. G., Kim, S., Shah, A. K., & Lin, J. (2021). Bayesian network meta-regression hierarchical models using heavy-tailed multivariate random effects with covariate-dependent variances. Statistics in Medicine.

See Also

bmeta_analyze for using the Formula interface

Examples

library(metapack)
data(TNM)
groupInfo <- list(c("PBO"), c("R"))
nz <- length(groupInfo)
ns <- nrow(TNM)
XCovariate <- model.matrix(~ 0 + bldlc + bhdlc + btg + age +
 white + male + bmi + potencymed + potencyhigh + durat, data = TNM)
XCovariate <- scale(XCovariate, center = TRUE, scale = FALSE)
ZCovariate <- matrix(0, ns, nz)
for (j in 1:length(groupInfo)) {
    for (i in 1:ns) {
        if (TNM$treat[i] %in% groupInfo[[j]]) {
            ZCovariate[i, j] <- 1
        }
    }
}
addz <- scale(cbind(TNM$bldlc, TNM$btg), center=TRUE, scale=TRUE)
ZCovariate <- cbind(1, ZCovariate, addz)
theta_init <- c(0.05113, -1.38866, 1.09817, -0.85855, -1.12056, -1.14133,
             -0.22435, 3.63453, -2.09322, 1.07858, 0.80566, -40.76753,
             -45.07127, -28.27232, -44.14054, -28.13203, -19.19989,
             -47.21824, -51.31234, -48.46266, -47.71443)
set.seed(2797542)
fit <- bayes_nmr(TNM$ptg, TNM$sdtg, XCovariate, ZCovariate, TNM$treat,
    TNM$trial, TNM$n, prior = list(c01 = 1.0e05, c02 = 4, df = 3),
    mcmc = list(ndiscard = 1, nskip = 1, nkeep = 1),
    init = list(theta = theta_init),
    Treat_order = c("PBO", "S", "A", "L", "R", "P", "E", "SE",
         "AE", "LE", "PE"),
    scale_x = TRUE, verbose = FALSE)

metapack documentation built on May 31, 2022, 1:05 a.m.