Skip to contents

Borrowing from the approach in the heemod package, as well as defining the analysis in an R script it is also possible to specify the analysis with only file inputs. This vignette will show how to do this with a simple example.

Introduction

The idea is to create folder with all of the information needed to run the NMA analysis contained in files within. The meta information about the contents of the folder is contained in a reference file. The reference file is called REFERENCE.csv.

Reference file

This file contains two columns called type and file. Rows in the type column must contain one of the following keywords:

  • bugs: File containing the BUGS input parameters for MCMC
  • analysis: File containing the scenario information
  • subData: Mandatory NMA data. Required column headings of tx, base, study, Lmean, Lse, multi_arm
  • survDataBin: Optional binary data. Required column headings of tx, base, study, BinN, BinR
  • survDataMed: Optional median time data. Required column headings of tx, base, study, medN, medR, median
type file
bugs bugs.csv
analysis analysis.csv
subData subData.csv

Parameter files

bugs.csv includes: OpenBUGS or WinBUGS option PROG, N.BURNIN, N.SIMS, N.CHAINS, N.THIN, PAUSE. For example,

PROG, openBugs
N.BURNIN, 1000
N.SIMS, 1500
N.CHAINS, 2
N.THIN, 1
PAUSE, TRUE

and analysis.csv includes: whether a random effects model, is_random; the type of survival data, data_typethe reference treatment, REFTX; effectParam, label and endpoint. For example,

is_random, FALSE
data_type, hr_data
refTx, X
effectParam, beta
label, my_label
endpoint, my_endpoint

Running an NMA

A single call sets-up the NMA represented by the contents of the folder.

nma_model <- new_NMA_dir(data_dir = here::here("inst/analysis_folder_test"))

Run MCMC

The NMA MCMC function calls the appropriate BUGS model in the usual way.

nma_res <- NMA_run(nma_model, save = FALSE)
#> ====== RUNNING BUGS MODEL

nma_res
#> Inference for Bugs model at "C:\Users\n8tha\AppData\Local\Temp\Rtmp0UB0w3/bugs_model.txt", 
#>  2 chains, each with 2500 iterations (first 1000 discarded)
#>  n.sims = 3000 iterations saved
#>          mean  sd 2.5%  25%  50%  75% 97.5% Rhat n.eff
#> beta[2]  -0.2 0.1 -0.4 -0.2 -0.2 -0.1   0.1    1  1200
#> beta[3]  -0.4 0.1 -0.7 -0.5 -0.4 -0.3  -0.2    1  2300
#> totLdev  37.0 2.1 35.0 35.6 36.4 37.8  42.7    1  3000
#> deviance 31.0 2.1 29.1 29.6 30.4 31.8  36.8    1  3000
#> 
#> For each parameter, n.eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor (at convergence, Rhat=1).
#> 
#> DIC info (using the rule, pD = Dbar-Dhat)
#> pD = 2.0 and DIC = 33.1
#> DIC is an estimate of expected predictive error (lower deviance is better).