Learn R Programming

locits (version 1.7.7)

plot.lacfCI: Plot confidence intervals for localized autocovariance for locally stationary time series.

Description

Plot the localized autocovariance and approximate confidence intervals.

Usage

# S3 method for lacfCI
plot(x, plotcor = TRUE, type = "line",
    lags = 0:as.integer(10 * log10(nrow(x$lacf))), tcex = 1,
    lcol = 1, llty = 1, ylim = NULL, segwid = 1,
    segandcross = TRUE, conf.level = 0.95, plot.it = TRUE,
    xlab, ylab, sub, ...)

Value

A vector of the extracted acfvals invisibly returned. Note: what is returned depends on the arguments, what is returned is what would have been plotted if plot.it

were TRUE

Arguments

x

The lacfCI object you wish to plot, e.g. produced by the Rvarlacf function.

plotcor

If TRUE then autocorrelations are plotted, if FALSE then autocovariances are. Note: not all combinations of types of plot and plotcor are valid, but many are.

type

This can be one of three values "line", "persp" or "acf". The value "acf" produces a plot like the regular acf function, but note, the values plotted are from a localized autocovariance function centred at the time location contained in the object object (and that time appears in the subtitle). This is the only plot that also plots the confidence intervals. The "line" plot plots autocorrelations (only) for the specified lags and does this over all time for the whole extent of the series. This plot is useful to see if the autocorrelations are changing over time. The final option, "persp" produces a perspective plot of the autocovariance or autocorrelations. Arguments can be supplied (theta, phi) to rotate the perspective plot, as it can be sometimes hard to visualize the plot.

lags

The lags that you wish to display. This should be a list of non-negative integers, but not necessarily consecutive.

tcex

On the "line" plot this argument controls the expansion of the font for the labels on the lines. So, setting tcex=2, for example, will double the size of these. These labels visually indicate which line corresponds to which lag.

lcol

On the "line" plot, this argument controls the colour of the lines that are used to show the acfs.

llty

As lcol but for line types.

ylim

The vertical limits of the plot.

segwid

On the "acf" plot, this argument controls the widths of the little acf segments that connect the x-axis with the acf values.

segandcross

If TRUE then a small diamond is plotted at the location of the acf, to make it clearer.

conf.level

The confidence level of the confidence intervals.

plot.it

If FALSE then no plot is produced. This can be used if you merely want to extract the relevant acf values (which are returned).

xlab

X-axis label, constructed internally if not supplied

ylab

Y-axis label, constructed internally if not supplied

sub

A subtitle for the plot

...

Other arguments to the main plot command.

Author

Guy Nason.

Details

This function can plot the localized autocovariance in three ways. Like a regular acf plot (but obviously a slice out of a time-varying autocovariance, not the regular acf), a line plot which shows the acfs over time and a perspective plot which can plot the estimate of \(c(z, \tau)\) as a 2D function. Currently, the confidence intervals can only be displayed on the "acf" type plot.

References

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

Rvarlacf

Examples

Run this code
#
# Simulate a TVAR(1) process
#
x <- tvar1sim()
#
# Computes its time-localized autocovariance and confidence intervals
# Note: smoothing is done automatically!
#
x.lacf <- Rvarlacf(x=x, nz=50, var.lag.max=20)
#
# Now plot this, plot covariances as an acf plot, with the CIs
#
if (FALSE) plot(x.lacf, type="acf", plotcor=FALSE)
#
# Now plot it as a line plot, as correlations and can't do CIs
#
if (FALSE) plot(x.lacf)

Run the code above in your browser using DataLab