0
$\begingroup$

When I try to compute the cross-correlation function between two vectors c(0, 0, 0, 1, 0, 0) and c(0, 1, 0, 0, 0, 0) via

ccf(c(0, 0, 0, 1, 0, 0), c(0, 1, 0, 0, 0, 0))

I get the following result: enter image description here

Here all values are nonzero, which seems strange for me, because for most lags, when I multiply two vectors (for example for zero lag), I should get zero, because where one vector has nonzero element, another has zero and vice versa. Why do I get some nonzero results on the graph where I should get zero?

$\endgroup$
  • $\begingroup$ Hint: you can find a lag where there is at least one term without any zeros in its factors. Don't forget that correlation concerns the residuals after means are subtracted. There's probably also a technical issue similar to that discussed at stats.stackexchange.com/questions/81754; namely, there are several slightly different formulas for the ccf in use. $\endgroup$ – whuber May 27 '19 at 15:07
  • $\begingroup$ Yes, I had a lack of understanding how cross-correlation is computed, I didn't know that it is computed for mean-substracted values. When I computed ccf with vectors c(-1, 0, 0, 1, 0, 0) and c(0, 1, 0, 0, 0, -1) (which have zero means), I got nonzero elements at lags 1, 2, 3 and everywhere else it is zero, how should be. $\endgroup$ – bastak May 27 '19 at 16:29
  • $\begingroup$ Some people (typically in engineering fields) do not subtract the means in their definition, often because they assume a zero-mean process anyway. That difference has little impact with the typical long time series ("signals") they work with, but it can have a huge difference with tiny example data like these. $\endgroup$ – whuber May 27 '19 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.