#' @title Run multivariate network meta-analysis (NMA) anlaysis
#' @description The function conducts bivariate NMA using a \code{mnma.model} object as an input. It uses \bold{OpenBUGS} software (through the \code{R2OpenBUGS} package).
#' @param input \code{mnma.model} class data, which can be generated using \code{mnma.model} function
#' @param inits a list of initial values for \bold{OpenBUGS} model with \code{n.chains} elements; If \code{inits=NULL} (default), initial values are randomly generated by \bold{OpenBUGS}.
#' @param n.iter number of total iterations per chain (default: 5000)
#' @param n.burnin length of burnin per chain (default: 2000)
#' @param n.chains number of Markov chains (default: 1)
#' @param n.thin thining rate (default: 1)
#' @param debug if FALSE (default), \strong{OpenBUGS} is closed automatically after running the \code{mnma.run} script. If TRUE, \strong{OpenBUGS} remains open with additional information.
#' @param codaPkg if FALSE (default), a \code{bugs} object is returned. Otherwise, file names of \strong{OpenBUGS} output are returned with TRUE.
#' @import R2OpenBUGS
#' @export
#' @references Efthimiou et al. (2015) Biostatistics 16(1):84-97
#' (\href{https://academic.oup.com/biostatistics/article/16/1/84/258780}{doi: 10.1093/biostatistics/kxu030})
#' @seealso \code{\link[R2OpenBUGS]{bugs}}
#' @return \code{mnma.result} class \code{bugs} result. See \code{\link[R2OpenBUGS]{bugs}} for details.
#' @examples \dontrun{
#' # Run after data transformation using mnma.model function.
#' res <- mnma.run(data, n.iter=3000, n.burnin=1000)
#' names(res)
#' # provides mean, standard deviation, and percentile information about log odds ratio
#' res$summary
#' }
#'
#'
mnma.run <- function(input, inits=NULL, n.iter=5000, n.burnin=2000, n.chains=1, n.thin=1, debug=FALSE, codaPkg=FALSE){
input <- input$multivariate
if (input$noa=="3arm"){
models = model.file = system.file("bnma_3arm.txt",package="mnma") # Fix the location
} else if (input$noa=="2arm"){
models = model.file = system.file("bnma_2arm.txt",package="mnma") # Fix the location
}
if ( class(input) == "mnma.model"){
data <- as.list(input$data)
out.mul <- bugs(data=data,
inits=inits,
parameters.to.save= input$parameters,
n.iter=n.iter,
n.burnin=n.burnin,
n.thin=n.thin,
n.chains=n.chains,
model.file = models,
debug=debug,
codaPkg=codaPkg,
DIC = FALSE # To have the results, we need to set this off.
)
class(out.mul) <- "mnma.result"
}else{
stop("Input data have to be 'mnma.model' class ")
}
return(out.mul)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.