plot.marssResiduals | R Documentation |
Plots residuals using the output from a residuals()
call. By default all available residuals plots are plotted. Individual plots can be plotted by passing in plot.type
. If an individual plot is made using autoplot()
, the ggplot object is returned which can be further manipulated. Plots are only shown for those residual types in the marssResiduals
object.
## S3 method for class 'marssResiduals'
plot(x, plot.type = c("all", "residuals", "qqplot", "acf"),
conf.int = TRUE, conf.level = 0.95, decorate = TRUE,
plot.par = list(), silent = FALSE, ...)
## S3 method for class 'marssResiduals'
autoplot(x,
plot.type = c("all", "residuals", "qqplot", "acf"),
conf.int = TRUE, conf.level = 0.95, decorate = TRUE,
plot.par = list(),
silent = FALSE)
x |
A |
plot.type |
Type of plot. If not passed in, all plots are drawn. See details for plot types. |
conf.int |
TRUE/FALSE. Whether to include a confidence interval. |
conf.level |
Confidence level for CIs. |
decorate |
TRUE/FALSE. Add smoothing lines to residuals plots or qqline to qqplots and add data points plus residuals confidence intervals to states and observations plots. |
plot.par |
A list of plot parameters to adjust the look of the plots. The default is list(point.pch = 19, point.col = "blue", point.fill = "blue", point.size = 1, line.col = "black", line.size = 1, line.linetype = "solid", ci.fill = "grey70", ci.col = "grey70", ci.linetype = "solid", ci.linesize = 0, ci.alpha = 0.6). |
silent |
No console interaction or output. |
... |
Not used. |
If resids <- residuals(x)
is used (default) where x
is a marssMLE
object from a MARSS()
call, then resids
has the innovations residuals, or one-step-ahead residuals. These are what are commonly used for residuals diagnostics in state-space modeling. However, other types of residuals are possible for state-space models; see MARSSresiduals()
for details. The plot function for marssResiduals
objects will handle all types of residuals that might be in the marssResiduals
object. However if you simply use the default behavior, resids <- residuals(x)
and plot(resids)
, you will get the standard model residuals diagnostics plots for state-space models, i.e. only model residuals plots and only plots for innovations model residuals (no smoothations model residuals).
The plot types are as follows:
"all"
All the residuals in the residuals object plus QQ plots and ACF plots.
"residuals"
Only residuals versus time.
"qqplot"
Only QQ plots. Visual normality test for the residuals.
"acf"
ACF of the residuals. If x$type is "ytt1"
, these are the one-step-ahead (aka innovations) residuals and they should be temporally independent.
If an individual plot is selected using plot.type
and autoplot()
is called, then the ggplot object is returned invisibly.
Eli Holmes
data(harborSealWA)
model.list <- list( Z = as.factor(c(1, 1, 1, 1, 2)), R = "diagonal and equal")
fit <- MARSS(t(harborSealWA[, -1]), model = model.list)
resids <- residuals(fit)
require(ggplot2)
# plots of residuals versus time, QQ-norm plot, and ACF
autoplot(resids)
# only the ACF plots
# autoplot(resids, plot.type = "acf")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.