1
$\begingroup$

matlab is giving some weird results.

I have a vector of nonnegative numbers which is the duration between subsequent events. I calculate the autocorrelation of this and plot it, and after about lag 100 it turns negative...

the source data is here enter image description here

and the autocorrelation is here

enter image description here

$\endgroup$
12
  • 3
    $\begingroup$ Can the correlation between two non-negative random variables be negative? $\endgroup$ Nov 10, 2018 at 1:40
  • $\begingroup$ @MossMurderer I don't think so but if I knew that I wouldn't be asking $\endgroup$
    – crow
    Nov 10, 2018 at 2:06
  • 4
    $\begingroup$ As one increases, the other decreases. Why would that be restricted to variables that can have negative values? $\endgroup$ Nov 10, 2018 at 2:39
  • $\begingroup$ The correlation formula is $r = \frac{\sum{(x-m_x)(y-m_y)}}{\sqrt{\sum{(x-mx)^2}\sum{(y-my)^2}}}$ how can it be negative if no element of the input vectors x and y are negative? actually I see how it could be.. I've just never encountered a process with these characteristics... Interesting $\endgroup$
    – crow
    Nov 10, 2018 at 3:04
  • 3
    $\begingroup$ If x tends to be above/below $m_x$ when y is below/above $m_y$, then the numerator is a sum over mostly negative values. $\endgroup$ Nov 10, 2018 at 3:42

1 Answer 1

2
$\begingroup$

can a vector of strictly positive values have a negative autocorrelation at any lag?

[NB As whuber notes, the question is ambiguous. I read it as "With positive time series, can there be a lag at which there's a negative correlation?".]

Consider the sequence $Y_t =12/Y_{t-1}$ with $Y_0=4$.

Alternatively, consider $Y_t=10-Y_{t-1}$ with $Y_0=4$.

As a more prosaic but realistic example, take some stationary series that has a negative correlation at some lag and shift it up by some large value $L$ (some value easily large enough to make the whole series positive). The autocorrelations are unchanged.

Or take a series with a strong negative correlation and little noise that's close to zero (but can be both positive and negative) and exponentiate it. For example:

 x <- arima.sim(n=1000,list(ar=-.9),sd=.01)
 y <- exp(x)
 acf(y)

Any of these should suffice to demonstrate that negative autocorrelations are easily attained with positive variates.

$\endgroup$
2
  • $\begingroup$ It's unclear which question you are answering, Glen: the answer to the question in the title, which can be understood as "can a vector of positive values have negative autocorrelation coefficients at all nonzero lags," would be a little different. $\endgroup$
    – whuber
    Nov 10, 2018 at 13:56
  • 1
    $\begingroup$ @whuber I'm answering "With positive time series, can there be a lag at which there's a negative autocorrelation?" which is how I read the title, though I agree it's ambiguous. I'll put a clarification in my answer. $\endgroup$
    – Glen_b
    Nov 10, 2018 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.