Announcement

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

  • Matching case control 1:n on Stata

    Hi everyone

    I am doing a piece of work looking at determinants of abortion in a sample of women using electronic health records from primary care practices. I am using an open cohort over 10 years so my dataset is quite big (4mill women so far).

    I am looking at a matched case control design, using abortion event as outcome and seeing if various factors (eg age, deprivation, history of previous abortions, smoking, alcohol use etc) are predictors using regression analysis.

    Currently I am stuck at trying to do a 1:n matching - I have enough patients to do at the very least 1:2 to 1:5 matching. However, after looking at the forum chats it looks like there isn't a simple programme on Stata which can do that!

    A random sample of my dataset is as follows:

    input double patid int EVENT long medcode int(yob pracid) byte region float abort
    1022310159 13515 1686 1966 10159 12 1
    2229310229 17716 6039 1966 10229 8 0
    6702810229 13149 255 1966 10229 8 1
    1568310093 19982 12944 1968 10093 6 0
    1784210093 12784 255 1968 10093 6 1
    40110303 17070 461 1968 10303 9 0
    2364410303 11323 1748 1968 10303 9 1
    806210981 18604 91 1968 10981 12 0
    1875910981 12784 1686 1968 10981 12 1
    300010025 14936 5926 1969 10025 2 0
    281610025 11183 255 1969 10025 2 1
    2591110342 15537 1 1969 10342 3 0
    2476910342 9497 1748 1969 10342 3 1
    617510442 17149 11955 1969 10442 1 0
    2127810442 10958 2187 1969 10442 1 1
    271010500 18644 6677 1969 10500 13 0
    1063410500 12116 1748 1969 10500 13 1
    2321010586 19521 795 1969 10586 5 0
    666410586 16617 1686 1969 10586 5 1
    772510797 18483 56 1969 10797 12 0
    1128210797 14538 1686 1969 10797 12 1

    To start with I would like to match on practice (Pracid) first, then practice and age (using YOB). I haven't added any other covariates yet to this dataset.

    Is there any easy way to do the matching? I can only find ccmatch which only does 1:1 matching.

    Many thanks!

    Richard

  • #2
    see also the user-written commands -vmatch-, -ultimatch-, -kmatch-

    use -search- to find and download

    Comment


    • #3
      I think I might have answered my own question using optmatch2 from https://personalpages.manchester.ac..../optmatch.html
      It took me a while to realise there were two other packages to install and the syntax is used - optimach [case control variable] [varlist], options
      it seems to match the way i want it. I will see how this goes!



      . optmatch2 abort yob pracid, maxc(5) gen(match) id(patid)

      ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
      .................................................. 50
      .................................................. 100
      .................................................. 150
      .................................................. 200
      .................................................. 250
      .................................................. 300
      .....


      Matched 61 treated subjects and 305 untreated subjects
      Sum of distances within matched sets = 161.657

      . summ

      Variable | Obs Mean Std. Dev. Min Max
      -------------+---------------------------------------------------------
      patid | 50,000 1.21e+09 1.16e+09 110272 1.34e+10
      EVENT | 50,000 16728.06 2577.914 -3527 20088
      medcode | 50,000 7918.855 15444.64 0 114536
      yob | 50,000 1961.655 7.104622 1950 2001
      pracid | 50,000 10452.9 277.8403 10001 10999
      -------------+---------------------------------------------------------
      region | 50,000 8.36922 3.704113 1 13
      start | 50,000 15372.59 2218.547 10113 20088
      end | 50,000 20479.3 1752.029 16071 22607
      abort | 50,000 .00122 .0349075 0 1
      match | 366 31 17.63092 1 61


      Comment

      Working...
      X