Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • nnmatch question

    Hi everyone,

    I am trying to run a matching estimators analysis - say teffects nnmatch (dep_variable x_covariate) (treatment) but filtering the data for different U.S. states - so I would have

    teffects nnmatch (dep_variable x_covariate) (treatment) if state = "California"

    teffects nnmatch (dep_variable x_covariate) (treatment) if state = "North Carolina"

    etc..


    My problems are the following:

    (1) for some states some of the observations don't return feasible matches and the message "use option osample() to identify all
    observations with deficient matches" shows up. Ideally I would like to simply exclude the unmatched observations from my input and simply find the ATE and ATET without including them. Is it possible? The error message suggests to use osample() but I don't know how would be the syntax of the code (I am quite novice to Stata... only used MATLAB until yesterday).

    (2) is there any way for me to "loop" across different states? Like in MATLAB I would do a for s=1:50 and then call the vector with the strings for the state inside the loop (like state_string(s)) as the argument for the matching function.

    Thank you very much for your help.

  • #2
    Hi, can anybody give me a helping hand on it? Thanks

    Comment


    • #3
      For the second question, see help levelsof.

      For the first question, the osample option will help, as Stata suggests. I think the observations that don't overlap are excluded when estimating the ATE (they have no nearest neighbor in the control group). To confirm, run


      Code:
      teffects nnmatch (dep_variable x_covariate) (treatment) if state = "California",  osample(calsample)
      Then the observations that are unmatched will be marked with a 1 in the calsample variable. Afterwards, you can run the matching again on the observations that satisfy overlap:

      Code:
      teffects nnmatch (dep_variable x_covariate) (treatment) if state = "California" & !calsample
      These should be the same if the observations that don't overlap are excluded.

      Jorge Eduardo Pérez Pérez
      www.jorgeperezperez.com

      Comment


      • #4
        Thanks for your reply Jorge but still it doesn't work. The problem is that the flag vector calsample here will consider the observations with no exact matches for a given treatment observation. So in theory to deal with this problem I would have to run many "loops" until the data is exhausted... In other words, firslty I get the output below

        no exact matches for observation 23472; use option osample() to identify all observations with deficient matches

        then I include the osample(calsample) as you suggested and it idenfities 334 observations have no exact matches... then i run the code considering

        state = "California" & !calsample but still now I have "fewer than 2 exact matches for observation 23481 when in-group matching for the robust() option".

        Do you have any idea of an easy way to deal with this loop?
        Thanks

        Comment


        • #5
          The last error message indicates that for your second estimation (excluding the unmatched observations), the problem is not because there are treated observations than do not have matched nearest neighbors in the control group. Instead, the problem appears in the second matching procedure used to obtain robust standard errors. Here Stata tries to match treated observations with other treated observations to obtain an estimate of variance. By default it requires two matches per treated observation, and it's only finding one for observation 23481.

          You can try

          Code:
           
           teffects nnmatch (dep_variable x_covariate) (treatment) if state = "California" & !calsample, vce(robust, nn(1))
          to require one match instead of two matches per treated observations. I don't know the implications of this, but I presume the variance estimate may be less reliable. You can also try to use the caliper option to allow more flexibility when finding matches.

          Jorge Eduardo Pérez Pérez
          www.jorgeperezperez.com

          Comment


          • #6
            Thanks again Jorge but still it's not working... the error message is the following...

            invalid vce() specification; nn(#) must be an integer between 2 and the number of observations in the smallest group = 112

            One thing I also didn't understand: why do I have to use nnmatch with this syntax of teffects nnmatch .... while the paper from Abadie and http://www.stata-journal.com/sjpdf.h...iclenum=st0072 simply call "nnmatch.... " on their examples?

            Thanks again for your support.

            Comment


            • #7
              Oh, I didn't know about the requirement of at least two matches for the variance estimation. My only advice now is to increase the width of the caliper, or discard the observation that is not matched (23481) in the second estimation.

              teffects nnmatch is part of official Stata. nnmatch is an user written command.
              Jorge Eduardo Pérez Pérez
              www.jorgeperezperez.com

              Comment

              Working...
              X