diff --git a/.gitignore b/.gitignore index 368dbcfe..f9df55b6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ gemtc.Rcheck *.swp gemtc_*.tar.gz *.so -*.o +*.o \ No newline at end of file diff --git a/gemtc/DESCRIPTION b/gemtc/DESCRIPTION index a58d8b89..65c4d3fb 100644 --- a/gemtc/DESCRIPTION +++ b/gemtc/DESCRIPTION @@ -1,5 +1,5 @@ Package: gemtc -Version: 1.0-2 +Version: 1.0-2.9000 Date: 2023-06-21 Title: Network Meta-Analysis Using Bayesian Methods Author: Gert van Valkenhoef, Joel Kuiper diff --git a/gemtc/NEWS.md b/gemtc/NEWS.md index 9eb9f9c1..71c42115 100644 --- a/gemtc/NEWS.md +++ b/gemtc/NEWS.md @@ -1,3 +1,10 @@ +gemtc 1.0-2.9000 +=========== + +Released 2024-XX-XX + +* Add addtional n.burnin argument to the mtc.run and mtc.sample. The update is connected with the fact that the nadapt is not equal to nburnin. + gemtc 1.0-2 =========== diff --git a/gemtc/R/mtc.run.R b/gemtc/R/mtc.run.R index b88564bd..fbed115e 100644 --- a/gemtc/R/mtc.run.R +++ b/gemtc/R/mtc.run.R @@ -19,7 +19,8 @@ mtc.model.run <- function(network, type, ...) { # If is.na(sampler), a sampler will be chosen based on availability, in this order: # JAGS, BUGS. When the sampler is BUGS, BRugs or R2WinBUGS will be used. -mtc.run <- function(model, sampler=NA, n.adapt=5000, n.iter=20000, thin=1) { +mtc.run <- function(model, sampler=NA, n.adapt=5000, n.iter=20000, thin=1, n.burnin=0) { + if (!is.na(sampler)) { if (sampler %in% c("JAGS", "rjags")) { warning("Setting the sampler is deprecated.") @@ -28,7 +29,7 @@ mtc.run <- function(model, sampler=NA, n.adapt=5000, n.iter=20000, thin=1) { } } - result <- mtc.sample(model, n.adapt=n.adapt, n.iter=n.iter, thin=thin) + result <- mtc.sample(model, n.adapt=n.adapt, n.iter=n.iter, thin=thin, n.burnin=n.burnin) result <- c(result, list(model = model)) class(result) <- "mtc.result" @@ -44,7 +45,7 @@ mtc.build.syntaxModel <- function(model) { ) } -mtc.sample <- function(model, n.adapt=n.adapt, n.iter=n.iter, thin=thin) { +mtc.sample <- function(model, n.adapt, n.iter, thin, n.burnin) { # generate JAGS model syntax <- mtc.build.syntaxModel(model) @@ -64,6 +65,9 @@ mtc.sample <- function(model, n.adapt=n.adapt, n.iter=n.iter, thin=thin) { inits=syntax[['inits']], n.chains=model[['n.chain']], n.adapt=n.adapt) + + if (n.burnin > 0) update(jags, n.iter=n.burnin) + samples <- rjags::coda.samples(jags, variable.names=vars, n.iter=n.iter, thin=thin) unlink(file.model) diff --git a/gemtc/man/mtc.run.Rd b/gemtc/man/mtc.run.Rd index bf767a1e..26caf0d1 100644 --- a/gemtc/man/mtc.run.Rd +++ b/gemtc/man/mtc.run.Rd @@ -14,7 +14,7 @@ The function \code{mtc.run} is used to generate samples from a object of type \c The resulting \code{mtc.result} object can be coerced to an \code{mcmc.list} for further analysis of the dataset using the \code{coda} package. } \usage{ -mtc.run(model, sampler = NA, n.adapt = 5000, n.iter = 20000, thin = 1) +mtc.run(model, sampler = NA, n.adapt = 5000, n.iter = 20000, thin = 1, n.burnin = 0) \method{summary}{mtc.result}(object, ...) \method{plot}{mtc.result}(x, ...) @@ -28,6 +28,7 @@ mtc.run(model, sampler = NA, n.adapt = 5000, n.iter = 20000, thin = 1) \item{n.adapt}{Amount of adaptation (or tuning) iterations.} \item{n.iter}{Amount of simulation iterations.} \item{thin}{Thinning factor.} + \item{n.burnin}{Amount of burn-in iterations. Has to be positive number.} \item{object}{Object of S3 class \code{mtc.result}.} \item{x}{Object of S3 class \code{mtc.result}.}