# How do I incorporate time-variability in a pair trading framework?

Recently I have been looking at pair trading strategies from a cointegration perspective, as described in chapter 5 of Carol Alexander's Market Risk Analysis volume 2. As most quantitative finance texts the science is well explained, but the description of applications is a bit on the light side.

Theoretically it's pretty straightforward and easy to run the tests for a given time period to see whether a certain pair is likely to be conintegrated or not. To apply the theory to an actual pairs trade however, I would like to add the time dimension to my parameters.

If I simply model the spread as $residuals = y - \alpha - \beta x$, the first thing I'd like to know is the mean and variance of the residuals. In order to setup my bid/ask limits I must have a mean and some measure of the variance. In an ideal case the two would be stable, but how can I quantify this and incorporate the information into the model? Also, how can I make this analysis structural, rather than having to depend on subjective eye-balling of data?

Could anyone point me in the right direction here? My guess is that I should take a look at regime switching models. But since that topic is unknown to me, I'd appreciate very much if someone could give some pointers so I can avoid the worst pitfalls.

EDIT: Perhaps I wasn't clear enough, but my question is not how to do the tests, it's how can do can I quantify the stability of the parameters, i.e., the mean and variance of the spread?

-

If you're using R and would like a few examples, here's Paul Teetor's website:

And, Ernie Chan's website:

http://epchan.blogspot.com/

Energy pairs: