plot.iNZightTS: Draw a simple time series plot

Description Usage Arguments Details Value Forecast References Examples

View source: R/rawplot.R

Description

Draws a plot of a given iNZightTS object with the trend superimposed.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## S3 method for class 'iNZightTS'
plot(
  x,
  multiplicative = FALSE,
  ylab = obj$currVar,
  xlab = "Date",
  title = "%var",
  animate = FALSE,
  t = 10,
  smoother = TRUE,
  aspect = 3,
  plot = TRUE,
  col = ifelse(forecast > 0, "#0e8c07", "red"),
  xlim = c(NA, NA),
  model.lim = NULL,
  seasonal.trend = FALSE,
  forecast = 0,
  ...
)

Arguments

x

an iNZightTS object

multiplicative

logical. If TRUE, a multiplicative model is used, otherwise an additive model is used by default.

ylab

a title for the y axis

xlab

a title for the x axis

title

a title for the graph

animate

logical, if true the graph is animated

t

smoothing parameter

smoother

logical, if TRUE the smoother will be drawn

aspect

the aspect ratio of the plot; it will be about ASPECT times wider than it is high

plot

logical, if FALSE, the graph isn't drawn

col

the colour of the smoothed trend line

xlim

axis limits, specified as dates

model.lim

limits of the series to use for modelling/forecast

seasonal.trend

logical, if TRUE seasonal+trend curve added

forecast

numeric, how many observations ahead to forecast (default is 0, no forecast)

...

additional arguments (not used)

Details

If animate is set to TRUE, a scatterplot of all points in the time series will appear followed by slowly drawn lines connecting the points, simulating the drawing of a time series by hand.

Value

a time series plot (constructed with ggplot2) is returned invisibly, which can be added to if desired.

Forecast

The predictions and prediction intervals are the result of models fitted by the Holt-Winters method. The amount of predicted observations is specified by the value of 'forecast'.

References

C.C Holt (1957) Forecasting seasonals and trends by exponentially weighted moving averages, ONR Research Memorandum, Carnegie Institute 52.

P.R Winters (1960) Forecasting sales by exponentially weighted moving averages, Management Science 6, 324–342.

Examples

1
2
3
4
5
t <- iNZightTS(visitorsQ)
plot(t)

# Forecast plot (8 quarterly forecasts):
plot(t, forecast = 8)

iNZightTS documentation built on Feb. 1, 2022, 1:08 a.m.