Announcement

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

  • Matching with CEM

    Dear Statalisters,

    I am stuck at a seemingly easy code. I am using matching algorithm, cem (coarsened exact matching).

    There are two groups - smokers and non-smokers. I want to match the two groups on a number characteristics - say age, education, income, and etc. But I want to keep a condition where characteristics are flexible in 30% range. For example, the size of the match could vary in the range of -30% to +30%. I am not sure how I can incorporate this in my code.

    cem age educ income, treatment(smoker)

    Any guidance would be appreciated.

    Thank you.

    Kind regards,
    Manish

  • #2
    As far as I know, -cem- cannot do this. -cem- allows you to specify cutpoints on the variables that define bins, and matching within bins will be exact. That is quite different from matching to within a range of -30% to +30%.

    Here is some code that will do the kind of matching you have described (which is usually called caliper matching). I assume the variable smoker is coded 0/1.

    Code:
    preserve
    keep if smoker == 0
    ds smoker, not
    rename (`r(varlist)') =_ctrl
    tempfile controls
    save `controls'
    
    restore
    keep if smoker == 1
    ds smoker, not
    rename `r(varlist)' =_case
    cross using `controls'
    foreach v of varlist age educ income {
        drop if !inrange(`v'_ctrl/`v'_case, 0.7, 1.3)
    }
    At that point the data in memory will consist of all pairs of cases and controls that agree to within 30% on age educ and income. (There may, of course, be cases or controls who do not have any satisfactory match under these criteria.) At that point you can prune the data to the number of controls you want to retain from each match by doing some random selection.

    Note: if you also intend to have exact matching on some discrete variables, for example, sex race, you can make this happen by replacing -cross using `controls'- with -joinby sex race using `controls', unmatched(both)-

    Comment


    • #3
      Dear Clyde,

      Thank you very much. Much appreciated.

      Best wishes,
      Manish

      Comment

      Working...
      X