View source: R/xyplot.forecast.R
| xyplot.forecast | R Documentation |
Plot forecasts from forecast::forecast(). It is built mostly to resemble
the forecast::autoplot.forecast() and forecast::plot.forecast()
functions, but in addition tries to plot the predictions on the original
scale.
## S3 method for class 'forecast'
xyplot(
x,
data = NULL,
ci = TRUE,
ci_levels = x$level,
ci_key = ci,
ci_pal = hcl(0, 0, 45:100),
ci_alpha = trellis.par.get("regions")$alpha,
...
)
x |
An object of class |
data |
Data of observations left out of the model fit, usually "future" observations. |
ci |
Plot confidence intervals for the predictions. |
ci_levels |
The prediction levels to plot as a subset of those
forecasted in |
ci_key |
Set to |
ci_pal |
Color palette for the confidence bands. |
ci_alpha |
Fill alpha for the confidence interval. |
... |
Arguments passed on to |
This function requires the zoo package.
An object of class "trellis". The
update method can be used to
update components of the object and the
print method (usually called by
default) will plot it on an appropriate plotting device.
lattice::panel.xyplot(), forecast::forecast(), lattice::xyplot.ts().
if (require(forecast)) {
train <- window(USAccDeaths, c(1973, 1), c(1977, 12))
test <- window(USAccDeaths, c(1978, 1), c(1978, 12))
fit <- arima(train, order = c(0, 1, 1),
seasonal = list(order = c(0, 1, 1)))
fcast1 <- forecast(fit, 12)
xyplot(fcast1, test, grid = TRUE, auto.key = list(corner = c(0, 0.99)),
ci_key = list(title = "PI Level"))
# A fan plot
fcast2 <- forecast(fit, 12, level = seq(0, 95, 10))
xyplot(fcast2, test, ci_pal = heat.colors(100))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.