# Time-series similarity measures

Suppose I have two time series $X$ and $Y$ of stock prices. How do I measure the "similarity" of $X$ and $Y$?

(I'm being deliberately vague as I don't have a particular application, and I'm curious about different approaches in general. But I guess you can imagine that there's some stock x that I don't want to trade directly, for whatever reason, so I want to find a similar stock y to trade in its place.)

One method is to take a Pearson or Spearman correlation. To avoid problems of spurious correlation (since the price series likely contain trends), I should take these correlations on the differenced or returns series (which should be more stationary).

What are other similarity methods and their pros/cons?

-

I assume you're using returns (or log returns) instead of actual stock prices. In practice, you may also want to smooth the data by using a moving average.

There are several correlation coefficients:

$$r = \frac{\sigma_{x,y}}{\sigma_x \sigma_y}$$

• Spearman's $\rho$ - uses the rank of each data set (array index if data had been sorted); less sensitive to outliers in the sample as it's non-parametric:

$$d_i = x_i - y_i$$

$$\rho = 1 - \frac{6\Sigma d_{i}^{2}}{n(n^{2}-1)}$$

• Kendall's $\tau$ - also based on ranking, but represents the probability that the two data sets are in the same order vs. the probability that they are in different orders:

$$\tau = \frac{C - D}{\frac{1}{2} n(n - 1)}$$

$$\Gamma = \frac{C - D}{C + D}$$

$C$ is the number of concordant pairs and $D$ is the number of discordant pairs.

-

You can look at cointegration.

-
I suppose this would only work for long-term investments. – Owe Jessen Mar 30 '11 at 9:01
So do I but I'm not completly sure of that. I would like to here if people think this could work for short term investement if cointegration is found on high frequency data. – Zarbouzou Mar 30 '11 at 9:16
@owe jessen - curious what you mean when you say futures and OI are cointegrated since although related, one measures price and the other measures quantity. – Joshua Chance Mar 30 '11 at 15:55
That takes me back some time - I took the levels of the SP500, Volume SP 500 and OI of SP500-Futures, tested for cointegration and couldn't dismiss two relationships. Dito for the time-dependent (GARCH) Volatility of the SP500. I'm not shure why the different units should pose a problem. – Owe Jessen Apr 1 '11 at 15:53
No, there was no correctorion of this kind. I didn't develop a trading simulation, so i can't say if it is really tradeable, but I also found a significant (negative) influence of first differences of open interest on the level of the SP500 when used as additional variable in the mean equation of a GARCH model. Sadly I can't publish the results in detail because this was propriatory research. I generally used the method of Floros, Christos (2007): Price and Open Interest in Greek Stock Index Futures Market. In: Journal of Emerging Market Finance, p. 191–202. – Owe Jessen Apr 2 '11 at 11:46