Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gglagplot

Time series lag ggplots


Description

Plots a lag plot using ggplot.

Usage

gglagplot(
  x,
  lags = ifelse(frequency(x) > 9, 16, 9),
  set.lags = 1:lags,
  diag = TRUE,
  diag.col = "gray",
  do.lines = TRUE,
  colour = TRUE,
  continuous = frequency(x) > 12,
  labels = FALSE,
  seasonal = TRUE,
  ...
)

gglagchull(
  x,
  lags = ifelse(frequency(x) > 1, min(12, frequency(x)), 4),
  set.lags = 1:lags,
  diag = TRUE,
  diag.col = "gray",
  ...
)

Arguments

x

a time series object (type ts).

lags

number of lag plots desired, see arg set.lags.

set.lags

vector of positive integers specifying which lags to use.

diag

logical indicating if the x=y diagonal should be drawn.

diag.col

color to be used for the diagonal if(diag).

do.lines

if TRUE, lines will be drawn, otherwise points will be drawn.

colour

logical indicating if lines should be coloured.

continuous

Should the colour scheme for years be continuous or discrete?

labels

logical indicating if labels should be used.

seasonal

Should the line colour be based on seasonal characteristics (TRUE), or sequential (FALSE).

...

Not used (for consistency with lag.plot)

Details

“gglagplot” will plot time series against lagged versions of themselves. Helps visualising 'auto-dependence' even when auto-correlations vanish.

“gglagchull” will layer convex hulls of the lags, layered on a single plot. This helps visualise the change in 'auto-dependence' as lags increase.

Value

None.

Author(s)

Mitchell O'Hara-Wild

See Also

Examples

gglagplot(woolyrnq)
gglagplot(woolyrnq,seasonal=FALSE)

lungDeaths <- cbind(mdeaths, fdeaths)
gglagplot(lungDeaths, lags=2)
gglagchull(lungDeaths, lags=6)

gglagchull(woolyrnq)

forecast

Forecasting Functions for Time Series and Linear Models

v8.14
GPL-3
Authors
Rob Hyndman [aut, cre, cph] (<https://orcid.org/0000-0002-2140-5352>), George Athanasopoulos [aut], Christoph Bergmeir [aut] (<https://orcid.org/0000-0002-3665-9021>), Gabriel Caceres [aut], Leanne Chhay [aut], Mitchell O'Hara-Wild [aut] (<https://orcid.org/0000-0001-6729-7695>), Fotios Petropoulos [aut] (<https://orcid.org/0000-0003-3039-4955>), Slava Razbash [aut], Earo Wang [aut], Farah Yasmeen [aut] (<https://orcid.org/0000-0002-1479-5401>), R Core Team [ctb, cph], Ross Ihaka [ctb, cph], Daniel Reid [ctb], David Shaub [ctb], Yuan Tang [ctb] (<https://orcid.org/0000-0001-5243-233X>), Zhenyu Zhou [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.