Description Usage Arguments Value Notes See Also Examples
dcf
returns the Discrete Correlation Function estimates.
1 2 |
ts.1 |
(array or dataframe) data for time series 1 and 2. |
ts.2 |
(array or dataframe) data for time series 1 and 2. |
tau |
(vector) list of lags at which to compute the CCF. |
min.pts |
(integer) each DCF bin must contain at least |
local.est |
(logical) use 'local' (not 'global') means and variances? |
zero.clip |
(logical) remove pairs of points with exactly zero lag? |
use.errors |
(logical) if |
cov |
(logical) if |
chatter |
(integer) set the level of feedback. |
A data frame containing columns:
tau |
the centre of the lag bins (vector) |
ccf |
the correlation coefficent in each lag bin |
n |
the number of data point pairs included in each lag bin |
Input are two time series (data frames with columns: t, y, dy
[optional]) Output is the correlation coefficient ccf[i]
in different
lag bins tau[i]
.
In what follows we refer to the t, y
values of time series 1
(ts.1
) as t.1, y.1
, and similarly for time series 2.
We first subtract the mean values from y.1
and y.2
. Then,
within the i
th lag bin (tau[i] - dtau/2
, tau[i] +
dtau/2
) we collect all pairs (y.1, y.2
) of data for which t.1 -
t.2
falls within the lag bin. Using these pairs of data we compute the sum
of their product and normalise it:
cov[i] = (1/n) * sum_{j,k=1..n} (y.1[j] * y.2[k])
Here, j, k
are index arrays of length n
that specify the points
of time series 1 and 2 (respectively) which pair-up within lag bin i
.
This gives a covariance. If cov = TRUE
we keep these values. Otherwise
(default: cov = FALSE
) we normalise by the product of the standard
deviations of y.1
and y.2
.
The number of output lags tau
is 2*lag.bins+1
, and the lags are
centred on zero. So they run from -max.lag
to +max.lag
. Any lag
bins containing fewer than min.pts pairs of points will have ccf = NA
.
If 'errors' are suppled for either or both time series (dx.1, dx.2)
and use.errors = TRUE
then the variance used
in the denominator terms of correlation coefficient calculation will be
the 'excess variance', i.e. the total sample variance minus the
mean square error. If dy.1 and/or dy.2 are a single number, this is
assumed to be the same error for each data point. If use.errors = FALSE
(default) then the usual sample variance will be used.
1 2 3 4 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.