Announcement

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

  • Cem (coarsened exact matching) create identifier for matched pairs

    Dear Statalist Users,

    My data is on the district-year level and I am looking at the effect of mine openings on child health. In this context, I would like to do a Difference-in-Differences analysis. However,
    the treatment (mine opening) in the treatment districts occured in various different years.
    I am using cem from SSC in stata 15.0 in order to reduce imbalance in co-variates between treated and control groups.
    After having created my matched treatment-control pairs I would like to impute to the control district the same treatment year as the year of treatment of its matched treatment district.
    The problem is that I could not find any function in cem allowing to identify the matched pairs.

    Any help or advice is greatly appreciated.

  • #2
    Don't the created variables cem_strata and cem_match identify the treated and controls?

    Comment


    • #3
      How did you set up cem to do matched pairs? That's not an option as far as I can tell., The k2k option is supposed to forcel equal numbers of treated and controls in each matched set (stratum), but, unfortunately, doesn't always work. Here's an example from the Stata Journal article.

      Code:
      use http://gking.harvard.edu/files/gking/files/lalonde.dta, clear
      gen id = _n
      cem age education black nodegree re74, k2k treatment(treated)
      
      return list
      matrix list r(match_table). //There are 67 strata with matches
      gen control = (treated==0)
      
      egen st_trt = total(treated) , by(cem_strata). // n. treated in stratum
      egen st_con = total(control), by(cem_strata). // n. controls in stratum
      
      gen has_matches = st_trt >0  & st_con >0  //identify strata with treated & untreated
      keep if has_matches. // keep only strata with matches
      
      sort cem_strata
      preserve
      bys cem_strata: keep if _n==1
      ** count number of treated and controls in each stratum
      list cem_strata st_trt st_con
      restore
      
      /* Identify treated & controls  in same stratum */
      list cem_strata id treated, sepby(cem_strata) noobs
      Last edited by Steve Samuels; 07 Feb 2019, 19:38.
      Steve Samuels
      Statistical Consulting
      [email protected]

      Stata 14.2

      Comment


      • #4
        Actually, I didn't manage to set up cem to do matched pairs yet. I was wondering if there is a way to do this in Stata similar to the pair function in R (https://www.rdocumentation.org/packa...19/topics/pair) where nearest neighbor matching inside each cem strata can be implemented.

        Comment


        • #5
          Stata has other commands to create matched pairs. (I haven't used them so can't recommend one.) You should be able to apply one of those commands to the strata identified by the code above. The authors of CEM proposed this strategy in Section 1 of their Stata Journal article.
          CEM can also be used to improve other methods of matching by applying those methods to CEM-matched data (they formally inherit CEM’s properties if applied within CEM strata).
          Last edited by Steve Samuels; 14 Feb 2019, 07:46.
          Steve Samuels
          Statistical Consulting
          [email protected]

          Stata 14.2

          Comment


          • #6
            I recommend psmatch2, which will do 1-1 Mahalanobis matching and save the id of the closest matching control in a variable "_n1" written to each treated observation. I've never used it seriously, but here's an example. The -help- says that you can set a caliper to exclude bad matches.
            Code:
            . use http://www.stata-press.com/data/r14/cattaneo3, clear
            (Excerpt from Cattaneo (2010) Journal of Econometrics 155: 138-154)
            
            . psmatch2 mbsmoke,  mahal(bweight mage prenatal1 mmarried fbaby) 
            
            . keep if  _treated
            (3,778 observations deleted)
            
            . list _id _n1 in 1/5
            
                 +-------------+
                 |  _id    _n1 |
                 |-------------|
              1. | 3779   2810 |
              2. | 3780   2047 |
              3. | 3781   3234 |
              4. | 3782   1079 |
              5. | 3783   1354 |
            Steve Samuels
            Statistical Consulting
            [email protected]

            Stata 14.2

            Comment

            Working...
            X