devplot: Plot deviance contributions from an MBNMA model

Description Usage Arguments Details Value Examples

View source: R/plot.functions.R

Description

Plot deviance contributions from an MBNMA model

Usage

1
2
3
4
5
6
7
8
9
devplot(
  mbnma,
  plot.type = "scatter",
  facet = TRUE,
  dev.type = "resdev",
  n.iter = mbnma$BUGSoutput$n.iter,
  n.thin = mbnma$BUGSoutput$n.thin,
  ...
)

Arguments

mbnma

An S3 object of class "mbnma" generated by running a dose-response MBNMA model

plot.type

Deviances can be plotted either as scatter points ("scatter" - the default) or as boxplots ("box")

facet

A boolean object that indicates whether or not to facet (by agent for MBNMAdose and by treatment for MBNMAtime)

dev.type

STILL IN DEVELOPMENT FOR MBNMAdose! Deviances to plot - can be either residual deviances ("resdev", the default) or deviances ("dev")

n.iter

number of total iterations per chain (including burn in; default: 2000)

n.thin

thinning rate. Must be a positive integer. Set n.thin > 1 to save memory and computation time if n.iter is large. Default is max(1, floor(n.chains * (n.iter-n.burnin) / 1000)) which will only thin if there are at least 2000 simulations.

...

Arguments to be sent to ggplot2::geom_point() or ggplot2::geom_boxplot

Details

Deviances should only be plotted for models that have converged successfully. If deviance contributions have not been monitored in mbnma$parameters.to.save then additional iterations will have to be run to get results for these.

For MBNMAtime, deviance contributions cannot be calculated for models with a multivariate likelihood (i.e. those that account for correlation between observations) because the covariance matrix in these models is treated as unknown (if rho = "estimate") and deviance contributions will be correlated.

Value

Generates a plot of deviance contributions and returns a list containing the plot (as an object of class(c("gg", "ggplot"))), and a data.frame of posterior mean deviance/residual deviance contributions for each observation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Using the triptans data
network <- mbnma.network(HF2PPITT)

# Run an Emax dose-response MBNMA and predict responses
emax <- mbnma.emax(network, method="random")

# Plot deviances
devplot(emax)

# Plot deviances using boxplots
devplot(emax, plot.type="box")

# Plot deviances on a single plot (not facetted by agent)
devplot(emax, facet=FALSE, plot.type="box")

# A data frame of deviance contributions can be obtained from the object
#returned by `devplot`
devs <- devplot(emax)
head(devs$dev.data)

# Other deviance contributions not currently implemented but in future
#it will be possible to plot them like so
#devplot(emax, dev.type="dev")

MBNMAdose documentation built on Sept. 13, 2020, 5:08 p.m.