Learn R Programming

MARSS (version 3.10.12)

plot.marssMLE: Plot MARSS MLE objects

Description

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.

Usage

# S3 method for marssMLE
plot(x, plot.type=c("observations", "states", "model.residuals", 
                       "state.residuals", "model.residuals.qqplot", 
                       "state.residuals.qqplot"), 
           form=c("marxss", "marss", "dfa"),
           conf.int=TRUE, conf.level=0.95, decorate=TRUE,
           plot.par = list(), ...)
  # S3 method for marssMLE
autoplot(x, plot.type=c("observations", "states", "model.residuals", 
                       "state.residuals", "model.residuals.qqplot", 
                       "state.residuals.qqplot", "expected.value.observations", 
                       "model.residuals.acf", "state.residuals.acf"),
           form=c("marxss", "marss", "dfa"),
           conf.int=TRUE, conf.level=0.95, decorate=TRUE, pi.int = FALSE,
           plot.par = list(), ...)

Arguments

x

A marssMLE object.

plot.type

Type of plot. If not passed in, all plots are drawn. Options for arguments include "observations" (fits to the raw data), "states" (estimates of the hidden or latent trends), "model.residuals" (residuals for the observation error), "state.residuals" (residuals associated with the process model), "model.residuals.qqplot" (qq plot for the observation residuals), "state.residuals.qqplot" (qq plot for the state residuals). "expected.value.observations" (estimates of the missing data points), "model.residuals.acf" and "state.residuals.acf" (ACF of the residuals).

form

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.

conf.int

TRUE/FALSE. Whether to include a confidence interval.

pi.int

TRUE/FALSE. Whether to include a prediction interval on the observations plot

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).

...

Other arguments, not used.

Value

If an individual plot is selected using plot.type and autoplot is called, then the ggplot object is returned invisibly.

Examples

Run this code
# 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 = "observations")

require(ggplot2)
autoplot(fit, plot.type = "observations")

# }
# NOT RUN {
# DFA example
dfa <- MARSS(t(harborSealWA[, -1]), model = list(m = 2), form = "dfa")
plot(dfa, plot.type = "states")
# }

Run the code above in your browser using DataLab