devplot {MBNMAtime} | R Documentation |
Plot deviance contributions from an MBNMA model
Description
Plot deviance contributions from an MBNMA model
Usage
devplot(
mbnma,
dev.type = "dev",
plot.type = "box",
xaxis = "time",
facet = TRUE,
n.iter = round(mbnma$BUGSoutput$n.iter/4),
n.thin = mbnma$BUGSoutput$n.thin,
...
)
Arguments
mbnma |
An S3 object of class |
dev.type |
Deviances to plot - can be either residual deviances ( |
plot.type |
Deviances can be plotted either as scatter points ( |
xaxis |
A character object that indicates whether deviance contributions should be plotted
by time ( |
facet |
A boolean object that indicates whether or not to facet by treatment |
n.iter |
The number of iterations to update the model whilst monitoring additional parameters (if necessary).
Must be a positive integer. Default is the value used in |
n.thin |
The thinning rate. Must be a positive integer. Default is the value used in |
... |
Arguments to be sent to |
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.
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
# Make network
alognet <- mb.network(alog_pcfb)
# Run MBNMA
mbnma <- mb.run(alognet, fun=tpoly(degree=2), intercept=FALSE)
# Plot residual deviance contributions in a scatterplot
devplot(mbnma)
# Plot deviance contributions in boxplots at each follow-up measurement
# Monitor for 500 additional iterations
devplot(mbnma, dev.type="dev", plot.type="box", xaxis="fup", n.iter=500)