# Why does matrix condition number change drastically when a constant is added?

If I create a regression model design matrix with 3 uncorrelated variables, I get a small condition number as expected. MWE:

> import numpy as np, pandas as pd
> n = 1000
> X = pd.DataFrame()
> X['x1'] = np.random.normal(size=n) * 500
> X['x2'] = np.random.normal(size=n) * 200
> X['x3'] = np.random.normal(size=n) * 300
> print(np.linalg.cond(X))

2.4566193714711306


But if I add a constant to the design matrix (as expected in python statsmodels), my condition number blows up:

> import numpy as np, pandas as pd
> n = 1000
> X = pd.DataFrame()
> X['x0'] = [1] * n
> X['x1'] = np.random.normal(size=n) * 500
> X['x2'] = np.random.normal(size=n) * 200
> X['x3'] = np.random.normal(size=n) * 300
> print(np.linalg.cond(X))

497.654501825216


Accordingly, I have an extremely high condition number and warning of multicollinearity when I estimate my model even though none of my predictors (or constant) are correlated. Why does the design matrix's condition number change drastically when a constant is added?

• I wonder what happens when you drop all the "00" from the scaling constants :-).
– whuber
Mar 9, 2018 at 15:02