匹配数据R的加权t检验

时间:2013-11-07 04:50:07

标签: r statistics matching weighted

我使用倾向得分匹配将案例与控件匹配(matchIt包,比率1:2)。现在我想使用权重(权重已知)获得两组中年龄变量的独立t检验统计量。

之前我使用过相同的代码并且有效。它适用于20 ob​​s的样本数据集; doent工作10个obs或整个数据集(856 obs)。我现在无法弄清楚出了什么问题。 var age的类型是整数。 这是我使用的代码(所有主题都在相同的数据集“matched_data”,w =权重var):

wtd.t.test {weights}

wtd.t.test(matched_data$age[matched_data$group==1], 
           matched_data$age[matched_data$group==0], 
           weight=matched_data$w[matched_data$group==1], 
           weighty=matched_data$w[matched_data$group==0], samedata=FALSE)

这是警告信息:

Warning message:
In wtd.t.test(matched_data$age[matched_data$group == 1], matched_data$age[matched_data$group ==  :
  Treating data for x and y separately

> sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

示例数据集:

group age   w
0   25  1.911564626
1   30  1
0   72  1.911564626
1   72  1
1   72  1
0   58  0.955782313
0   83  0.955782313
0   61  0.955782313
0   71  0.955782313
0   37  0.955782313
1   77  1
1   78  1
1   65  1
0   89  0.955782313
1   50  1
1   89  1
1   63  1
0   81  0.955782313
1   65  1
0   91  0.955782313

提前致谢!

0 个答案:

没有答案