使用匹配包进行遗传匹配

时间:2019-06-07 14:52:47

标签: tidyverse matching

我正在使用匹配包和GenMatch函数。我不了解“容忍度”选项的单位。

虽然单位是与马哈拉诺比斯距离相同的单位,但马哈拉诺比斯距离是两个观察值之间的差平方除以方差协方差矩阵。

library(tidyverse)
library(Matching)
V0 <- c(0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,1)
V1 <- c(0,10,20,30,41,51,60,70,80,90,101,110,120,118,64,61,42,140)
Tr <- as.numeric(V0)
X  <- cbind(V1) %>% as.matrix()

set.seed(4)
match <- Matching::GenMatch(Tr = Tr, X = X, replace = T, M = 1, ties = 
T,pop.size = 1000,wait.generations = 10,
                        distance.tolerance = 0.01) 
#dont know how to set this 
f<-match$matches

f %>% as_tibble() %>% add_column(V1[f[,1]],V1[f[,2]]) %>% as.data.frame %>% print()
sum(abs(V1[f[,1]]-V1[f[,2]])*f[,3])
sum(((V1[f[,1]]-V1[f[,2]]))**2*f[,3])

0 个答案:

没有答案