Tham chiếu đến gói Matching là gì, chúng tôi xem ví dụ bằng cách sử dụng GenMatch
.Ma trận Trọng lượng được tạo ra trong Gói phù hợp
Chúng ta đọc thấy rằng Weight Matrix
mà được tạo ra là một ma trận mà tương ứng chéo với trọng lượng cho mỗi biến trong X
Nhưng chúng tôi không chắc chắn về giá trị được tạo ra đại diện - là họ liên quan đến một tiêu chuẩn độ lệch.
Hãy lấy ví dụ được cung cấp trong GenMatch
library(Matching)
data(lalonde)
attach(lalonde)
#The covariates we want to match on
X = cbind(age, educ, black, hisp, married, nodegr, u74, u75, re75, re74)
#The covariates we want to obtain balance on
BalanceMat <- cbind(age, educ, black, hisp, married, nodegr, u74, u75, re75, re74,
I(re74*re75))
#Let's call GenMatch() to find the optimal weight to give each
#covariate in 'X' so as we have achieved balance on the covariates in
#'BalanceMat'. This is only an example so we want GenMatch to be quick
#so the population size has been set to be only 16 via the 'pop.size'
#option. This is *WAY* too small for actual problems.
#For details see http://sekhon.berkeley.edu/papers/MatchingJSS.pdf.
#
genout <- GenMatch(Tr=treat, X=X, BalanceMatrix=BalanceMat, estimand="ATE", M=1,
pop.size=16, max.generations=10, wait.generations=1)
Sau đó, chúng ta có thể sản lượng Weight.matrix
sẽ được sử dụng sau này để ghép các dữ liệu
genout$Weight.matrix
và đặc biệt là giá trị được gán cho age
genout$Weight.matrix[1,1]
Chúng tôi nhận được một giá trị ~ 205. Nhưng trọng lượng này có ý nghĩa gì hoặc đại diện cho ??
Hơn nữa, nếu chúng tôi sắp xếp ngẫu nhiên thứ tự của dữ liệu, giá trị sẽ thay đổi liên tục.
n <- 100
P1 <- rep(NA, n)
for (i in 1:n) {
lalonde <- lalonde[sample(1:nrow(lalonde)), ] # randomise order
X = cbind(lalonde$age, lalonde$educ, lalonde$black, lalonde$hisp,
lalonde$married, lalonde$nodegr, lalonde$u74, lalonde$u75,
lalonde$re75, lalonde$re74)
BalanceMat <- cbind(lalonde$age, lalonde$educ, lalonde$black,
lalonde$hisp, lalonde$married, lalonde$nodegr,
lalonde$u74, lalonde$u75, lalonde$re75, lalonde$re74,
I(lalonde$re74*lalonde$re75))
genout <- GenMatch(Tr=lalonde$treat, X=X, BalanceMatrix=BalanceMat, estimand="ATE", M=1,
pop.size=16, max.generations=10, wait.generations=1)
P1[i] <- genout$Weight.matrix[1,1]
}
Tác giả của bài báo cũng gợi ý các additional information có thể hỗ trợ, nhưng nó không giải thích gì weight matrix
giá trị đại diện. Bất cứ ai giải thích chúng hoặc hiểu lý do tại sao độ lớn của chúng thay đổi khi thứ tự của dữ liệu được thay đổi