Conditions Under Which PLS Works Where OLS Fails

Version 2 | Created: 2026-11-02 | Updated: 2026-11-07 13:46 UTC
- 1. Purpose
- 2. Summary
- 3. Taxonomy and its Hierarchy
- 4. Singular Cross-Product Matrix
- 5. High Multicollinearity
- Appendix A. Terminology
- Appendix B. Worked Example
- Problem Statement: 입력 변수가 sample 보다 많거나 입력 변수끼리 선형으로 얽힌 데이터에서는 OLS (Ordinary Least Squares) 의 계수를 구할 수 없거나 계수가 크게 흔들린다.
- Goal: OLS 가 계수를 구하지 못하는 조건과 구하지만 불안정한 조건을 가르고, 각 조건에서 PLS (Partial Least Squares) 가 계수를 구하는 이유를 독자가 식으로 확인할 수 있게 한다.
-
Non-Goal: 성분 수
$K$ 를 고르는 절차와 Ridge 같은 penalty 방법은 다루지 않는다.
OLS 가 계수를 구할 수 없고 PLS 는 구할 수 있는 조건은 cross-product matrix
OLS 가 계수를 구할 수 있는지는 sample 수와 입력 변수 수의 관계, 그리고 입력 변수 열 사이의 선형 종속 정도의 두 축으로 정해진다. 두 축은 아래 Fig 1 과 같다.
Axis 1. Size of X (N x P) Axis 2. Dependence among the columns of X
------------------------- -----------------------------------------
P < N : fewer columns than rows independent : no column near a mix of others
P >= N : as many columns or more nearly dependent : a column close to a mix of others
exactly dependent: a column equal to a mix of others
Fig 1. Two axes that decide whether OLS has a unique solution
OLS 에서 PLS 로 내려가면 입력 변수의 모든 방향을 쓰는 대신 고른 방향
OLS regresses y on all P columns of X
| needs : X^T X invertible (rank P)
|
+-- PLS regresses y on K orthogonal scores, K <= rank(X)
gives up: directions of X beyond the K chosen ones
gains : no inverse of X^T X; works when P >= N or columns depend
Fig 2. Hierarchy from OLS to PLS
OLS 는
데이터 조건마다 OLS 와 PLS 의 결과는 Table 1 과 같다.
Table 1. OLS and PLS by data condition
| Condition | Rank of |
OLS | PLS | Section |
|---|---|---|---|---|
|
|
계수를 하나로 정할 수 없음 | 계수를 구함 | section 4 | |
| 완전 다중공선성 |
|
계수를 하나로 정할 수 없음 | 계수를 구함 | section 4 |
| 높은 다중공선성 | 계수를 구하지만 크게 흔들림 | 안정적인 계수 | section 5 | |
|
|
안정적인 계수 | 안정적인 계수 | - |
방법마다 가정, 설정값, 깨지는 조건, 쓰이는 곳은 Table 2 와 같다.
Table 2. Assumption, setting, failure condition and usage of each method
| Method | Assumption | Setting | Breaks when | Where used |
|---|---|---|---|---|
| OLS |
|
없음 |
|
변수가 적고 서로 독립인 데이터 |
| PLS |
|
성분 수 |
관계가 비선형일 때 | 센서 수백 개, 스펙트럼 같은 고차원 데이터 |
OLS 의 계수
식 (3) 대로 잔차 제곱합이 같은 계수가 끝없이 많으므로, OLS 는 계수를 하나로 정할 수 없다.
PLS 는
식 (4) 의 분모
다중공선성이 높지만 완전하지 않으면
열이 거의 종속이면 가장 작은 eigenvalue 가 0 에 가깝고, 식 (6) 에서
- centering: 각 열에서 그 열의 평균을 빼서 평균을 0 으로 만드는 처리.
-
cross-product matrix:
$\mathbf{X}^\top \mathbf{X}$ 로, 입력 변수 열끼리의 내적을 원소로 가진$P \times P$ 행렬. -
deflation: 찾은 score 가 설명한 부분을
$\mathbf{X}$ 에서 빼서, 다음 score 를 남은 정보에서 찾게 하는 단계. -
eigenvector: 행렬
$\mathbf{A}$ 에 곱해도 방향이 바뀌지 않는 벡터$\mathbf{v}$ 이며,$\mathbf{A}\mathbf{v} = \lambda\mathbf{v}$ 의$\lambda$ 를 그 eigenvector 의 eigenvalue 라 한다. - OLS (Ordinary Least Squares): 잔차 제곱합을 최소로 하는 계수를 구하는 선형 회귀.
-
PLS (Partial Least Squares):
$\mathbf{X}$ 와 타겟의 공분산이 큰 방향으로 score 를 뽑고 그 score 에 회귀하는 방법. - rank: 행렬의 선형독립인 열의 수. 차원과 rank 의 구별은 Dimension and Rank Primer 에 있다.
- score: Sample 을 한 방향으로 투영한 좌표값.
- singular matrix: 역행렬이 없는 정사각행렬이며, rank 가 행렬의 크기보다 작다.
- 다중공선성 (multicollinearity): 입력 변수 열 사이의 선형 상관이 높아, 한 열이 다른 열들의 선형결합에 가까운 상태.
- 완전 다중공선성 (perfect multicollinearity): 한 열이 다른 열들의 선형결합과 정확히 같은 상태.
아래 code 는 숨은 요인 두 개가 센서를 움직이고 그 가운데 하나가 두께를 정하는 데이터를 만들어, Table 1 의 앞 세 조건에서 OLS 와 PLS 를 견준다. 실행 환경은 NumPy 2.5.3, scikit-learn 1.9.1 이다.
# Python
import numpy as np
from sklearn.cross_decomposition import PLSRegression
rng = np.random.default_rng(0)
def sensors(n_wafers: int = None, n_sensors: int = None) -> tuple:
"""Return X driven by two hidden factors and a thickness y driven by the second one."""
factors = rng.standard_normal((n_wafers, 2))
loadings = rng.standard_normal((2, n_sensors))
X = factors @ loadings + 0.1 * rng.standard_normal((n_wafers, n_sensors))
y = 2.0 * factors[:, 1] + 0.1 * rng.standard_normal(n_wafers)
return X - X.mean(axis=0), y - y.mean()
# 1. P > N: 50 sensors, 20 wafers
X, y = sensors(n_wafers=20, n_sensors=50)
print(f"P > N : X {X.shape}, rank of X^T X = {np.linalg.matrix_rank(X.T @ X)} of {X.shape[1]}")
# Two different OLS coefficient vectors that fit the data equally well
beta_a = np.linalg.lstsq(X, y, rcond=None)[0]
null_direction = np.linalg.svd(X)[2][-1] # X @ null_direction is zero
beta_b = beta_a + 5.0 * null_direction
print(f" ||X beta_a - y|| = {np.linalg.norm(X @ beta_a - y):.2e}, "
f"||X beta_b - y|| = {np.linalg.norm(X @ beta_b - y):.2e}, "
f"||beta_a - beta_b|| = {np.linalg.norm(beta_a - beta_b):.2f}")
pls = PLSRegression(n_components=2, scale=False).fit(X, y)
print(f" PLS with K = 2: R^2 = {pls.score(X, y):.3f}")
print("-" * 72)
# 2. Perfect multicollinearity: one column is twice another
X, y = sensors(n_wafers=40, n_sensors=10)
X[:, 1] = 2.0 * X[:, 0]
print(f"perfect collin. : X {X.shape}, rank of X^T X = {np.linalg.matrix_rank(X.T @ X)} of {X.shape[1]}")
pls = PLSRegression(n_components=2, scale=False).fit(X, y)
print(f" PLS with K = 2: R^2 = {pls.score(X, y):.3f}")
print("-" * 72)
# 3. High multicollinearity: X^T X has an inverse, but a tiny eigenvalue
X, y = sensors(n_wafers=40, n_sensors=10)
eigenvalues = np.linalg.eigvalsh(X.T @ X)
print(f"high collin. : rank of X^T X = {np.linalg.matrix_rank(X.T @ X)} of {X.shape[1]}, "
f"eigenvalue max/min = {eigenvalues[-1] / eigenvalues[0]:.1e}")
# Refit 200 times with fresh noise in y, and measure how far the coefficients move
ols_runs, pls_runs = [], []
for _ in range(200):
y_new = y + 0.1 * rng.standard_normal(len(y))
ols_runs.append(np.linalg.solve(X.T @ X, X.T @ y_new))
pls_runs.append(PLSRegression(n_components=2, scale=False).fit(X, y_new).coef_.ravel())
print(f" mean sd of coefficients: OLS {np.std(ols_runs, axis=0).mean():.3f}, "
f"PLS {np.std(pls_runs, axis=0).mean():.3f}")실행 결과는 아래와 같다.
P > N : X (20, 50), rank of X^T X = 19 of 50
||X beta_a - y|| = 6.29e-15, ||X beta_b - y|| = 1.06e-14, ||beta_a - beta_b|| = 5.00
PLS with K = 2: R^2 = 0.994
------------------------------------------------------------------------
perfect collin. : X (40, 10), rank of X^T X = 9 of 10
PLS with K = 2: R^2 = 0.996
------------------------------------------------------------------------
high collin. : rank of X^T X = 10 of 10, eigenvalue max/min = 3.2e+03
mean sd of coefficients: OLS 0.164, PLS 0.003
- 첫 묶음: wafer 20 장을 centering 하여 rank 가
$N - 1 = 19$ 이다. 서로 5.00 떨어진 두 OLS 계수의 잔차가 모두$10^{-14}$ 수준이어서 식 (3) 대로 계수가 하나로 정해지지 않고, 잔차가 0 이어서 학습 데이터에 완전히 맞는다. - 둘째 묶음: 둘째 열을 첫째 열의 2 배로 두어 rank 가 10 중 9 이지만, PLS 는
$K = 2$ 로 계수를 구한다. - 셋째 묶음: 숨은 요인 두 개가 센서 10 개를 움직여 열이 거의 종속이다. 역행렬은 있지만, 잡음만 바꾼 200 번의 적합에서 OLS 계수가 PLS 계수보다 약 50 배 크게 흔들린다.

I liked the fact that this article encourages readers to think rather than simply accept a conclusion. The different points provide plenty of room for consideration. I have also written about a related topic on my website.
I found the explanations useful because they provide enough detail to understand the subject while keeping the language accessible. The article is easy to stay engaged with. I have also covered a connected subject on my website.