multinma (version 0.1.3)

mcmc_array-class: Working with 3D MCMC arrays

Description

3D MCMC arrays (Iterations, Chains, Parameters) are produced by as.array() methods applied to stan_nma or nma_summary objects.

Usage

# S3 method for mcmc_array
summary(object, ..., probs = c(0.025, 0.25, 0.5, 0.75, 0.975))

# S3 method for mcmc_array print(x, ...)

# S3 method for mcmc_array names(x)

# S3 method for mcmc_array names(x) <- value

Arguments

...

Further arguments passed to other methods

probs

Numeric vector of quantiles of interest

x, object

A 3D MCMC array of class mcmc_array

value

Character vector of replacement parameter names

Value

The summary() method returns a nma_summary object, the print() method returns x invisibly. The names() method returns a character vector of parameter names, and names()<- returns the object with updated parameter names.

Examples

Run this code
# NOT RUN {
## Smoking cessation
# Set up network of smoking cessation data
head(smoking)

smk_net <- set_agd_arm(smoking,
                       study = studyn,
                       trt = trtc,
                       r = r,
                       n = n,
                       trt_ref = "No intervention")

# Print details
smk_net

# }
# NOT RUN {
# Fitting a random effects model
smk_fit_RE <- nma(smk_net,
                  trt_effects = "random",
                  prior_intercept = normal(scale = 100),
                  prior_trt = normal(scale = 100),
                  prior_het = normal(scale = 5))

smk_fit_RE
# }
# NOT RUN {
# }
# NOT RUN {
# Working with arrays of posterior draws (as mcmc_array objects) is
# convenient when transforming parameters

# Transforming log odds ratios to odds ratios
LOR_array <- as.array(relative_effects(smk_fit_RE))
OR_array <- exp(LOR_array)

# mcmc_array objects can be summarised to produce a nma_summary object
smk_OR_RE <- summary(OR_array)

# This can then be printed or plotted
smk_OR_RE
plot(smk_OR_RE, ref_line = 1)

# Transforming heterogeneity SD to variance
tau_array <- as.array(smk_fit_RE, pars = "tau")
tausq_array <- tau_array^2

# Correct parameter names
names(tausq_array) <- "tausq"

# Summarise
summary(tausq_array)
# }

Run the code above in your browser using DataLab