Plots fitted observations and estimated states with confidence intervals using base R graphics (plot
) and ggplot2 (autoplot
). Diagnostic plots also shown. By default all plots are plotted. Individual plots can be plotted by passing in type.plot
. If an individual plot is made using autoplot
, the ggplot object is returned which can be further manipulated.
# S3 method for marssMLE
plot(x, plot.type = c("model.ytT", "xtT", "model.resids",
"state.resids", "qqplot.model.resids",
"qqplot.state.resids", "ytT", "acf.model.resids"),
form = c("marxss", "marss", "dfa"),
conf.int = TRUE, conf.level = 0.95, decorate = TRUE,
pi.int = FALSE, plot.par = list(), ..., silent = FALSE)
# S3 method for marssMLE
autoplot(x, plot.type = c("model.ytT", "xtT", "model.resids",
"state.resids", "qqplot.model.resids", "qqplot.state.resids", "ytT",
"acf.model.resids"),
form=c("marxss", "marss", "dfa"),
conf.int=TRUE, conf.level=0.95, decorate=TRUE, pi.int = FALSE,
plot.par = list(), ..., silent = FALSE)
A marssMLE
object.
Type of plot. If not passed in, all plots are drawn. See details for plot types.
Optional. Form of the model. This is normally taken from the form attribute of the MLE object (x), but the user can specify a different form.
TRUE/FALSE. Whether to include a confidence interval.
TRUE/FALSE. Whether to include a prediction interval on the observations plot
Confidence level for CIs.
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.
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).
No console interaction or output.
Other arguments, not used.
If an individual plot is selected using plot.type
and autoplot
is called, then the ggplot object is returned invisibly.
The plot types are as follows:
"model.ytT"
"observations"
can also be used. This plots the fitted ytT, which is the expected value of new data. It is \(Z*xtT + a\). The data are plotted for reference but note that the lines and intervals are for new data not the observed data.
"xtT"
"states"
can also be used. The estimates states from the Kalman smoother (conditioned on all the data).
"model.resids"
"model.residuals"
can also be used. Model smoothation residuals (data minus fitted ytT). The intervals are the CIs for the smoothation residuals not one-step-ahead (aka innovations) residuals.
"state.resids"
"state.residuals"
can also be used. State smoothation residuals (E(x(t) | xtT(t-1)) minus xtT(t)). The intervals are the CIs for the smoothation residuals not one-step-ahead residuals.
qqplot.model.resids
"model.residuals.qqplot"
can also be used. Visual normality test for the model residuals.
qqplot.state.resids
"state.residuals.qqplot"
can also be used. Visual normality test for the state residuals.
"ytT"
The expected value of \(y\) conditioned on the data. Use this for estimates of the missing data points. Note for non-missing \(y\) values, the expected value of \(y\) is \(y\).
"acf.model.resids"
ACF of the one-step-ahead model residuals.
# NOT RUN {
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)
plot(fit, plot.type = "model.ytT")
require(ggplot2)
autoplot(fit, plot.type = "model.ytT")
# }
# NOT RUN {
# DFA example
dfa <- MARSS(t(harborSealWA[, -1]), model = list(m = 2), form = "dfa")
plot(dfa, plot.type = "xtT")
# }
Run the code above in your browser using DataLab