Propensity Score Matching (PSM)
정의
Propensity Score가 유사한 처치군과 대조군 개인을 매칭
여기서 는 Propensity Score.
직관적 이해
왜 PS로 매칭?
Rosenbaum & Rubin (1983):
- PS가 같으면 처치 확률이 같음
- → 고차원 대신 스칼라 로 매칭 가능
- 차원 축소: Curse of dimensionality 완화
예시
| 환자 | 나이 | 성별 | 병력 | PS |
|---|---|---|---|---|
| A (처치) | 45 | M | 고혈압 | 0.72 |
| B (대조) | 52 | F | 당뇨 | 0.70 |
는 다르지만 가 유사 → 매칭 가능.
절차
1단계: PS 추정
방법:
- Logistic regression (일반적)
- Random forest
- Gradient boosting
- Neural network
2단계: 매칭
각 처치군 개인에 대해 PS가 가장 유사한 대조군 찾기:
For each treated unit i:
Find control j* with |e(Xi) - e(Xj)| minimized
Match (i, j*)
3단계: 효과 추정
매칭 옵션
1. Caliper
거리 제한:
일반적으로 .
2. 1:k Matching
처치 1명당 대조 k명 매칭:
- k=1: 표준
- k>1: 분산 감소, 편향 증가 가능
3. With/Without Replacement
| 옵션 | 장점 | 단점 |
|---|---|---|
| With | 좋은 매칭, 편향↓ | 분산↑, 일부 대조군 과다 사용 |
| Without | 분산↓, 공정 | 매칭 품질↓ |
장단점
장점
| 장점 | 설명 |
|---|---|
| 차원 축소 | 고차원 X → 스칼라 PS |
| 직관적 | ”유사 확률 비교” |
| 투명성 | 매칭 쌍 검토 가능 |
| 유연성 | 다양한 매칭 옵션 |
단점
| 단점 | 설명 |
|---|---|
| PS 모델 의존 | PS 오특정 시 편향 |
| 정보 손실 | 매칭 안 된 샘플 제외 |
| 분산 | IPW보다 효율 낮을 수 있음 |
| 매칭 품질 | 나쁜 매칭 가능 |
품질 평가
균형 확인
매칭 후 공변량 분포 비교:
기준:
시각화
import matplotlib.pyplot as plt
# 매칭 전후 PS 분포
plt.subplot(1, 2, 1)
plt.hist(ps[W==1], alpha=0.5, label='Treated')
plt.hist(ps[W==0], alpha=0.5, label='Control')
plt.title('Before Matching')
plt.subplot(1, 2, 2)
plt.hist(ps_matched[W_matched==1], alpha=0.5, label='Treated')
plt.hist(ps_matched[W_matched==0], alpha=0.5, label='Control')
plt.title('After Matching')
구현
R (MatchIt)
library(MatchIt)
# PSM with 1:1 nearest neighbor
m.out <- matchit(treat ~ x1 + x2 + x3,
data = df,
method = "nearest",
distance = "logit",
caliper = 0.2)
# 균형 확인
summary(m.out)
# 매칭 데이터
matched_data <- match.data(m.out)
# ATT 추정
lm(y ~ treat, data = matched_data, weights = weights)
Python
from sklearn.linear_model import LogisticRegression
from sklearn.neighbors import NearestNeighbors
# PS 추정
lr = LogisticRegression()
lr.fit(X, W)
ps = lr.predict_proba(X)[:, 1]
# 매칭
treated_idx = np.where(W == 1)[0]
control_idx = np.where(W == 0)[0]
nn = NearestNeighbors(n_neighbors=1)
nn.fit(ps[control_idx].reshape(-1, 1))
distances, matches = nn.kneighbors(ps[treated_idx].reshape(-1, 1))
# ATT 추정
att = np.mean(Y[treated_idx] - Y[control_idx[matches.flatten()]])
관련 개념
- Matching Methods Overview - 매칭 방법 통합
- Propensity Score - 핵심 도구
- Nearest Neighbor Matching - 일반 NNM
- ATT - PSM의 주요 추정 대상
- Selection Bias - 해결 대상
참고 논문
- Rosenbaum, P. R., & Rubin, D. B. (1983). The central role of the propensity score
- yaoSurveyCausalInference2021 - Section 3.3
- Caliendo, M., & Kopeinig, S. (2008). Some practical guidance for PSM