remo
remo

Reputation: 375

R: Nearest neighbour matching with MatchIT

I would like to use nearest neighbour matching with MatchIt in R. So far I have used the following code:

Matching<- matchit(Treatment ~ Size+ Age + Expenses, data=data, method = "nearest", distance="glm", replace=TRUE)

I have two questions:

Question 1.)

When I run this code and run Matching again then I get a summary. One line then says

A matchit object
 - method: 1:1 nearest neighbor matching with replacement

I want to have the same control observation to be matched multiple times if neeeded. Is the code above doing that? I am confused since it says 1:1 nearest neighbor matching with replacement, I don't know if it now only uses an observation in the control group not more than once due to the 1:1 part in the sentence. However, since I use replace=true in the code I thought that this does exactly that so that one observation in the control group can be matched several times.

Could someone explain to me if my understanding is correct?

Question 2.)

After having run

Matching<- matchit(Treatment ~ Size+ Age + Expenses, data=data, method = "nearest", distance="glm", replace=TRUE)

I would like to estimate the average treatment effect. I use the following document as a reference on how to estimate it: https://cran.r-project.org/web/packages/MatchIt/vignettes/estimating-effects.html#after-pair-matching-with-replacement However, I would like to use clustered standard errors by subclass and id. Therefore, I need to first write the code:

Matching_gm <- get_matches(Matching)

When I look at the weights of Matching_gm they are always 1. However, when I run summary(Matching$weigths) there are many weights that are different from 1. Why do the weights change when I use get_matches ? As far as I know, this should not be the case.

Upvotes: 0

Views: 792

Answers (1)

Noah
Noah

Reputation: 4414

  1. It is called 1:1 matching because each treated unit gets one match, but it is possible that control units are reused as matches for multiple treated units. If you set ratio to something other than 1, you would be doing k:1 matching, where each treated units gets k matches, composed of controls that may be resued for other treated units.

  2. get_matches() produces a row for each unit for each time it is matched. If a control unit is matched twice (i.e., to two different treated units), it will have two rows each with a weight of 1 in the get_matches() output, but it will have a weight of 2 in the matchit() output (though this weight may be scaled to be different from 2). If you use match.data() instead of get_matches(), you will see that each unit receives only one row and the weights for each control unit are the same as in the matchit() output.

Upvotes: 1

Related Questions