Learn R Programming

locits (version 1.7.7)

plot.lacf: Plot localized autocovariance (lacf) object.

Description

Produces various ways of looking at a localized autocovariance (lacf) object.

Usage

# S3 method for lacf
plot(x, plotcor = TRUE, type = "line",
        lags = 0:min(as.integer(10 * log10(nrow(x$lacf))), ncol(x$lacf) - 1),
        tcex = 1, lcol = 1, llty = 1, the.time = NULL, plot.it=TRUE,
	xlab, ylab, ...)

Value

For the acf type plot the acf values are returned invisibly. For the other types nothing is returned.

Arguments

x

The localized autocovariance object you want to plot (lacf)

plotcor

If TRUE then plot autocorrelations, otherwise plot autocovariances.

type

The lacf objects are fairly complex and so there are different ways you can plot them. The types are line, persp or acf, see the details for description. Note that the line plot only works with correlations currently.

lags

The lags that you wish included in the plot. The default is all the lags from 0 up to the maximum that is used in the R acf plot

tcex

In the line plot lines are plotted that indicate the time-varying correlation. Each lag gets a different line and the lines are differentiated by the lag id being placed at intervals along the line. This argument changes the size of those ids (numbers).

lcol

Controls the colours of the lines in the line plot.

llty

Controls the line types of the lines in the line plot.

the.time

If the acf plot is chosen then you have to specify a time point about which to plot the acf. I.e. in general this funcion's lacf argument is a 2D function: \(c(t, \tau)\), the acf plot produces a plot like the regular acf function and so you have to turn the 2D \(c(t, \tau)\) into a 1D function \(c(t_0, \tau)\) by specifying a fixed time point \(t_0\).

plot.it

If TRUE the plot is produced and displayed. If FALSE then no plot is produced but the autocovariance or autocorrelation values that would have been produced are returned as numerical values instead. This means that this function is an extractor function for the lacf class object.

xlab

X-axis label, constructed internally if not supplied

ylab

Y-axis label, constructed internally if not supplied

...

Other arguments to plot.

Author

G.P. Nason

Details

This function produces pictures of the two-dimensional time-varying autocovariance or autocorrelation, \(c(t, \tau)\), of a locally stationary time series. There are three types of plot depending on the argument to the type argument.

The line plot draws the autocorrelations as a series of lines, one for each lag, as lines over time. E.g. a sequence #of lines \(c(t, \tau_i)\) is drawn, one for each \(\tau_i\). The zeroth lag line is the autocorrelation at lag 0 which is always 1. By default all the lags are drawn which can result in a confusing picture. Often, one is only interested in the low level lags, so only these can be plotted by changing the lags argument and any selection of lags can be plotted. The colour and line type of the plotted lines can be changed with the lcol and the llty arguments.

The acf plot produces pictures similar to the standard R acf() function plot. However, the regular acf is a 1D function, since it is defined to be constant over all time. The time-varying acf supplied to this function is not constant over all time (except for stationary processes, theoretically). So, this type of plot requires the user to specify a fixed time at which to produce the plot, and this is supplied by the the.time argument.

The persp plot plots the 2D function \(c(t, \tau)\) as a perspective plot.

References

Cardinali, A. and Nason, G.P. (2012) Costationarity of Locally Stationary Time Series using costat.

Cardinali, A. and Nason, G.P. (2010) Costationarity of locally stationary time series. J. Time Series Econometrics, 2, Issue 2, Article 1.

Nason, G.P. (2013) A test for second-order stationarity and approximate confidence intervals for localized autocovariances for locally stationary time series. J. R. Statist. Soc. B, 75, 879-904. tools:::Rd_expr_doi("10.1111/rssb.12015")

See Also

lacf

Examples

Run this code
#
# Make some dummy data, e.g. white noise
#
v <- rnorm(256)
#
# Compute the localized autocovariance (ok, the input is stationary
# but this is just an example. More interesting things could be achieved
# by putting the results of simulating from a LSW process, or piecewise
# stationary by concatenating different stationary realizations, etc.
#
vlacf <- lacf(v, lag.max=30)
#
# Now let's do some plotting of the localized autocovariance
#
if (FALSE) plot(vlacf, lags=0:6)
#
# Should get a plot where lag 0 is all up at value 1, and all other
# autocorrelations are near zero (since its white noise).
#
#
# How about just looking at lags 0, 2 and 4, and some different colours.
#
if (FALSE) plot(vlacf, lags=c(0,2,4), lcol=c(1,2,3))
#
# O.k. Let's concentrate on time t=200, let's look at a standard acf
# plot near there.
#
if (FALSE) plot(vlacf, type="acf", the.time=200)
#
# Now plot the autocovariance, rather than the autocorrelation.
#
if (FALSE) plot(vlacf, type="acf", the.time=200, plotcor=FALSE)
#
# Actually, the plot doesn't look a lot different as the series is white
# noise, but it is different if you look closely.

Run the code above in your browser using DataLab