R:倾向得分匹配。 matchit 函数是否适用于分类匹配变量?

R: Propensity Score Matching. Does matchit function work with categorical matching variables?

我正在使用 R 中的 matchIt 包和倾向得分匹配。我看到了一些示例。但是我找不到一些使用匹配变量作为 factor ou 字符的示例。例如,年龄段。

head(mydata)
    People region sex age_group treatment
    1      1      1   3         0
    2      1      2   5         0
    3      2      2   2         1
    4      2      2   3         0
    5      3      1   3         1
    6      3      1   6         1

其中前四个变量来自因子或字符类型。此外,性别级别为 Men = 1 和 Famale = 2。

下一行使用数字匹配变量(tot、mim 和 dis)- stw 是治疗变量-

m.out = matchit(stw ~ tot + min + dis,
data = mydata, method = "nearest",
ratio = 1) 

来源:http://pareonline.net/getvn.asp?v=19&n=18

我想知道 matchit 函数是否适用于分类匹配变量。如果没有,有没有合适的包?

是的,它会起作用,但最近邻方法最适用于连续变量。只要确保您首先将变量声明为因子(即,将它们转换为虚拟二进制变量)。

参见 Stuart EA (2010)。 2010. 统计科学 25(1):1-25 https://projecteuclid.org/euclid.ss/1280841730