nma.diag: Trace plots and convergence diagnostics for MCMC chains

View source: R/nma.diag.R

nma.diagR Documentation

Trace plots and convergence diagnostics for MCMC chains

Description

Produces trace plots and Gelman-Rubin and Geweke convergence diagnostics for the MCMC chains obtained from nma.run(). The Gelman-Rubin and Geweke diagnostics are implemented using functions from the coda package.

Usage

nma.diag(
  nma,
  trace = TRUE,
  gelman.rubin = TRUE,
  geweke = TRUE,
  params = "all",
  thin = 1,
  ncol = 1,
  nrow = 3,
  plot_prompt = TRUE,
  geweke_frac1 = 0.1,
  geweke_frac2 = 0.5
)

Arguments

nma

A BUGSnetRun object produced by nma.run()

trace

If TRUE, outputs trace plots. Default is TRUE.

gelman.rubin

If TRUE, runs Gelman-Rubin diagnostic. Default is TRUE.

geweke

If TRUE, runs Geweke diagnostic. Default is TRUE.

params

Integer or character vector which specifies which parameters to produce trace plots for when trace is set to TRUE. Default is "all" which plots every monitored parameter.

thin

Thinning factor for the mcmc chains when producing trace plots. Default is 1.

ncol

Number of columns in each batch of trace plots

nrow

Number rows in each batch of trace plots

plot_prompt

If TRUE, prompts the user to hit enter before plotting each additional batch of trace plots. Default is TRUE.

geweke_frac1

Fraction to use from beginning of chain. Default is 0.1.

geweke_frac2

Fraction to use from end of chain. Default is 0.5.

Value

gelman.rubin An object of class gelman.rubin.results containing the Gelman-Rubin diagnostic results. A formatted table with custom PSRF threshold can be printed using print(x, gelman.rubin.threshold = 1.2).

geweke An object of class geweke.results containing the Geweke diagnostic results. A formatted table with custom significance level can be printed using print(x, alpha = 0.05).

See Also

nma.run

Examples

data(thrombolytic)
dich.slr <- data.prep(arm.data = thrombolytic, varname.t = "treatment", 
                      varname.s = "study")
random_effects_model <- nma.model(data=dich.slr, outcome="events", 
                                  N="sampleSize", reference="SK",
                                  family="binomial", link="log", 
                                  effects="random")
random_effects_results <- nma.run(random_effects_model, n.adapt=100, 
                                  n.burnin=0, n.iter=100)
nma.diag(random_effects_results)

audrey-b/BUGSnet documentation built on Feb. 2, 2025, 5:10 p.m.