Announcement

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

  • Nearest Neighbour matching with exact matches and with replacement

    Dear all,

    Without actually being interested in the estimation of a treatment effect, I want to generate a control group that is matched to the treatment group through Nearest Neighbour matching with exact matches on three variables and with replacement. I am using multiple imputed data, which is why I think I have to do the whole process manually instead of using teffects, kmatch or psmatch2.

    My treatment is divorce and I am trying to match respondents that will divorce in one of the following panel waves (treatment group) to respondents that stay continuously married (control group). For each respondent I have randomly selected a year that I am using for the matching.

    I calculate the propensity score as follows:
    Code:
    *estimate propensity score
    mi estimate, saving(reg_ps, replace): logistic treat c.age i.cohort i.mig /// basic demographic
                    c.siblings i.pedu /// family of origin
                    c.age0t17 i.east c.age18plus /// hh living arrangements
                    i.edu incomeheq_log incomeind_log  /// human capital
                    i.empst expft incsat i.worries ///
                    i.own i.saccount i.business i.bildloan /// wealth
                    i.lifeins i.shares i.gains_cat ///
                    c.p_age i.p_mig i.p_edu c.p_siblings i.p_pedu /// partner information
                    c.p_expft i.p_empst c.p_incsat i.p_worries
    mi predict    xb  using reg_ps, xb            
    mi xeq: gen ps=exp(xb)/(1+exp(xb))
    In a next step, I would like to match each treatment respondent to three nearest control respondents using caliper of 0.2. However, I also need to match treatment and control respondents exactly on "female", yearmarriage" (year the marriage started ranging from 1969 to 2011) and "agegroup" (4 categories).

    Is there an appropriate Stata command that I could use (and have not found yet)?

    I am using Stata 16.1

    Thanks
    Last edited by Nicole Kapelle; 17 Apr 2020, 10:14.

  • #2
    I wonder if a brute-force solution using -joinby- might work for you. I'm thinking of something that could be sketched like this:

    Code:
    preserve
        keep id ps x1 x2 x3 // propensity and your exact match vars
        rename (ps id) (ps_ctl id_ctl)
        tempfile temp
        save `temp'
    restore
    joinby x1 x2 x3 using `temp'
    drop if id == id_ctl // no self matches
    gen diff = abs(ps - ps_ctl)  // how close?
    // Keep matched observation with smallest diff, not worrying about ties
    bysort id (diff): keep in 1

    Comment

    Working...
    X