index.control 和 index.treated 在 R 的匹配包中的匹配数据集中

index.control and index.treated in matched dataset from R's Match Package

提问人:Hack-R 提问时间:2/12/2016 最后编辑:Hack-R 更新时间:2/12/2016 访问量:645

问:

我在使用伯克利的 J. Sekhon 的 R 包进行倾向得分匹配分析时得到了一些意想不到的结果。Matching

在运行具有匹配倾向分数的函数后,我尝试使用“治疗对已处理对象的平均效果”的 和 字段查看匹配的治疗组和对照组的恢复数据集。index.treatedindex.controlMatching

?Matching指示索引号是原始数据集中的观测值(行)。如果这是真的,我会感到非常困惑,因为原始数据中的相应行包含处理和对照的混合,其中应该只有 ID 的处理观察结果和相应的对照组。index.treatedindex.control

下面我尝试使用手册页中使用的内置数据集重现此错误。但是,结果看起来不错:

data(lalonde)

#
# Estimate the propensity model
#
glm1  <- glm(treat~age + I(age^2) + educ + I(educ^2) + black +
               hisp + married + nodegr + re74  + I(re74^2) + re75 + I(re75^2) +
               u74 + u75, family=binomial, data=lalonde)

#
#save data objects
#
X  <- glm1$fitted
Y  <- lalonde$re78
Tr  <- lalonde$treat

#
# Estimating the treatment effect on the treated (the "estimand" option defaults to ATT).
#
rr  <- Match(Y=Y, Tr=Tr, X=X, M=1, estimand = "ATT")
summary(rr)

# works
lalonde[row.names(lalonde) %in% rr$index.treated,]

好的,所以,如果它适用于示例数据集,那么问题出在我的代码上,对吧?但是我尝试按照上面的代码进行操作,但仍然得到了疯狂的结果。我将提供一些数据和代码,以便这是可重现的:dput

数据

dput(mydata)
structure(list(Start_Dt = structure(c(7L, 7L, 20L, 20L, 7L, 7L, 
7L, 7L, 7L, 7L, 7L, 20L, 7L, 7L, 7L, 7L, 20L, 7L, 20L, 7L, 7L, 
7L, 20L, 7L, 7L, 7L, 7L, 7L, 20L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
20L, 7L, 18L, 9L, 9L, 9L, 18L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
18L, 9L, 9L, 9L, 9L, 9L, 13L, 13L, 3L, 3L, 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, 9L, 9L, 9L, 9L, 18L, 9L, 9L, 9L, 
18L, 18L, 9L, 9L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 13L, 3L, 
3L, 13L, 13L, 13L, 3L, 3L, 13L, 3L, 3L, 3L, 3L, 13L, 3L, 13L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 13L, 3L, 3L, 13L, 13L, 13L, 13L, 
13L, 7L, 7L, 20L, 20L, 7L, 7L, 20L, 20L, 7L, 7L, 7L, 7L, 20L, 
7L, 7L, 20L, 7L, 7L, 7L, 20L, 20L, 20L, 9L, 18L, 18L, 18L, 9L, 
9L, 9L, 18L, 9L, 18L, 9L, 9L, 9L, 9L, 9L, 9L, 18L, 9L, 9L, 9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
9L, 9L, 9L, 18L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 18L, 9L, 18L, 18L, 18L, 18L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 18L, 18L, 18L, 18L, 18L, 18L, 
18L, 18L, 3L, 3L, 3L, 3L, 3L, 3L, 13L, 3L, 3L, 3L, 3L, 3L, 13L, 
3L, 3L, 13L, 3L, 13L, 3L, 3L, 3L, 13L, 3L, 3L, 3L, 13L, 3L, 13L, 
3L, 3L, 3L, 13L, 3L, 13L, 13L, 3L, 3L, 3L, 3L, 3L, 3L, 13L, 13L, 
3L, 13L, 13L, 3L, 13L, 13L, 13L, 13L, 13L), .Label = c("01DEC2014:00:00:00.000", 
"01JUN2015:00:00:00.000", "02DEC2013:00:00:00.000", "02JUN2014:00:00:00.000", 
"02MAR2015:00:00:00.000", "02SEP2014:00:00:00.000", "03JUN2013:00:00:00.000", 
"03MAR2014:00:00:00.000", "03SEP2013:00:00:00.000", "12JAN2015:00:00:00.000", 
"12OCT2015:00:00:00.000", "13APR2015:00:00:00.000", "13JAN2014:00:00:00.000", 
"13JUL2015:00:00:00.000", "13OCT2014:00:00:00.000", "14APR2014:00:00:00.000", 
"14JUL2014:00:00:00.000", "14OCT2013:00:00:00.000", "15APR2013:00:00:00.000", 
"15JUL2013:00:00:00.000", "31AUG2015:00:00:00.000"), class = "factor"), 
    term_1yr_status = c(1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 1L, 0L, 
    0L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 
    0L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 
    1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 
    1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 
    1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 
    1L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 
    1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 
    1L, 1L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 
    1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 1L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, 0, 0, 0, 0, 0, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 
    1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 
    1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 
    1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 
    1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 
    1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 
    0, 0, 0, 0)), .Names = c("Start_Dt", "term_1yr_status", "tr"
), class = "data.frame", row.names = c(1L, 2L, 3L, 4L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 20L, 
21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 
34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 43L, 44L, 45L, 46L, 47L, 
48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 
61L, 62L, 65L, 66L, 67L, 68L, 69L, 83L, 84L, 85L, 90L, 91L, 92L, 
93L, 94L, 95L, 96L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 
107L, 108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 167L, 168L, 
169L, 170L, 177L, 178L, 179L, 180L, 181L, 182L, 183L, 196L, 197L, 
198L, 199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L, 207L, 208L, 
209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 218L, 219L, 
220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L, 229L, 230L, 
231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 239L, 240L, 241L, 
260L, 261L, 262L, 263L, 264L, 265L, 266L, 267L, 268L, 269L, 270L, 
271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 279L, 280L, 281L, 
282L, 283L, 284L, 285L, 286L, 320L, 326L, 327L, 328L, 329L, 330L, 
331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L, 339L, 340L, 341L, 
342L, 359L, 360L, 361L, 362L, 364L, 375L, 376L, 377L, 378L, 380L, 
381L, 382L, 383L, 384L, 385L, 386L, 387L, 388L, 390L, 391L, 392L, 
393L, 394L, 395L, 396L, 397L, 398L, 399L, 400L, 401L, 402L, 403L, 
404L, 405L, 406L, 407L, 408L, 409L, 410L, 411L, 412L, 526L, 527L, 
528L, 529L, 530L, 531L, 532L, 533L, 534L, 535L, 536L, 537L, 538L, 
539L, 540L, 541L, 542L, 543L, 544L, 545L, 546L, 548L, 549L, 550L, 
551L, 552L, 554L, 556L, 557L, 558L, 559L, 560L, 561L, 562L, 563L, 
564L, 565L, 566L, 567L, 568L, 569L, 570L, 571L, 572L, 573L, 574L, 
575L, 576L, 577L, 578L, 579L, 580L, 581L, 686L, 687L, 688L, 689L, 
690L, 691L, 692L, 693L, 694L, 695L, 697L, 698L, 699L, 700L, 701L, 
702L, 703L, 704L, 706L, 707L, 708L, 709L, 710L, 711L, 712L, 713L, 
714L, 715L, 716L, 717L, 718L, 719L, 720L, 721L, 722L, 723L, 724L, 
725L, 726L, 727L, 728L, 729L, 730L, 731L, 732L, 733L, 734L, 735L, 
736L, 737L, 738L, 739L, 740L, 741L, 742L, 743L, 744L, 745L, 746L, 
747L, 748L, 749L, 750L, 751L, 752L, 753L, 754L, 755L, 756L, 757L, 
758L, 759L, 760L, 761L, 762L, 956L, 957L, 958L, 959L, 960L, 961L, 
962L, 963L, 964L, 966L, 967L, 968L, 969L, 970L, 971L, 972L, 973L, 
974L, 975L, 976L, 977L, 978L, 979L, 980L, 981L, 982L, 983L, 984L, 
985L, 986L, 987L, 988L, 989L, 990L, 991L, 992L, 993L, 994L, 995L, 
996L, 997L, 999L, 1000L, 1001L, 1002L, 1003L, 1004L, 1005L, 1006L, 
1007L, 1008L, 1009L, 1010L, 1011L, 1012L, 1013L, 1014L, 1015L, 
1016L, 1017L, 1018L, 1019L, 1020L, 1021L, 1022L, 1023L, 1024L, 
1025L, 1028L, 1029L, 1030L, 1031L, 1032L, 1033L, 1034L, 1035L, 
1036L, 1037L, 1038L, 1039L, 1040L, 1041L, 1042L, 1043L, 1044L, 
1045L, 1046L, 1047L, 1048L, 1049L, 1050L, 1051L, 1052L, 1053L, 
1054L, 1055L, 1056L, 1057L, 1058L, 1059L, 1060L, 1061L, 1062L, 
1063L, 1064L, 1065L, 1066L, 1067L, 1068L, 1069L, 1071L, 1072L, 
1073L, 1074L, 1075L, 1076L, 1078L, 1079L, 1080L, 1081L, 1082L, 
1083L, 1084L, 1085L, 1086L, 1087L, 1088L, 1089L, 1090L, 1091L, 
1092L, 1093L, 1094L, 1097L, 1098L, 1099L, 1100L, 1101L, 1102L, 
1103L, 1104L, 1105L, 1106L, 1107L, 1108L, 1109L, 1110L, 1111L, 
1112L, 1113L, 1114L, 1115L, 1116L, 1117L, 1118L))

法典

# tr = 1 for treatment, = 0 for control
table(mydata$tr)

# Propensity Scoring
glm1  <- glm(tr ~ Start_Dt, family=binomial, data=mydata)

# Create data objects for mamydatahing 
X     <- glm1$fitted
Y     <- mydata$term_1yr_status
Tr    <- mydata$tr

# Propensity Score Matching and calculation of Average Effect of Treatment on the Treated
rr    <- Match(Y=Y, Tr=Tr, X=X, M=1, estimand = "ATT")
summary(rr) # Crazy results

# OK, let's have a look at the data
mydata[row.names(mydata) %in% rr$index.treated,] # Why are control observations in my treated index??
mydata$tr[row.names(mydata) %in% rr$index.treated] # Why are control observations in my treated index??

  [1] 0 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 0 1 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 1 0 1 1 1 0
 [76] 1 0 1 0 0 0 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0

注意:由于示例数据集有 for 类,而我的数据有 class for,我尝试将标志的类更改为整数,但没有区别。integerTrnumericTrTr

注意:我注意到 lalonde 数据是按处理标志排序的。我尝试以这种方式对我的数据进行排序,但没有区别。

R 匹配

评论


答:

2赞 Hack-R 2/12/2016 #1

在匹配之前设置数据对象的行名可解决此问题:

> row.names(mydata) <- 1:nrow(mydata)
> table(mydata$tr)

  0   1 
225 293 
> # Propensity Scoring
> glm1  <- glm(tr ~ Start_Dt, family=binomial, data=mydata)
> # Create data objects for Matching
> X     <- glm1$fitted
> Tr    <- as.integer(mydata$tr)
> # Propensity Score Matching and calculation of Average Effect of Treatment on the Treated
> rr    <- Match(Y=Y, Tr=Tr, X=X, M=1, estimand = "ATT", replace = T)
> mydata$tr[row.names(mydata) %in% rr$index.treated] 
  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [76] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[151] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[226] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
> mydata$tr[row.names(mydata) %in% rr$index.control]
  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 [76] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0