R中马氏距离最近邻匹配的子分类

R中马氏距离最近邻匹配的子分类,r,mahalanobis,R,Mahalanobis,我正在使用MatchIt包实现与Mahalonobis距离的最近邻匹配。在匹配阶段后,我如何让它报告与每个治疗观察相匹配的对照观察 下面的代码不起作用,并抛出警告“没有纯马氏距离的子分类” 库(“匹配”) 数据(“拉隆德”) lalonde_matchit_nn在本例中,您正在查找输出的属性:输出为lalonde_matchit_nn,属性为nn和match.matrix smry<-lalonde_matchit_nn$nn #A basic summary table of match

我正在使用MatchIt包实现与Mahalonobis距离的最近邻匹配。在匹配阶段后,我如何让它报告与每个治疗观察相匹配的对照观察

下面的代码不起作用,并抛出警告“没有纯马氏距离的子分类”

库(“匹配”)
数据(“拉隆德”)

lalonde_matchit_nn在本例中,您正在查找输出的属性:输出为
lalonde_matchit_nn
,属性为
nn
match.matrix

smry<-lalonde_matchit_nn$nn #A basic summary table of matched data (e.g., the number of matched units)

#represent the names of the treatment units, which
#come from the data frame specified in data. Each column stores the name(s)
#of the control unit(s) matched to the treatment unit of that row. F
matchedPool<-lalonde_matchit_nn$match.matrix

smry告诉每种类型的总体,匹配池为您提供根据您的最佳标准匹配的ID,在本例中为Mahanlobis距离,然而,警告消息
警告消息:没有纯马氏距离的子分类
告诉您,对于这种方法,其他最佳参数可能是更好的选择

如需了解更多详细信息,最好参考包装文件,

在本例中,您正在查找输出的属性:输出是
lalonde\u matchit\u nn
,属性是
nn
match.matrix

smry<-lalonde_matchit_nn$nn #A basic summary table of matched data (e.g., the number of matched units)

#represent the names of the treatment units, which
#come from the data frame specified in data. Each column stores the name(s)
#of the control unit(s) matched to the treatment unit of that row. F
matchedPool<-lalonde_matchit_nn$match.matrix

smry告诉每种类型的总体,匹配池为您提供根据您的最佳标准匹配的ID,在本例中为Mahanlobis距离,然而,警告消息
警告消息:没有纯马氏距离的子分类
告诉您,对于这种方法,其他最佳参数可能是更好的选择

如需了解更多详细信息,最好参考包装文件,

警告是因为您有
method=“mahalanobis”
subclass=T
,但不允许将它们放在一起。您可以选择子分类(在倾向评分上)或马氏距离匹配。@Noah谢谢,是的,我知道。对于最近邻匹配,不跟踪匹配的组(这是子类正在做的事情之一)似乎是一个奇怪的设计选择。我意识到,与其他匹配方法不同,它是1:1匹配,因此不需要在组内进行加权。但是有一个带有子类ID的列对于其他目的仍然有用,并且在我的应用程序中是必需的。您看到我的答案了吗?警告是因为您有
method=“mahalanobis”
subclass=T
,但不允许将它们放在一起。您可以选择子分类(在倾向评分上)或马氏距离匹配。@Noah谢谢,是的,我知道。对于最近邻匹配,不跟踪匹配的组(这是子类正在做的事情之一)似乎是一个奇怪的设计选择。我意识到,与其他匹配方法不同,它是1:1匹配,因此不需要在组内进行加权。但有一个带有子类ID的列对于其他用途仍然有用,并且在我的应用程序中是必要的。您看到我的答案了吗?它解决了这个问题?
smry
          Control Treated
All           429     185
Matched       185     185
Unmatched     244       0
Discarded       0       0

head(matchedPool)

     1        
NSW1 "PSID375"
NSW2 "PSID341"
NSW3 "PSID361"
NSW4 "PSID345"
NSW5 "PSID172"
NSW6 "PSID237"