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.

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")