## Saturday, April 23, 2011

### The many facets of linear regression

Many years ago, a portfolio manager asked me in a phone interview: "Do you believe that linear or nonlinear models are more powerful in building trading models?" Being a babe-in-the-woods, I did not hesitate in answering "Nonlinear!" Little did I know that this is the question that separate the men from the boys in the realm of quantitative trading. Subsequent experiences showed me that nonlinear models have mostly been unmitigated disasters in terms of trading profits. As Max Dama said in a recent excellent article on linear regression: "...when the signal to noise ratio is .05:1, ... there’s not much point in worrying about [higher order effects]". One is almost certain to overfit a nonlinear model to non-recurring noise.

Until recently, I have used linear regression mainly in finding hedge ratios between two instruments in pair trading, or more generally in finding the weightings (in number of shares) of individual stocks in a basket in some form of index arbitrage. Of course, others have found linear algebra useful in principal component analysis and more generally factor analysis as well. But thanks to a number of commenters on this blog as well as various private correspondents, I have begun to apply linear regression more directly in trading models.

One way to directly apply linear regression to trading is to use it in place of moving averages. Using moving average implicitly assumes that there is no trend in a price series, that the mean of the prices will remain the same. This of course may not be true. So using linear regression to project the current equilibrium price is sometimes more accurate than just setting it equal to a moving average. I have found that in some cases, this equilibrium price results in better mean-reverting models: e.g. short an instrument when its current price is way above the equilibrium price. Of course, one can also use linear regression in a similar way in momentum models: e.g. if the current price is way above the equilibrium price, consider this a "breakout" and buy the instrument.

Max in his article referenced above also pointed out a more sophisticated version of linear regression, commonly called "weighted least squares regression" (WLS). WLS is to linear regression what exponential moving average (EMA) is to simple moving average (SMA): it gives more weights to recent data points. Indeed I have found that EMA often gives better results than SMA in trading. However, so far I have not found WLS to be better than simple least squares. Max also referenced an article which establishes the equivalence between weighted least squares and Kalman filter. Now Kalman filter is a linear model that is very popular among quantitative traders. The nice feature about Kalman filter is that there is very few free parameters: the model will adapt itself to the means and covariances of the input time series gradually. And furthermore, it can do so one-step at a time (or in technical jargon, using an "online" algorithm) : i.e., there is no need to separate the data into "training" and "test" sets, and no need to define a "lookback" period unlike moving averages. It makes use of "hidden states" much like Hidden Markov Models (HHM), but unlike HHM, Kalman filter is faithfully linear.

I haven't used Kalman filter much myself, but I would welcome any comments from our readers on its usage. Also, if you know of other ways to use linear regression in trading, do share with us here!
{"ft_lang_label":"__label__en","ft_lang_prob":0.94459367,"math_prob":0.8209195,"size":3461,"snap":"2021-31-2021-39","text_gpt3_token_len":708,"char_repetition_ratio":0.12207116,"word_repetition_ratio":0.010434783,"special_character_ratio":0.19994222,"punctuation_ratio":0.10502283,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9794036,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-08-02T03:27:58Z\",\"WARC-Record-ID\":\"<urn:uuid:5db1e466-3465-4977-9a82-15c9f0fafad8>\",\"Content-Length\":\"93648\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7e05876f-5d12-406b-aef3-5e667dff2342>\",\"WARC-Concurrent-To\":\"<urn:uuid:ae4312cf-e49d-414b-bd66-9f529da73257>\",\"WARC-IP-Address\":\"172.217.2.97\",\"WARC-Target-URI\":\"http://epchan.blogspot.com/2011/04/\",\"WARC-Payload-Digest\":\"sha1:6P6EZBKL6JCWXKU26C2OH3JK5DRPVST6\",\"WARC-Block-Digest\":\"sha1:NNX2ERTFNJVQ4TL7YCLGKSADZFGD2HMK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046154302.46_warc_CC-MAIN-20210802012641-20210802042641-00050.warc.gz\"}"}