Learn R Programming

gemtc (version 0.1-2)

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)

Arguments

model
A object of S3 class mtc.model describing a consistency or inconsistency model
sampler
A string literal indicating which sampler to use. Allowed values are 'JAGS', 'BUGS' or 'YADAS'. Alternatively, the specific package to be used can be specified: 'rjags', 'BRugs' or 'R
n.adapt
Amount of adaptation (or tuning) iterations
n.iter
Amount of simulation iterations
thin
Thinning factor

Value

  • An object of class mtc.result. This is a list with the following elements:
  • samplesThe samples resulting from running the MCMC model
  • modelThe mtc.model used to produce the samples
  • samplerThe sampler 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 (gelman.diag, 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 from the meta package has been overridden 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 calculated rank probabilities for consistency models.

See Also

mtc.model, relative.effect, rank.probability, gelman.diag, gelman.plot

Examples

Run this code
file <- system.file("extdata/luades-thrombolytic.gemtc", package="gemtc")
network <- read.mtc.network(file)
model <- mtc.model(network, n.chain=2)

# Using BUGS or JAGS is preferred over YADAS, 
# however YADAS does not require additional dependencies.
results <- mtc.run(model, "YADAS", n.iter=10000, n.adapt=2500, thin=10)
results <- mtc.run(model, "YADAS", n.iter=1000, n.adapt=250, thin=1)
summary(results)

## Iterations = 2501:12491
## Thinning interval = 10 
## Number of chains = 2 
## Sample size per chain = 1000 
## 
## 1. Empirical mean and standard deviation for each variable,
##    plus standard error of the mean:
## 
##                   Mean      SD Naive SE Time-series SE
## d.ASPAC.AtPA -0.304820 0.18735 0.004189       0.016522
## d.ASPAC.SK   -0.052619 0.12632 0.002825       0.009398
## d.ASPAC.tPA  -0.082183 0.14001 0.003131       0.009953
## d.AtPA.Ret    0.056672 0.13778 0.003081       0.006673
## d.AtPA.SKtPA  0.182576 0.17255 0.003858       0.008097
## d.AtPA.Ten    0.003885 0.18986 0.004245       0.005752
## d.AtPA.UK    -0.010540 0.25126 0.005618       0.020747
## sd.d          0.144836 0.09832 0.002198       0.009121
## 
## 2. Quantiles for each variable:
## 
##                  2.5%      25%        50%       75%    97.5%
## d.ASPAC.AtPA -0.80131 -0.37424 -0.2633908 -0.194203 -0.02693
## d.ASPAC.SK   -0.36079 -0.10434 -0.0446136  0.021031  0.18066
## d.ASPAC.tPA  -0.41917 -0.14239 -0.0607428  0.002906  0.13709
## d.AtPA.Ret   -0.22937 -0.01136  0.0543854  0.132491  0.34123
## d.AtPA.SKtPA -0.12126  0.08231  0.1607389  0.257809  0.59299
## d.AtPA.Ten   -0.36726 -0.08907  0.0006722  0.096692  0.38692
## d.AtPA.UK    -0.50267 -0.17332 -0.0040873  0.165143  0.48285
## sd.d          0.02821  0.07322  0.1186668  0.192236  0.40152

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