1
R操作与应用:Matching命令
背景数据描述:
这是国家支持工作示范(NSW)处理组数据的子样本和当前人口调查(CPS)的比较样本。Lalonde(1986)、Dehejia和Wahba(1999)对这些数据进行了广泛的分析。
R软件操作倾向匹配得分的函数安装包比较多,主要包括Matching、MatchIt等。
例如使用Matching前,需要先进行安装:install.packages(“Matching”)就可以安装了。
1、首先进行数据查看
> data("lalonde")> summary(lalonde) age educ black Min. :17.00 Min. : 3.0 Min. :0.0000 1st Qu.:20.00 1st Qu.: 9.0 1st Qu.:1.0000 Median :24.00 Median :10.0 Median :1.0000 Mean :25.37 Mean :10.2 Mean :0.8337 3rd Qu.:28.00 3rd Qu.:11.0 3rd Qu.:1.0000 Max. :55.00 Max. :16.0 Max. :1.0000 hisp married Min. :0.00000 Min. :0.0000 1st Qu.:0.00000 1st Qu.:0.0000 Median :0.00000 Median :0.0000 Mean :0.08764 Mean :0.1685 3rd Qu.:0.00000 3rd Qu.:0.0000 Max. :1.00000 Max. :1.0000 nodegr re74 Min. :0.000 Min. : 0.0 1st Qu.:1.000 1st Qu.: 0.0 Median :1.000 Median : 0.0 Mean :0.782 Mean : 2102.3 3rd Qu.:1.000 3rd Qu.: 824.4 Max. :1.000 Max. :39570.7 re75 re78 u74 Min. : 0 Min. : 0 Min. :0.0000 1st Qu.: 0 1st Qu.: 0 1st Qu.:0.0000 Median : 0 Median : 3702 Median :1.0000 Mean : 1377 Mean : 5301 Mean :0.7326 3rd Qu.: 1221 3rd Qu.: 8125 3rd Qu.:1.0000 Max. :25142 Max. :60308 Max. :1.0000 u75 treat Mi