Plot time series against lagged versions of themselves.
Helps visualizing ‘auto-dependence’ even when auto-correlations
vanish.
Usage
lag.plot(x, lags = 1, layout = NULL, set.lags = 1:lags,
main = NULL, asp = 1,
diag = TRUE, diag.col = "gray", type = "p", oma = NULL,
ask = NULL, do.lines = (n <= 150), labels = do.lines,
...)
Arguments
x
time-series (univariate or multivariate)
lags
number of lag plots desired, see arg set.lags.
layout
the layout of multiple plots, basically the mfrowpar() argument. The default uses about a square
layout (see n2mfrow such that all plots are on one page.
set.lags
vector of positive integers allowing specification of
the set of lags used; defaults to 1:lags.
main
character with a main header title to be done on the top
of each page.
asp
Aspect ratio to be fixed, see plot.default.
diag
logical indicating if the x=y diagonal should be drawn.
diag.col
color to be used for the diagonal if(diag).
type
plot type to be used, but see plot.ts about
its restricted meaning.
oma
outer margins, see par.
ask
logical or NULL; if true, the user is asked to
confirm before a new page is started.
do.lines
logical indicating if lines should be drawn.
labels
logical indicating if labels should be used.
...
Further arguments to plot.ts. Several
graphical parameters are set in this function and so cannot be
changed: these include xlab, ylab, mgp,
col.lab and font.lab: this also applies to the
arguments xy.labels and xy.lines.
Details
If just one plot is produced, this is a conventional plot. If more
than one plot is to be produced, par(mfrow) and several other
graphics parameters will be set, so it is not (easily) possible to mix
such lag plots with other plots on the same page.
If ask = NULL, par(ask = TRUE) will be called if more than
one page of plots is to be produced and the device is interactive.
Note
It is more flexible and has different default behaviour than
the S version. We use main = instead of head = for
internal consistency.
Author(s)
Martin Maechler
See Also
plot.ts which is the basic work horse.
Examples
require(graphics)
lag.plot(nhtemp, 8, diag.col = "forest green")
lag.plot(nhtemp, 5, main = "Average Temperatures in New Haven")
## ask defaults to TRUE when we have more than one page:
lag.plot(nhtemp, 6, layout = c(2,1), asp = NA,
main = "New Haven Temperatures", col.main = "blue")
## Multivariate (but non-stationary! ...)
lag.plot(freeny.x, lags = 3)
## no lines for long series :
lag.plot(sqrt(sunspots), set = c(1:4, 9:12), pch = ".", col = "gold")
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(stats)
> png(filename="/home/ddbj/snapshot/RGM3/R_rel/result/stats/lag.plot.Rd_%03d_medium.png", width=480, height=480)
> ### Name: lag.plot
> ### Title: Time Series Lag Plots
> ### Aliases: lag.plot
> ### Keywords: hplot ts
>
> ### ** Examples
>
> require(graphics)
>
> lag.plot(nhtemp, 8, diag.col = "forest green")
> lag.plot(nhtemp, 5, main = "Average Temperatures in New Haven")
> ## ask defaults to TRUE when we have more than one page:
> lag.plot(nhtemp, 6, layout = c(2,1), asp = NA,
+ main = "New Haven Temperatures", col.main = "blue")
>
> ## Multivariate (but non-stationary! ...)
> lag.plot(freeny.x, lags = 3)
>
> ## no lines for long series :
> lag.plot(sqrt(sunspots), set = c(1:4, 9:12), pch = ".", col = "gold")
>
>
>
>
>
> dev.off()
null device
1
>