I have sales data of a group of products over the same time period. I would like to calculate a covariance matrix of the products, but the time series are not stationary, there are seasonalities and trends.

How can one use the standard covariance formula:

$COV(X,Y)=E[(X-E(X))(Y-E(Y))]$ if $E(X)$ and $E(Y)$ are time dependent? What is a suitable substitute for $E(X)$ and $E(Y)$?

I've tried replacing $X-E(X)$ with $X(t)-\hat{X}(t)$ and $Y-E(Y)$ with $Y(t)-\hat{Y}(t)$, with $\hat{X}(t)$ and $\hat{Y}(t)$ being suitable chosen models of the time series.

So that:


But I'm not shore if this is correct. (Is this a valid approach? Am I missing something?)

Also I need to calculate the covariance matrix not just of my actuals but for future time frames, so even if my approach is valid, I don't know what to use for future time frames, since $X(t)-\hat{X}(t)$ and $Y(t)-\hat{Y}(t)$ don't make sense for future times.


1 Answer 1


Covariance on nonstationary series rarely makes a sense. Difference the series until they become stationary. With sales data the growth rates or log differences often work well

  • $\begingroup$ Why not? Consider 3 time series a.b and c: a and b have the same trend but different seasonalities, while b and c have the same seasonality but different trends. Wouldn't a covariance matrix of the 3 somehow reflect that? $\endgroup$
    – Skander H.
    Apr 4, 2018 at 20:46
  • $\begingroup$ You run a big risk of spurious correlations when calculating covariance on nonstationary series. Moreover, if you have consistently growing series, then contribution of earlier observations is smaller just by the fact that their levels are lower. It just creates a lot of nasty problems $\endgroup$
    – Aksakal
    Apr 4, 2018 at 20:49

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.