# Testing for statistically significant difference in time series?

I have the time series of the prices of two securities, A and B, over the same period of time and sampled at the same frequency. I would like to test whether there is any statistically significant difference over time between the two prices (my null hypothesis would be that the difference is null). Specifically, I am using price differences as a proxy for market efficiency. Imagine A and B are a security and its synthetic equivalent (i.e. both are claims to exactly the same cash flows). If the market is efficient, both should have the exact same price (barring different transaction costs, etc.), or a zero price difference. This is what I would like to test for. What is the best way to do so?

I might have intuitively run a two-sided t-test on the "difference" time series, i.e. on the A-B time series, and tested for $\mu_0$=0. However, I have the suspicion that there might be more robust tests, that take into account things like potential homoskedastic errors or the presence of outliers. In general, are there things to watch out for when working with the prices of securities?

• I think to make this question answerable, we need a model of some type. In particular, what does it mean to ask if "there is a statistically significant difference over time between the two prices" unless there is some noise in observing the prices? There is no parameter here and no randomness. Perhaps you are wanting to make some assumption about some parameter of the price process over time. A "standard" formulation might look at the log-returns process $R_t = \log(X_t/X_{t-1})$ and assume that these are iid normal. (cont.) – cardinal Apr 6 '12 at 19:01
• (cont.) Then, one might want to test if the mean returns between the two processes are equal. But, that's getting a bit ahead of ourselves, perhaps, and also fixes rather strong (and, often, empirically false) assumptions on the price process. – cardinal Apr 6 '12 at 19:02
• @cardinal: I want to test the existence of ANY arbitrage strategy, to test for market efficiency. H0: market is efficient, therefore one is not able to make riskless profit with no investment of cash, using any imaginable strategy. – lodhb Apr 7 '12 at 16:52
• lodhb, that is interesting in that I did not interpret your question at all as having that as the main interest. This makes me think (i) the answer you have accepted has almost nothing to do with your comment, (ii) I'm not sure that @naught101, who has offered a bounty on your question, has read this as your intent and (iii) if this is really what you are looking to test, you might strongly consider updating your question to reflect this, though it might put naught101 in a bit of an awkward spot. – cardinal Apr 7 '12 at 18:24
• Doesn't bother me if the question changes. That's part of the risk of offering a bounty on someone else's question. Go for it. – naught101 Apr 8 '12 at 2:29

I would not start by taking differences of stock prices, normalized for the same initial capital or not. Stock prices do not go below zero, so at best the differences between two stock prices (or accrued difference in initial capital outlay) would only be slightly more normal than the not normal distributions of price (or capital worth) of the stocks taken individually, and, not normal enough to justify a difference analysis.

However, as stock prices are approximately log-normal, I would start normalizing by taking the ratio of the two prices $\frac{\$A}{\$B}$, which obviates having to normalize to initial capital outlay. To be specific, what I am expecting is that stock prices vary as proportional data, that a change from a price of $\$1.00$to$\$1.05$, discretization aside, is as expected as the change from $\$100.00$to$\$105.00$. Then, all you have to worry about is whether the ratio of stock prices is increasing or decreasing in time. For that, I would suggest ARIMA or some other trending analysis.

You can use Kendalls Tau, spearmans rho, or just correlation coefficient to check for these. In R the code will look something like

library(fBasics)
> cor(A,B)
 0.5485227
> cor(A,B,method='kendall')
 0.3581761
> cor(A,B,method='spearman')
 0.5095149


This sounds like an attempt to compare two samples each of size one. If the two time series are not equal, then there is, with hindsight, and arbitrage strategy.

The question is whether this strategy is discoverable in advance. To answer this you must have some idea of the universe from which strategies can be drawn, e.g. an arbitrageur could be guided by exchange rates, weather, phases of the moon... You can then find the best arbitrage strategy from the family you have defined.

If the family is big, then there is risk of overfitting.

Let me split my answer into two parts 1)Logical reasoning: Are these two securities A and B belongs to same organization or product or firm or service? or different If they both are different then we should not do test for comparision. Because, any difference between two numbers can not be global. It means, just by comparing numbers we can not conclude anything. So, we are missing the big picture. 2)Statistical reasoning: Consider both these are independant items A and B, then you can go for statistical test for independence. (Depends on the size of data points you need to decide whether you have to go for parametric or non parametric test) Then, check the P value and find out significant difference in mean value or not.