multinma (version 0.1.3)

plot_prior_posterior: Plot prior vs posterior distribution

Description

Produce plots comparing the prior and posterior distributions of model parameters.

Usage

plot_prior_posterior(
  x,
  ...,
  prior = NULL,
  post_args = list(),
  prior_args = list(),
  overlay = c("prior", "posterior"),
  ref_line = NA_real_
)

Arguments

x

A stan_nma object

...

Additional arguments passed on to methods

prior

Character vector selecting the prior and posterior distribution(s) to plot. May include "intercept", "trt", "het", "reg", or "aux", as appropriate.

post_args

List of arguments passed on to ggplot2::geom_histogram to control plot output for the posterior distribution

prior_args

List of arguments passed on to ggplot2::geom_path to control plot output for the prior distribution. Additionally, n controls the number of points the density curve is evaluated at (default 500), and p_limits controls the endpoints of the curve as quantiles (default c(.001, .999)).

overlay

String, should prior or posterior be shown on top? Default "prior".

ref_line

Numeric vector of positions for reference lines, by default no reference lines are drawn

Value

A ggplot object.

Details

Prior distributions are displayed as lines, posterior distributions are displayed as histograms.

Examples

Run this code
# NOT RUN {
## Smoking cessation NMA
# 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 {
# Plot prior vs. posterior, by default all parameters are plotted
plot_prior_posterior(smk_fit_RE)

# Plot prior vs. posterior for heterogeneity SD only
plot_prior_posterior(smk_fit_RE, prior = "het")

# Customise plot
plot_prior_posterior(smk_fit_RE, prior = "het",
                     prior_args = list(colour = "darkred", size = 2),
                     post_args = list(alpha = 0.6))
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace