tseries (version 0.1-1)

ccf: Crosscorrelation Function

Description

Computes the sample crosscorrelation (covariance) function of x and y up to lag lag. If pl is TRUE, then the crosscorrelation (covariance) function is plotted. For the crosscorrelation function also the 95% confidence bounds for strict white noise are plotted. Uses fft for efficiency reasons.

Missing values are not handled.

Usage

ccf (x, y, lag = length(x)-1, correlation = TRUE, pl = TRUE, ...)

Arguments

x,y
two numeric vector or time series.
lag
a scalar lag parameter.
pl
a logical indicating whether the crosscorrelation (covariance) function is plotted.
...
additional arguments to plot.tsparam.

Value

  • A "tsparam" object.

References

P. J. Brockwell and R. A. Davis (1991): Time Series: Theory and Methods, 2nd Edition, Springer Verlag, NY, pp. 373-375, 405-417.

See Also

tsparam

Examples

Run this code
data (sales)  # parts of Example 11.2.2 from Brockwell and Davies (1991).
sal <- diff (sales)
led <- diff(lead)
ccf (led, sal, lag = 20, ylim = range(-1,1), type="o")

Run the code above in your browser using DataCamp Workspace