What is the weight matrix generated in the matching package?

Turning to the matching package, we will look at an example using GenMatch .

We read that the created Weight Matrix is a matrix whose diagonal corresponds to the weight given by each variable in X

But we are not sure what the generated values ​​are - are they related to the standard deviation.

Let's take an example presented in 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 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) 

Then we can print Weight.matrix which will be used later for data pairing.

 genout$Weight.matrix 

And in particular, the value assigned to age

 genout$Weight.matrix[1,1] 

We get a value of ~ 205. But what does this weight mean or represent?

Further, if we want to randomize the order of the data, the value is constantly changing.

 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] } 

The author also suggests that additional information may be useful, but it does not explain what weight matrix values ​​are. Can someone interpret them or understand why their value changes when the data order is changed

+5
source share
1 answer

Unfortunately, this is not a question that can be answered very easily (but in order to answer part of your question, no, the values ​​of the weight matrix are not related to the standard deviation).

GenMatch is an affine-invariant matching algorithm that uses a measure of distance d (), in which all elements of W are zero, except for the main diagonal. The main diagonal consists of k parameters that must be selected. (note that if each of these k parameters is set equal to 1, d () coincides with the Mahalanobis distance). Like the Mahalanobis distance, this distance metric can be used to conduct a greedy or optimal full match. (The choice of setting off-diagonal elements of W to zero is made only for reasons of computing power)

The reason for changing values ​​when changing the order of the data is that the weight matrix W has infinity of equivalent solutions. The obtained coincidences are invariant to a change in the constant scale to measure distance. In particular, the matches obtained are the same for each W = cW for any positive scalar c, and therefore, the matrix can be uniquely identified in many ways.

To fully understand how nonzero elements of the weight matrix are calculated, I recommend reading the full article behind GenMatch wording, which takes a somewhat deep and complex look at the methods used.

If you're just interested in the source code, you can view it on GitHub . If you have additional questions about a specific R code, I will be happy to try to answer them, however, if you have additional questions about algorithms for generating a weight matrix, you will likely have to switch to Cross Validated.

+3
source

All Articles