avehtari / ROS-Examples

Regression and other stories R examples
https://avehtari.github.io/ROS-Examples/
325 stars 256 forks source link

Clarification for normed weights in figure 20.15, page 410 #101

Closed rckwzrd closed 2 years ago

rckwzrd commented 3 years ago

It is stated in the text on page 410 that normed weights derived from propensity scores should average to 1. Why do the normed weights present in the figure in 20.15 not average to 1?

mean(c(0.625,1,2.5,1))
[1] 1.28125

Following the procedure laid out in the text on page 410 shouldn't the weights and psuedo population be closer to this:

ATE_w = c(1/(1-0.2),1/(1-0.5),1/0.2,1/0.5)
ATE_w_norm = ATE_w/mean(ATE_w)
n = c(80*ATE_w_norm[1], 50*ATE_w_norm[2], 20*ATE_w_norm[3], 50*ATE_w_norm[4])
print(ATE_w)
[1] 1.25 2.00 5.00 2.00
print(ATE_w_norm)
[1] 0.4878049 0.7804878 1.9512195 0.7804878
print(n)
[1] 39.02439 39.02439 39.02439 39.02439
print(mean(ATE_w_norm))
[1] 1

Both the normed weights in figure 20.15 and those above return the same sample ATE, which is what is expected from the text:

ATE = (n[1]*(120-110)+n[2]*(90-90)+n[3]*(120-110)+n[4]*(90-90))/(n[1]+n[2]+n[3]+n[4])
true_ATE = (80*(120-110)+50*(90-90)+20*(120-110)+50*(90-90))/(80+50+20+50)
print(ATE)
[1] 5
print(true_ATE)
[1] 5

Which set of normed weights are correct?

andrewgelman commented 2 years ago

(0.62580 + 150 + 2.520 + 150) / (80 + 50 + 20 + 50) = 1

avehtari commented 2 years ago

Thanks Andrew for the clarification

rckwzrd commented 2 years ago

this clarification does not help. thanks.