Skip to content
All library documents

How Regression Intercepts Affect Pairs-Trading Hedge Ratios

Article Quant Q&A · Author: James VanLandingham

Summary

The document examines why rolling ordinary least squares estimates of a pairs-trading hedge ratio can become unstable when the regression includes an intercept. The questioner observes that forcing the intercept to zero produces smoother beta estimates, but worries that this changes the residual spread’s mean and may create a biased equilibrium estimate. The setup uses log prices and compares rolling regressions; the author also notes that the real implementation uses a Kalman filter.

One response offers intuition: an intercept lets the spread’s equilibrium level vary, while a zero-intercept model constrains it to zero, which can leave beta less room to move. It suggests considering a theoretically justified fixed hedge ratio and mentions total least squares as a symmetric alternative, while making clear these ideas are not established solutions in the discussion. A follow-up presents a Kalman filter example and says its beta series looked more stable, but its noise parameters were chosen arbitrarily. The material is exploratory, not a controlled comparison or definitive guidance on intercept choice.

Key ideas

  • Including an intercept allows the estimated spread equilibrium to vary rather than fixing it at zero.
  • Constraining the intercept to zero can reduce beta variation while changing the residual spread’s equilibrium assumption.
  • A fixed hedge ratio or total least squares is mentioned as an alternative to ordinary regression estimation.
  • The Kalman filter example reports smoother estimates, but its noise settings are arbitrary and the evidence is not conclusive.

Tags

Full text
# Role of Intercept In OLS Beta Estimation


# Role of Intercept In OLS Beta Estimation












I am constructing a classic pairs trading strategy in which I use a linear estimator to model the spread of two assets opening a long-short market neutral position during times of divergence. I am struggling to understand how to estimate the appropriate hedge ratio via regression. Namely, I am confused regarding the role of the intercept term in the regression equation.

Assume we want to model a dynamic beta using a rolling regression window. With an intercept term included, our beta estimate becomes highly unstable (to the point of un-usability). Alternatively, if the intercept is forced to zero, beta becomes both more stabilize and, intuitively, a more reasonable estimate. That said, I have ready many papers on the subject of pairs trades and beta estimation and it seems that the intercept is included in most regression equations for beta estimation. Moreover, I have always been told that one should always include an intercept term or risk bias in the model. What then is causing of beta's instability? Should I include an intercept in hedge ratio estimation?

Finally, as my strategy is centered around modeling the spread of assets (i.e., the residuals of my regression), I have additional concerns about a non-zero mean of residuals caused by the intercept being forced to zero. I imagine that I could run parallel regressions i.e., a regression without intercept for optimal hedge ratio estimation and a second regression with intercept for obtaining unbiased residuals, but I have not seen this referenced in any of the literature. I think I may be fundamentally missing an piece of the puzzle. For what it's worth, my real model is using Kalman Filter to calculate the spread and beta, but I believe this model suffers from the same weaknesses and concerns as the more simple OLS example I have given.

Here is a graph of the daily beta estimate from a rolling regression with lookback window of 20 using an intercept:

And this is a graph of the daily beta estimate for the same regression with the intercept forced to zero:

Below is a minimal reproducible code snippet from Python:

```
import yfinance as yf
import numpy as np
from statsmodels.regression.rolling import RollingOLS

data = yf.download(['AAPL', 'MSFT'], start='2015-01-01').get('Adj Close')
data = np.log(data)

# Model with intercept

rmod = RollingOLS(
    endog=data['AAPL'],
    exog=sm.add_constant(data['MSFT']), # Adding intercept
    window=20,
)
rres = rmod.fit()

beta = rres.params['MSFT']

plt.plot(beta)
plt.title('AAPL/MSFT Rolling Regression (With Intercept)')
plt.show()

# Model with intercept frozen =0

rmod_nointercept = RollingOLS(
    endog=data['AAPL'],
    exog=data['MSFT'],
    window=20,
)
rres_nointercept = rmod_nointercept.fit()

beta = rres_nointercept.params['MSFT']

plt.plot(beta)
plt.title('AAPL/MSFT Rolling Regression (No Intercept)')
plt.show()
```

## Answer by mark leeds (score 1, accepted)

https://quant.stackexchange.com/a/73549

Hi James: I find your question and results interesting and I can't answer or say anything definitive but I experienced similar issues back in the day when I tried to use cointegration for pairs. Just a couple of things as far as some intuition and comments. I was hoping someone else would say something because I doubt this will help in any specific way towards your question.

- I think the reason for your result is that, when you allow for an intercept, you're kind of allowing the spread to have more freedom because it can vary around a non-zero value, whereas in the no-intercept model, the variation is always measured around zero. So, what that means for the error correction model is that the long term equilibrium value ( I don't know if I remember the terminology exactly but when I say, "long term error correction term", I'm referrring to $Y - X \beta - \mu$ in the error correction model ) has a different mean all the time. In the no-intercept case, the long term equilibrium in the error correction model is always zero. So, since the equilibrium value has to be zero, the $\beta$ doesn't have as much room to move around from period to period in the no-intercept model because the error correction term, $Y - X \beta$, needs be near zero, because $\mu = 0$.

- One thing I tried ( don't know if it will help you ) was not only take the intercept out ( to reduce variation in hedge ratio ) but also set $\beta$ to 1.0 and test those residuals for stationarity. Note that, when doing this, you have to use different tables because $\beta$ is assumed to be known. This approach provided an automatic of reducing estimation variation because, if you can't reject the null that $\beta = 1$, then that will clearly reduce estimation variation to zero because there is no estimation !!!!!!! I don't remember how much the setting of the hedge ratio to some known value such as 1.0 helped but I do remember the $\beta $ estimates being way too volatile so I tried that instead.

- You may want to take a look total least squares regression where $x$ and $y$ are treated symmetrically. Paul Teetor wrote an article on this approach ( google for his name. I think he has a website or the paper will come up. If you can't find it, let me know ) and I think his results were promising but I don't remember the details.

Note that I never tried total least squares myself but the fact that the E-G approach is not symmetric around $x$ and $y$ was always bothersome to me. I was never able to justify in my mind how the cointegration results could depend on which variable, $x$ or $y$, was chosen as the response.

Good luck and I hope this helped slightly.

```
                                            Mark
```

P.S: One thing to think about is what does it imply when you force such a value as $\beta = 1.0$ or some other fixed value. When fixing $\beta$ to a known value, what is one saying about the correction process versus letting there be an estimate of $\beta$ that could be say 2 or 4 or 0.5 ? I don't know if I can answer that now but I could back when I worked on it.

## Answer by James VanLandingham (score 1)

https://quant.stackexchange.com/a/73574

As a follow-up to my original post, I wanted to supply a Kalman Filter example as the Kalman Filter seems to solve the issue of dynamic beta as supplied by the rolling OLS while not suffering from instability of the estimate as demonstrated in the original post's rolling OLS graph.

Kalman Filter beta estimation for AAPL/MSFT for the same time period and interval as the original post. Note that I chose entirely arbitrary values for the noise variables, delta and Vt:

Below is a minimal reproducible code snippet from Python:

```
import yfinance as yf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pykalman import KalmanFilter

data = yf.download(['AAPL', 'MSFT'], start='2015-01-01').get('Adj Close')
data = np.log(data)

H = np.eye(2)
delta = 1e-5
vt = 0.1
Wt = delta / (1 - delta) * np.eye(2) 
R = np.ones((2,2)) 
theta = np.zeros(2) 

F = np.vstack([data.iloc[:, 0], np.ones(data.iloc[:, 0].shape)]).T[:, np.newaxis]

kf = KalmanFilter(
    n_dim_obs=1, n_dim_state=2,     
    initial_state_mean=theta,       
    initial_state_covariance=R,     
    transition_matrices=H,          
    observation_matrices=F,         
    observation_covariance=vt,      
    transition_covariance=Wt,
)

# State means are frequently represented by theta
state_means, state_covs = kf.filter(data.iloc[:, 1].values)

ser = pd.Series(state_means[:,0], index=data.index, name='beta')

ser.plot()
plt.title('AAPL/MSFT Kalman Filter Beta Estimates')
```

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.