[1] 193.5 402.5
回帰分析とマッチング
関西大学総合情報学部
2024-11-25
内生性: 処置変数と誤差項間の相関関係
もし、\(X\)をしたら(did)\(Y\)はどうなった(would)だろうか
割当メカニズム (assignment mechanism)
matching_data1.csv
の例(架空データ; 30行 \(\times\) 4列)
# A tibble: 10 × 4
ID Income Yaruki Rishu
<dbl> <dbl> <dbl> <dbl>
1 1 659 0 1
2 2 587 1 1
3 3 628 1 1
4 4 563 1 1
5 5 531 1 1
6 6 79 0 0
7 7 356 0 1
8 8 176 0 0
9 9 339 0 0
10 10 520 1 1
# A tibble: 10 × 4
ID Income Yaruki Rishu
<dbl> <dbl> <dbl> <dbl>
1 11 239 0 0
2 12 276 1 0
3 13 609 1 1
4 14 254 0 0
5 15 423 0 1
6 16 172 0 1
7 17 20 0 0
8 18 447 1 0
9 19 498 1 1
10 20 648 1 1
# A tibble: 10 × 4
ID Income Yaruki Rishu
<dbl> <dbl> <dbl> <dbl>
1 21 155 0 0
2 22 768 1 1
3 23 463 1 0
4 24 309 1 0
5 25 304 0 0
6 26 408 1 1
7 27 259 0 0
8 28 516 1 1
9 29 476 1 0
10 30 110 0 0
方法:処置変数と結果変数に影響を与える要因(交絡要因)を揃える
Yaruki == 0
)だけに絞ってみる[1] 193.5 402.5
ID | 所得 | やる気 | 履修 | ID | 所得 | やる気 | 履修 | |
---|---|---|---|---|---|---|---|---|
1 | 659 | 0 | 1 | 6 | 79 | 0 | 0 | |
7 | 356 | 0 | 1 | 8 | 176 | 0 | 0 | |
15 | 423 | 0 | 1 | 9 | 339 | 0 | 0 | |
16 | 172 | 0 | 1 | 11 | 239 | 0 | 0 | |
14 | 254 | 0 | 0 | |||||
17 | 20 | 0 | 0 | |||||
21 | 155 | 0 | 0 | |||||
25 | 304 | 0 | 0 | |||||
27 | 259 | 0 | 0 | |||||
30 | 110 | 0 | 0 | |||||
Mean | 402.5 | Mean | 193.5 |
方法: 処置変数と結果変数に影響を与える要因(交絡要因)を揃える
Yaruki == 1
)だけに絞ってみる[1] 394.2000 570.5455
ID | 所得 | やる気 | 履修 | ID | 所得 | やる気 | 履修 | |
---|---|---|---|---|---|---|---|---|
2 | 587 | 1 | 1 | 12 | 276 | 1 | 0 | |
3 | 628 | 1 | 1 | 18 | 447 | 1 | 0 | |
4 | 563 | 1 | 1 | 23 | 463 | 1 | 0 | |
5 | 531 | 1 | 1 | 24 | 309 | 1 | 0 | |
10 | 520 | 1 | 1 | 29 | 476 | 1 | 0 | |
13 | 609 | 1 | 1 | |||||
19 | 498 | 1 | 1 | |||||
20 | 648 | 1 | 1 | |||||
22 | 768 | 1 | 1 | |||||
26 | 408 | 1 | 1 | |||||
28 | 516 | 1 | 1 | |||||
Mean | 570.5 | Mean | 394.2 |
履修 (T) | 平均年収 (Y) |
---|---|
1 | 402.5 |
0 | 193.5 |
履修 (T) | 平均年収 (Y) |
---|---|
1 | 570.5 |
0 | 394.2 |
やる気のある(ない)被験者を一人の被験者として考える場合、差分はITEと解釈可能。
ID (i) | N | やる気 (Zi) | Yi(Ti = 1) | Yi(Ti = 0) | ITEi |
---|---|---|---|---|---|
1 | 14 | 0 | 402.5 | 193.5 | 209.0 |
2 | 16 | 1 | 570.5 | 394.2 | 176.3 |
割当メカニズムを想定し、交絡要因が同じユニット同士を比較
ID (i) | Zi | Ti | Y0, i | Y1, i |
---|---|---|---|---|
1 | 0 | 0 | 0 | 1 |
2 | 0 | 0 | 1 | 0 |
3 | 0 | 0 | 0 | 0 |
4 | 0 | 0 | 0 | 0 |
5 | 0 | 1 | 0 | 0 |
6 | 0 | 1 | 1 | 0 |
7 | 0 | 1 | 0 | 0 |
8 | 0 | 1 | 0 | 1 |
9 | 1 | 0 | 1 | 1 |
10 | 1 | 0 | 1 | 0 |
11 | 1 | 0 | 0 | 1 |
12 | 1 | 1 | 1 | 1 |
13 | 1 | 1 | 1 | 1 |
14 | 1 | 1 | 0 | 1 |
15 | 1 | 1 | 0 | 1 |
16 | 1 | 1 | 0 | 1 |
17 | 1 | 1 | 1 | 1 |
18 | 1 | 1 | 1 | 0 |
19 | 1 | 1 | 1 | 0 |
20 | 1 | 1 | 1 | 0 |
X | Y0 | Y1 |
---|---|---|
T = 0 | 0.429 | 0.429 |
T = 1 | 0.538 | 0.538 |
ID (i) | Zi | Ti | Y0, i | Y1, i |
---|---|---|---|---|
1 | 0 | 0 | 0 | 1 |
2 | 0 | 0 | 1 | 0 |
3 | 0 | 0 | 0 | 0 |
4 | 0 | 0 | 0 | 0 |
5 | 0 | 1 | 0 | 0 |
6 | 0 | 1 | 1 | 0 |
7 | 0 | 1 | 0 | 0 |
8 | 0 | 1 | 0 | 1 |
9 | 1 | 0 | 1 | 1 |
10 | 1 | 0 | 1 | 0 |
11 | 1 | 0 | 0 | 1 |
12 | 1 | 1 | 1 | 1 |
13 | 1 | 1 | 1 | 1 |
14 | 1 | 1 | 0 | 1 |
15 | 1 | 1 | 0 | 1 |
16 | 1 | 1 | 0 | 1 |
17 | 1 | 1 | 1 | 1 |
18 | 1 | 1 | 1 | 0 |
19 | 1 | 1 | 1 | 0 |
20 | 1 | 1 | 1 | 0 |
\(Z\) で条件づけた場合(\(Z = 0\))
X | Y0 | Y1 |
---|---|---|
T = 0 | 0.250 | 0.250 |
T = 1 | 0.250 | 0.250 |
ID (i) | Zi | Ti | Y0, i | Y1, i |
---|---|---|---|---|
1 | 0 | 0 | 0 | 1 |
2 | 0 | 0 | 1 | 0 |
3 | 0 | 0 | 0 | 0 |
4 | 0 | 0 | 0 | 0 |
5 | 0 | 1 | 0 | 0 |
6 | 0 | 1 | 1 | 0 |
7 | 0 | 1 | 0 | 0 |
8 | 0 | 1 | 0 | 1 |
9 | 1 | 0 | 1 | 1 |
10 | 1 | 0 | 1 | 0 |
11 | 1 | 0 | 0 | 1 |
12 | 1 | 1 | 1 | 1 |
13 | 1 | 1 | 1 | 1 |
14 | 1 | 1 | 0 | 1 |
15 | 1 | 1 | 0 | 1 |
16 | 1 | 1 | 0 | 1 |
17 | 1 | 1 | 1 | 1 |
18 | 1 | 1 | 1 | 0 |
19 | 1 | 1 | 1 | 0 |
20 | 1 | 1 | 1 | 0 |
\(Z\) で条件づけた場合 ( \(Z = 1\) )
X | Y0 | Y1 |
---|---|---|
T = 0 | 0.667 | 0.667 |
T = 1 | 0.667 | 0.667 |
ID (i) | Zi | Ti | Y0, i | Y1, i |
---|---|---|---|---|
1 | 0 | 0 | 0 | 1 |
2 | 0 | 0 | 1 | 0 |
3 | 0 | 0 | 0 | 0 |
4 | 0 | 0 | 0 | 0 |
5 | 0 | 1 | 0 | 0 |
6 | 0 | 1 | 1 | 0 |
7 | 0 | 1 | 0 | 0 |
8 | 0 | 1 | 0 | 1 |
9 | 1 | 0 | 1 | 1 |
10 | 1 | 0 | 1 | 0 |
11 | 1 | 0 | 0 | 1 |
12 | 1 | 1 | 1 | 1 |
13 | 1 | 1 | 1 | 1 |
14 | 1 | 1 | 0 | 1 |
15 | 1 | 1 | 0 | 1 |
16 | 1 | 1 | 0 | 1 |
17 | 1 | 1 | 1 | 1 |
18 | 1 | 1 | 1 | 0 |
19 | 1 | 1 | 1 | 0 |
20 | 1 | 1 | 1 | 0 |
条件付き独立が成立するということは
重回帰分析における回帰係数の解釈
重回帰分析とマッチングの結果が近似することも \(\bigcirc\)
実質的にマッチングと回帰分析は同じという見解も(Angrist and Pischke 2009)
3種類の因果効果
ID (i) | Yarukii | Yi(Ti = 1) | Yi(Ti = 0) | ITEi |
---|---|---|---|---|
1 | 0 | 659 | 193.5 | 465.5 |
2 | 1 | 587 | 394.2 | 192.8 |
3 | 1 | 628 | 394.2 | 233.8 |
4 | 1 | 563 | 394.2 | 168.8 |
5 | 1 | 531 | 394.2 | 136.8 |
7 | 0 | 356 | 193.5 | 162.5 |
... | ... | ... | ... | ... |
20 | 1 | 648 | 394.2 | 253.8 |
22 | 1 | 768 | 394.2 | 373.8 |
26 | 1 | 408 | 394.2 | 13.8 |
28 | 1 | 516 | 394.2 | 121.8 |
平均 | 185.1 |
ID (i) | Yarukii | Yi(Ti = 1) | Yi(Ti = 0) | ITEi |
---|---|---|---|---|
6 | 0 | 402.5 | 79 | 323.5 |
8 | 0 | 402.5 | 176 | 226.5 |
9 | 0 | 402.5 | 339 | 63.5 |
11 | 0 | 402.5 | 239 | 163.5 |
12 | 1 | 570.5 | 276 | 294.5 |
14 | 0 | 402.5 | 254 | 148.5 |
... | ... | ... | ... | ... |
25 | 0 | 402.5 | 304 | 98.5 |
27 | 0 | 402.5 | 259 | 143.5 |
29 | 1 | 570.5 | 476 | 94.5 |
30 | 0 | 402.5 | 110 | 292.5 |
平均 | 198.1 |
\[\text{ATE} = \frac{N_{\text{treated}}}{N_{\text{all}}} \text{ATT} + \frac{N_{\text{controlled}}}{N_{\text{all}}} \text{ATC}.\]
Nearest-neighbor Matching
「近さ」の基準
\[d(i, j) = |X_i - X_j| + |Y_i - Y_j| \text{ where } i \neq j.\]
\[d(i, j) = \sqrt{\Bigg(\frac{X_i - X_j}{\sigma_X}\Bigg)^2 + \Bigg(\frac{Y_i - Y_j}{\sigma_Y}\Bigg)^2} \text{ where } i \neq j.\]
\[d(i, j) = \sqrt{\frac{1}{1 - \rho^2_{X, Y}} \Bigg[\Bigg(\frac{X_i - X_j}{\sigma_X}\Bigg)^2 + \Bigg(\frac{Y_i - Y_j}{\sigma_Y}\Bigg)^2 - 2\rho_{X,Y}\Bigg(\frac{X_i - X_j}{\sigma_X}\Bigg) \Bigg(\frac{Y_i - Y_j}{\sigma_Y}\Bigg)\Bigg]} \text{ where } i \neq j.\]
ATTの場合、処置群のケースに統制群の中で最も近いケース1個を割当
k-最近傍マッチング
\[Y_i(T_i = 0) = \begin{cases}Y_i & \text{ if } T_i = 0\\ \frac{1}{K} \sum_{m = 1}^K Y_{j(m)} & \text{ if } T_i = 1\end{cases}\]
「カリパーマッチング」と訳される(訳されてない…?)
\[Y_i(T_i = 0) = \begin{cases}Y_i & \text{ if } T_i = 0\\ \frac{\sum_{j=1}^N I(T_j = 0, d(i, j) < h)\cdot Y_i}{\sum_{j=1}^N I(T_j = 0, d(i, j) < h)} & \text{ if } T_i = 1\end{cases}\]
Coarsened Exact Matching (Iacus, King, and Porro 2011)
matching_data2.csv
の例
ID | 年齢 | 教育 | 処置 | 結果 | ID | 年齢 | 教育 | 処置 | 結果 | |
---|---|---|---|---|---|---|---|---|---|---|
1 | 29 | 院 | 0 | 6 | 13 | 57 | 高 | 0 | 4 | |
2 | 41 | 大 | 0 | 3 | 14 | 25 | 院 | 1 | 5 | |
3 | 31 | 院 | 1 | 7 | 15 | 55 | 中 | 1 | 9 | |
4 | 39 | 院 | 0 | 5 | 16 | 48 | 院 | 0 | 2 | |
5 | 53 | 大 | 0 | 6 | 17 | 23 | 専 | 0 | 2 | |
6 | 59 | 大 | 0 | 1 | 18 | 34 | 大 | 1 | 4 | |
7 | 37 | 高 | 1 | 8 | 19 | 42 | 大 | 1 | 9 | |
8 | 44 | 中 | 0 | 4 | 20 | 23 | 高 | 0 | 4 | |
9 | 51 | 中 | 0 | 2 | 21 | 22 | 高 | 1 | 8 | |
10 | 59 | 小 | 1 | 8 | 22 | 49 | 大 | 0 | 9 | |
11 | 21 | 大 | 1 | 4 | 23 | 45 | 高 | 1 | 6 | |
12 | 24 | 中 | 1 | 6 | 24 | 33 | 大 | 0 | 8 |
年齢は10歳刻み、学歴は大卒以上・未満に層化
ID | 年齢 | 教育 | 処置 | 結果 | ID | 年齢 | 教育 | 処置 | 結果 | |
---|---|---|---|---|---|---|---|---|---|---|
1 | 20代 | H | 0 | 6 | 13 | 50代 | L | 0 | 4 | |
2 | 40代 | H | 0 | 3 | 14 | 20代 | H | 1 | 5 | |
3 | 30代 | H | 1 | 7 | 15 | 50代 | L | 1 | 9 | |
4 | 30代 | H | 0 | 5 | 16 | 40代 | H | 0 | 2 | |
5 | 50代 | H | 0 | 6 | 17 | 20代 | L | 0 | 2 | |
6 | 50代 | H | 0 | 1 | 18 | 30代 | H | 1 | 4 | |
7 | 30代 | L | 1 | 8 | 19 | 40代 | H | 1 | 9 | |
8 | 40代 | L | 0 | 4 | 20 | 20代 | L | 0 | 4 | |
9 | 50代 | L | 0 | 2 | 21 | 20代 | L | 1 | 8 | |
10 | 50代 | L | 1 | 8 | 22 | 40代 | H | 0 | 9 | |
11 | 20代 | H | 1 | 4 | 23 | 40代 | L | 1 | 6 | |
12 | 20代 | L | 1 | 6 | 24 | 30代 | H | 0 | 8 |
層ごとにケースをマッチング
年齢 | 教育 |
処置群
|
統制群
|
||||
---|---|---|---|---|---|---|---|
ID | 処置 | 結果 | ID | 処置 | 結果 | ||
20代 | H | 11 | 1 | 5 | 1 | 0 | 6 |
20代 | H | 14 | 1 | 5 | |||
20代 | L | 12 | 1 | 6 | 17 | 0 | 2 |
20代 | L | 21 | 1 | 8 | 20 | 0 | 4 |
30代 | H | 3 | 1 | 7 | 4 | 0 | 5 |
30代 | H | 18 | 1 | 4 | 24 | 0 | 8 |
30代 | L | 7 | 1 | 8 | |||
40代 | H | 19 | 1 | 9 | 2 | 0 | 3 |
40代 | H | 16 | 0 | 2 | |||
40代 | H | 22 | 0 | 9 | |||
40代 | L | 23 | 1 | 6 | 8 | 0 | 4 |
50代 | H | 5 | 0 | 6 | |||
50代 | H | 6 | 0 | 1 | |||
50代 | L | 10 | 1 | 8 | 9 | 0 | 2 |
50代 | L | 15 | 1 | 9 | 13 | 0 | 4 |
ペアが組めない層を除外(30代Lと50代H)
年齢 | 教育 |
処置群
|
統制群
|
||||
---|---|---|---|---|---|---|---|
ID | 処置 | 結果 | ID | 処置 | 結果 | ||
20代 | H | 11 | 1 | 5 | 1 | 0 | 6 |
20代 | H | 14 | 1 | 5 | |||
20代 | L | 12 | 1 | 6 | 17 | 0 | 2 |
20代 | L | 21 | 1 | 8 | 20 | 0 | 4 |
30代 | H | 3 | 1 | 7 | 4 | 0 | 5 |
30代 | H | 18 | 1 | 4 | 24 | 0 | 8 |
40代 | H | 19 | 1 | 9 | 2 | 0 | 3 |
40代 | H | 16 | 0 | 2 | |||
40代 | H | 22 | 0 | 9 | |||
40代 | L | 23 | 1 | 6 | 8 | 0 | 4 |
50代 | L | 10 | 1 | 8 | 9 | 0 | 2 |
50代 | L | 15 | 1 | 9 | 13 | 0 | 4 |
各ユニットの重みを計算
\[w_i = \begin{cases} 1 & \text{ if } T_i = 1, \\ \frac{m_C}{m_T} \cdot \frac{m^s_T}{m^s_C} & \text{ if } T_i = 0.\end{cases}\]
年齢 | 教育 |
処置群
|
統制群
|
||||||
---|---|---|---|---|---|---|---|---|---|
ID | 処置 | 結果 | 重み | ID | 処置 | 結果 | 重み | ||
20代 | H | 11 | 1 | 5 | 1 | 1 | 0 | 6 | 2.2 |
20代 | H | 14 | 1 | 5 | 1 | ||||
20代 | L | 12 | 1 | 6 | 1 | 17 | 0 | 2 | 1.1 |
20代 | L | 21 | 1 | 8 | 1 | 20 | 0 | 4 | 1.1 |
30代 | H | 3 | 1 | 7 | 1 | 4 | 0 | 5 | 1.1 |
30代 | H | 18 | 1 | 4 | 1 | 24 | 0 | 8 | 1.1 |
40代 | H | 19 | 1 | 9 | 1 | 2 | 0 | 3 | 0.367 |
40代 | H | 16 | 0 | 2 | 0.367 | ||||
40代 | H | 22 | 0 | 9 | 0.367 | ||||
40代 | L | 23 | 1 | 6 | 1 | 8 | 0 | 4 | 1.1 |
50代 | L | 10 | 1 | 8 | 1 | 9 | 0 | 2 | 1.1 |
50代 | L | 15 | 1 | 9 | 1 | 13 | 0 | 4 | 1.1 |
重み付け回帰分析
lm(formula, data, weight = ...)
で推定可能
Propensity Score
処置変数(\(T_i\))を応答変数とし、共変量(\(X_i\))を説明変数とする。
オブジェクト名$fitted.value
で抽出可割り当てメカニズムを仮定
\[Pr(\text{処置}) \propto \beta_0 + \beta_1 \cdot \text{年齢} + \beta_2 \cdot \text{教育}\]
ID | 年齢 | 教育 | 処置 | 結果 | ID | 年齢 | 教育 | 処置 | 結果 | |
---|---|---|---|---|---|---|---|---|---|---|
1 | 29 | 6 | 0 | 6 | 13 | 57 | 3 | 0 | 4 | |
2 | 41 | 5 | 0 | 3 | 14 | 25 | 6 | 1 | 5 | |
3 | 31 | 6 | 1 | 7 | 15 | 55 | 2 | 1 | 9 | |
4 | 39 | 6 | 0 | 5 | 16 | 48 | 6 | 0 | 2 | |
5 | 53 | 5 | 0 | 6 | 17 | 23 | 4 | 0 | 2 | |
6 | 59 | 5 | 0 | 1 | 18 | 34 | 5 | 1 | 4 | |
7 | 37 | 3 | 1 | 8 | 19 | 42 | 5 | 1 | 9 | |
8 | 44 | 2 | 0 | 4 | 20 | 23 | 3 | 0 | 4 | |
9 | 51 | 2 | 0 | 2 | 21 | 22 | 3 | 1 | 8 | |
10 | 59 | 1 | 1 | 8 | 22 | 49 | 5 | 0 | 9 | |
11 | 21 | 5 | 1 | 4 | 23 | 45 | 3 | 1 | 6 | |
12 | 24 | 2 | 1 | 6 | 24 | 33 | 5 | 0 | 8 |
傾向スコアの算出
(1) | |
---|---|
(Intercept) | 3.839 (2.364) |
Age | -0.059 (0.039) |
Edu | -0.420 (0.304) |
Num.Obs. | 24 |
AIC | 35.5 |
F | 1.486 |
予測確率の抽出
1 2 3 4 5 6 7 8
0.4057364 0.3393856 0.3777795 0.2751913 0.2025844 0.1515735 0.6006657 0.6028218
9 10 11 12 13 14 15 16
0.5016153 0.4891956 0.6242461 0.8307399 0.3174741 0.4633432 0.4431796 0.1829360
17 18 19 20 21 22 23 24
0.6921133 0.4365297 0.3263554 0.7737818 0.7838885 0.2431492 0.4847003 0.4510136
傾向スコアの抽出
ID | 年齢 | 教育 | 処置 | 結果 | PS | ID | 年齢 | 教育 | 処置 | 結果 | PS | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 29 | 6 | 0 | 6 | 0.406 | 13 | 57 | 3 | 0 | 4 | 0.317 | |
2 | 41 | 5 | 0 | 3 | 0.339 | 14 | 25 | 6 | 1 | 5 | 0.463 | |
3 | 31 | 6 | 1 | 7 | 0.378 | 15 | 55 | 2 | 1 | 9 | 0.443 | |
4 | 39 | 6 | 0 | 5 | 0.275 | 16 | 48 | 6 | 0 | 2 | 0.183 | |
5 | 53 | 5 | 0 | 6 | 0.203 | 17 | 23 | 4 | 0 | 2 | 0.692 | |
6 | 59 | 5 | 0 | 1 | 0.152 | 18 | 34 | 5 | 1 | 4 | 0.437 | |
7 | 37 | 3 | 1 | 8 | 0.601 | 19 | 42 | 5 | 1 | 9 | 0.326 | |
8 | 44 | 2 | 0 | 4 | 0.603 | 20 | 23 | 3 | 0 | 4 | 0.774 | |
9 | 51 | 2 | 0 | 2 | 0.502 | 21 | 22 | 3 | 1 | 8 | 0.784 | |
10 | 59 | 1 | 1 | 8 | 0.489 | 22 | 49 | 5 | 0 | 9 | 0.243 | |
11 | 21 | 5 | 1 | 4 | 0.624 | 23 | 45 | 3 | 1 | 6 | 0.485 | |
12 | 24 | 2 | 1 | 6 | 0.831 | 24 | 33 | 5 | 0 | 8 | 0.451 |
ATT:傾向スコアが最も近い統制群を割り当てる
処置群
|
統制群
|
差分 | |||||
---|---|---|---|---|---|---|---|
ID | 結果 | PS | ID | 結果 | PS | ||
3 | 7 | 0.378 | 1 | 6 | 0.406 | 1 | |
7 | 8 | 0.601 | 8 | 4 | 0.603 | 4 | |
10 | 8 | 0.489 | 9 | 2 | 0.502 | 6 | |
11 | 4 | 0.624 | 8 | 4 | 0.603 | 0 | |
12 | 6 | 0.831 | 20 | 4 | 0.774 | 2 | |
14 | 5 | 0.463 | 24 | 8 | 0.451 | -3 | |
15 | 9 | 0.443 | 24 | 8 | 0.451 | 1 | |
18 | 4 | 0.437 | 24 | 8 | 0.451 | -4 | |
19 | 9 | 0.326 | 13 | 4 | 0.317 | 5 | |
21 | 8 | 0.784 | 20 | 4 | 0.774 | 4 | |
23 | 6 | 0.485 | 9 | 2 | 0.502 | 4 | |
差分の平均値 (ATT): 1.818 |
ATC:傾向スコアが最も近い処置群を割り当てる
処置群
|
統制群
|
差分 | |||||
---|---|---|---|---|---|---|---|
ID | 結果 | PS | ID | 結果 | PS | ||
3 | 7 | 0.378 | 1 | 6 | 0.406 | 1 | |
19 | 9 | 0.326 | 2 | 3 | 0.339 | 6 | |
19 | 9 | 0.326 | 4 | 5 | 0.275 | 4 | |
19 | 9 | 0.326 | 5 | 6 | 0.203 | 3 | |
19 | 9 | 0.326 | 6 | 1 | 0.152 | 8 | |
7 | 8 | 0.601 | 8 | 4 | 0.603 | 4 | |
10 | 8 | 0.489 | 9 | 2 | 0.502 | 6 | |
19 | 9 | 0.326 | 13 | 4 | 0.317 | 5 | |
19 | 9 | 0.326 | 16 | 2 | 0.183 | 7 | |
11 | 4 | 0.624 | 17 | 2 | 0.692 | 2 | |
21 | 8 | 0.784 | 20 | 4 | 0.774 | 4 | |
19 | 9 | 0.326 | 22 | 9 | 0.243 | 0 | |
15 | 9 | 0.443 | 24 | 8 | 0.451 | 1 | |
差分の平均値 (ATC): 3.923 |
ATE:ATTとATCの加重平均
\[\begin{align}\text{ATE} & = \frac{N_\text{Treat}}{N_\text{All}}\text{ATT} + \frac{N_\text{Control}}{N_\text{All}}\text{ATC} \\ & = \frac{11}{24} 1.818 + \frac{13}{24} 3.923 = 2.958\end{align}\]
処置を受ける確率 = 傾向スコア
IPW:Inverse Probability Weighting(Rubin 1985)
\[w_i = \begin{cases}\frac{1}{e_i} & \text{ if } T_i = 1, \\ \frac{1}{1 - e_i} & \text{ if } T_i = 0.\end{cases}\]
IPW:Inverse Probability Weighting(Rubin 1985)
\[w_i = T_i \frac{1}{e_i} + (1 - T_i) \frac{1}{1 - e_i}.\]
ID (i) | Zi | Ti | Y0, i | Y1, i |
---|---|---|---|---|
1 | 0 | 0 | 0 | 1 |
2 | 0 | 0 | 1 | 0 |
3 | 0 | 0 | 0 | 0 |
4 | 0 | 0 | 0 | 0 |
5 | 0 | 1 | 0 | 0 |
6 | 0 | 1 | 1 | 0 |
7 | 0 | 1 | 0 | 0 |
8 | 0 | 1 | 0 | 1 |
9 | 1 | 0 | 1 | 1 |
10 | 1 | 0 | 1 | 0 |
11 | 1 | 0 | 0 | 1 |
12 | 1 | 1 | 1 | 1 |
13 | 1 | 1 | 1 | 1 |
14 | 1 | 1 | 0 | 1 |
15 | 1 | 1 | 0 | 1 |
16 | 1 | 1 | 0 | 1 |
17 | 1 | 1 | 1 | 1 |
18 | 1 | 1 | 1 | 0 |
19 | 1 | 1 | 1 | 0 |
20 | 1 | 1 | 1 | 0 |
条件付き独立の例のデータ(matching_data3.csv
)
ID (i) | Zi | Ti | Y0, i | Y1, i | ei | Wi |
---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | ? | 0.50 | 2.00 |
2 | 0 | 0 | 1 | ? | 0.50 | 2.00 |
3 | 0 | 0 | 0 | ? | 0.50 | 2.00 |
4 | 0 | 0 | 0 | ? | 0.50 | 2.00 |
5 | 0 | 1 | ? | 0 | 0.50 | |
6 | 0 | 1 | ? | 0 | 0.50 | |
7 | 0 | 1 | ? | 0 | 0.50 | |
8 | 0 | 1 | ? | 1 | 0.50 | |
9 | 1 | 0 | 1 | ? | 0.75 | 4.00 |
10 | 1 | 0 | 1 | ? | 0.75 | 4.00 |
11 | 1 | 0 | 0 | ? | 0.75 | 4.00 |
12 | 1 | 1 | ? | 1 | 0.75 | |
13 | 1 | 1 | ? | 1 | 0.75 | |
14 | 1 | 1 | ? | 1 | 0.75 | |
15 | 1 | 1 | ? | 1 | 0.75 | |
16 | 1 | 1 | ? | 1 | 0.75 | |
17 | 1 | 1 | ? | 1 | 0.75 | |
18 | 1 | 1 | ? | 0 | 0.75 | |
19 | 1 | 1 | ? | 0 | 0.75 | |
20 | 1 | 1 | ? | 0 | 0.75 |
もし、全ケースが統制群なら?
ID (i) | Zi | Ti | Y0, i | Y1, i | ei | Wi |
---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | ? | 0.50 | |
2 | 0 | 0 | 1 | ? | 0.50 | |
3 | 0 | 0 | 0 | ? | 0.50 | |
4 | 0 | 0 | 0 | ? | 0.50 | |
5 | 0 | 1 | ? | 0 | 0.50 | 2.00 |
6 | 0 | 1 | ? | 0 | 0.50 | 2.00 |
7 | 0 | 1 | ? | 0 | 0.50 | 2.00 |
8 | 0 | 1 | ? | 1 | 0.50 | 2.00 |
9 | 1 | 0 | 1 | ? | 0.75 | |
10 | 1 | 0 | 1 | ? | 0.75 | |
11 | 1 | 0 | 0 | ? | 0.75 | |
12 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
13 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
14 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
15 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
16 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
17 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
18 | 1 | 1 | ? | 0 | 0.75 | 1.33 |
19 | 1 | 1 | ? | 0 | 0.75 | 1.33 |
20 | 1 | 1 | ? | 0 | 0.75 | 1.33 |
もし、全ケースが処置群なら?
ID (i) | Zi | Ti | Y0, i | Y1, i | ei | Wi |
---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | ? | 0.50 | 2.00 |
2 | 0 | 0 | 1 | ? | 0.50 | 2.00 |
3 | 0 | 0 | 0 | ? | 0.50 | 2.00 |
4 | 0 | 0 | 0 | ? | 0.50 | 2.00 |
5 | 0 | 1 | ? | 0 | 0.50 | 2.00 |
6 | 0 | 1 | ? | 0 | 0.50 | 2.00 |
7 | 0 | 1 | ? | 0 | 0.50 | 2.00 |
8 | 0 | 1 | ? | 1 | 0.50 | 2.00 |
9 | 1 | 0 | 1 | ? | 0.75 | 4.00 |
10 | 1 | 0 | 1 | ? | 0.75 | 4.00 |
11 | 1 | 0 | 0 | ? | 0.75 | 4.00 |
12 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
13 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
14 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
15 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
16 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
17 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
18 | 1 | 1 | ? | 0 | 0.75 | 1.33 |
19 | 1 | 1 | ? | 0 | 0.75 | 1.33 |
20 | 1 | 1 | ? | 0 | 0.75 | 1.33 |
W
の和: 20W
の和: 20W
の和はサンプルサイズと一致するID (i) | Zi | Ti | Y0, i | Y1, i | ei | Wi |
---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | ? | 0.50 | 2.00 |
2 | 0 | 0 | 1 | ? | 0.50 | 2.00 |
3 | 0 | 0 | 0 | ? | 0.50 | 2.00 |
4 | 0 | 0 | 0 | ? | 0.50 | 2.00 |
5 | 0 | 1 | ? | 0 | 0.50 | 2.00 |
6 | 0 | 1 | ? | 0 | 0.50 | 2.00 |
7 | 0 | 1 | ? | 0 | 0.50 | 2.00 |
8 | 0 | 1 | ? | 1 | 0.50 | 2.00 |
9 | 1 | 0 | 1 | ? | 0.75 | 4.00 |
10 | 1 | 0 | 1 | ? | 0.75 | 4.00 |
11 | 1 | 0 | 0 | ? | 0.75 | 4.00 |
12 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
13 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
14 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
15 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
16 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
17 | 1 | 1 | ? | 1 | 0.75 | 1.33 |
18 | 1 | 1 | ? | 0 | 0.75 | 1.33 |
19 | 1 | 1 | ? | 0 | 0.75 | 1.33 |
20 | 1 | 1 | ? | 0 | 0.75 | 1.33 |
\[\mathbb{E}^w[Y_1] - \mathbb{E}^w[Y_0] = 0\]
共変量選択の基準は (星野 2009; Imbens and Rubin 2015など)
VanderWeele (2019) のmodified disjunctive cause criterion
DAGitty — draw and analyze causal diagrams
{ggdag}を用いた可視化
lalondeは様々なパッケージがサンプルデータとして提供しているが、本講義では{cobalt}のlalondeデータセットを利用
data("lalonde", package = "cobalt")
で読み込み
# A tibble: 614 × 9
treat age educ race married nodegree re74 re75 re78
<int> <int> <int> <fct> <int> <int> <dbl> <dbl> <dbl>
1 1 37 11 black 1 1 0 0 9930.
2 1 22 9 hispan 0 1 0 0 3596.
3 1 30 12 black 0 0 0 0 24909.
4 1 27 11 black 0 1 0 0 7506.
5 1 33 8 black 0 1 0 0 290.
6 1 22 9 black 0 1 0 0 4056.
7 1 23 12 black 0 0 0 0 0
8 1 32 11 black 0 1 0 0 8472.
9 1 22 16 black 0 0 0 0 2164.
10 1 33 12 white 1 0 0 0 12418.
# ℹ 604 more rows
変数名 | 説明 | |
---|---|---|
1 | treat |
職業訓練の履修有無 |
2 | age |
年齢 |
3 | educ |
教育年数 |
4 | race |
人種 |
5 | married |
結婚有無 |
6 | nodegree |
学位有無 |
7 | re74 |
1974年の所得 |
8 | re75 |
1975年の所得 |
9 | re78 |
1978年の所得 |