Learn R Programming

gemtc (version 0.7-1)

mtc.run: Running an mtc.model using an MCMC sampler

Description

The function mtc.run is used to generate samples from a object of type mtc.model using a MCMC sampler. The resulting mtc.results object can be coerced to an mcmc.list for further analysis of the dataset using the coda package.

Usage

mtc.run(model, sampler = NA, n.adapt = 5000, n.iter = 20000, thin = 1)

## S3 method for class 'mtc.result': summary(object, ...) ## S3 method for class 'mtc.result': plot(x, ...) ## S3 method for class 'mtc.result': forest(x, use.description=FALSE, ...) ## S3 method for class 'mtc.result': print(x, ...) ## S3 method for class 'mtc.result': as.mcmc.list(x, ...)

Arguments

model
An object of S3 class mtc.model describing a network meta-analysis model.
sampler
A string literal indicating which sampler to use. Allowed values are 'JAGS' or 'BUGS'. Alternatively, the specific package to be used can be specified: 'rjags', 'BRugs' or 'R2WinBUGS'. When
n.adapt
Amount of adaptation (or tuning) iterations.
n.iter
Amount of simulation iterations.
thin
Thinning factor.
object
Object of S3 class mtc.result.
x
Object of S3 class mtc.result.
use.description
Display treatment descriptions instead of treatment IDs.
...
Additional arguments.

Value

  • An object of class mtc.result. This is a list with the following elements:
  • samplesThe samples resulting from running the MCMC model, in mcmc.list format.
  • modelThe mtc.model used to produce the samples.
  • samplerThe sampler (R package) used to produce the samples.
  • The object can be coerced to an mcmc.list from the coda package by the generic S3 method as.mcmc.list.

encoding

utf8

Analysis of the results

Convergence of the model can be assessed using methods from the coda package. For example the Brooks-Gelman-Rubin method (coda::gelman.diag, coda::gelman.plot). The summary also provides useful information, such as the MCMC error and the time series and densities given by plot should also be inspected.

The forest function can provide forest plots for mtc.result objects. This is especially useful in combination with the relative.effect function that can be used to calculate relative effects compared to any baseline for consistency models. The rank.probability function calculates rank probabilities for consistency models.

See Also

mtc.model

relative.effect.table, relative.effect, rank.probability

coda::gelman.diag, coda::gelman.plot

Examples

Run this code
model <- mtc.model(smoking)

results <- mtc.run(model, thin=10)
results <- dget(system.file("extdata/luades-smoking.samples.gz", package="gemtc"))

# Convergence diagnostics
gelman.plot(results)

# Posterior summaries
summary(results)
## Iterations = 5010:25000
## Thinning interval = 10 
## Number of chains = 4 
## Sample size per chain = 2000 
## 
## 1. Empirical mean and standard deviation for each variable,
##    plus standard error of the mean:
## 
##         Mean     SD Naive SE Time-series SE
## d.A.B 0.4965 0.4081 0.004563       0.004989
## d.A.C 0.8359 0.2433 0.002720       0.003147
## d.A.D 1.1088 0.4355 0.004869       0.005280
## sd.d  0.8465 0.1913 0.002139       0.002965
## 
## 2. Quantiles for each variable:
## 
##          2.5%    25%    50%    75% 97.5%
## d.A.B -0.2985 0.2312 0.4910 0.7530 1.341
## d.A.C  0.3878 0.6720 0.8273 0.9867 1.353
## d.A.D  0.2692 0.8197 1.0983 1.3824 2.006
## sd.d   0.5509 0.7119 0.8180 0.9542 1.283

plot(results) # Shows time-series and density plots of the samples
forest(results) # Shows a forest plot

Run the code above in your browser using DataLab