
This function creates residual plots for an estimated ctsmTMB object
Source:R/S3_plot.R
plot.ctsmTMB.fit.RdThis function creates residual plots for an estimated ctsmTMB object
Usage
# S3 method for class 'ctsmTMB.fit'
plot(
x,
print.plot = 1,
type = c("residuals", "states"),
state.type = c("prior", "posterior", "smoothed"),
against.obs = NULL,
standardized.residuals = TRUE,
residual.burnin = 0L,
residual.vs.obs.and.inputs = FALSE,
ggtheme = getggplot2theme(),
time.series.ylims = c(NA, NA),
hist.bins = 50,
...
)Arguments
- x
A R6 ctsmTMB fit object
- print.plot
an integer determining which of the produced plots to print in the plot window. A value of 0 means not to plot anything.
- type
a character vector either 'residuals' or 'states' determining what to plot.
- state.type
a character vector either 'prior', 'posterior' or 'smoothed' determining what kind of states to plot. 'prior' and 'posterior' are available for the Kalman filter methods, while 'smoothed' is available for the Laplace methods (and is used automatically for those fits).
- against.obs
name of an observation to plot state predictions against.
- standardized.residuals
logical whether or not the time-series and histogram plots show standardized residuals.
- residual.burnin
integer N - removes the first N entries in the residual vectors, including NAs.
- residual.vs.obs.and.inputs
the residual plots also include a new window with time-series plots of residuals, associated observations and inputs
- ggtheme
ggplot2 theme to use for creating the ggplot.
- time.series.ylims
limits on the y-axis for residual time-series plot
- hist.bins
number of bins passed to
ggplot2::geom_histogram- ...
additional arguments
Examples
if (FALSE) { # \dontrun{
# Given a fit from estimate i.e.
fit <- model$estimate(data)
# We can generate a standard residual analysis plot by
plot(fit)
# We can remove the first say 10 residuals of the series if they are off due
# to a bad initial prior state
plot(fit, residual.burnin=10)
# We can also plot residuals against inputs and observations instead
plot(fit, residual.vs.obs.and.inputs=TRUE)
# We can also plot the prior or posterior states using the 'type' and
# 'state.type' arguments.
plot(fit, type="states", state.type="prior")
# We can also show observations on that plot
plot(fit, type="states", state.type="prior", against.obs="y")
# For fits obtained with the Laplace methods the smoothed states are plotted
plot(fit, type="states", state.type="smoothed", against.obs="y")
} # }