Announcement

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

  • Matching method

    Hi all,

    I have a cross-sectional dataset which contains info on 417 different funds. These funds belong to 50 fund management firms and belong to 33 different fund category. Each of the fund has a unique numeric fund size and also has a rating that falls between 1-5 (integer). I am trying to match each fund with a similar fund that belongs to a different management firm but has exact same category, exact same rating and similar size (the closest size would do the work). I tried psmatch2 but it can't do the work for matching within the same category. Any idea how I can achieve my goal most efficiently?

    Here is a sample data.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float firm str10 fundid str44 category double size byte rating
    1 "FS00008ZUU" "US Fund Large Growth"                229673447 2
    1 "FS00008ZWL" "US Fund Foreign Large Growth"        110501073 1
    1 "FS00008ZWN" "US Fund Small Growth"                 55452462 2
    1 "FS00009GXV" "US Fund Large Blend"                4644569606 5
    1 "FS00009GXW" "US Fund Foreign Large Blend"         237360495 3
    1 "FS00009GXX" "US Fund Diversified Emerging Mkts"    80227554 2
    1 "FS00009X63" "US Fund Large Blend"                1450134107 2
    1 "FS00009X64" "US Fund Small Blend"                 562499095 2
    1 "FS00009X65" "US Fund Foreign Large Blend"         268643551 3
    1 "FS0000AKOY" "US Fund Diversified Emerging Mkts"   225074936 2
    1 "FS0000BA0L" "US Fund Large Blend"                 309548198 3
    1 "FS0000BA0M" "US Fund Small Blend"                  23660328 2
    1 "FS0000BA0N" "US Fund Foreign Large Blend"         184436563 4
    1 "FS0000BA0O" "US Fund Diversified Emerging Mkts"   333097437 3
    1 "FSUSA09O6Z" "US Fund World Large Stock"           310567936 3
    1 "FSUSA09O70" "US Fund Foreign Large Blend"         239748475 3
    1 "FSUSA09RM8" "US Fund Large Growth"                958597273 3
    1 "FSUSA09RM9" "US Fund Small Growth"                268192785 2
    1 "FSUSA09RMA" "US Fund Foreign Large Growth"        431019773 1
    2 "FS0000C3L5" "US Fund Japan Stock"                   1489081 1
    2 "FSUSA000QA" "US Fund Foreign Large Blend"         144978149 1
    2 "FSUSA002U0" "US Fund Small Growth"                891343036 3
    2 "FSUSA002YI" "US Fund Foreign Small/Mid Growth"     99756308 4
    2 "FSUSA004T1" "US Fund World Large Stock"            30981549 2
    2 "FSUSA004UV" "US Fund Foreign Large Growth"        233724685 2
    2 "FSUSA004VL" "US Fund Large Growth"                368304607 2
    2 "FSUSA06AEX" "US Fund World Large Stock"            61856916 1
    2 "FSUSA079ML" "US Fund Diversified Emerging Mkts"  5069505514 4
    2 "FSUSA0A4YD" "US Fund Pacific/Asia ex-Japan Stk"     6687735 3
    3 "FS0000A8ZP" "US Fund Diversified Emerging Mkts"    19283803 3
    3 "FSUSA0002K" "US Fund Diversified Emerging Mkts"  1142744049 3
    4 "FS00008TI1" "US Fund Large Blend"                 217947857 4
    4 "FS0000AL1R" "US Fund Diversified Emerging Mkts"     5247985 2
    4 "FS0000AOEX" "US Fund Foreign Large Growth"         68297269 4
    4 "FS0000AOEY" "US Fund Small Value"                 326360962 3
    4 "FS0000AZL4" "US Fund World Large Stock"           828417375 4
    4 "FS0000BV6N" "US Fund Foreign Large Blend"         226479466 3
    4 "FS0000C44R" "US Fund Small Blend"                 928255274 3
    4 "FS0000C44S" "US Fund Foreign Small/Mid Growth"   1220487768 2
    4 "FS0000C44T" "US Fund Foreign Large Blend"        4036240930 3
    4 "FSUSA0001Q" "US Fund World Large Stock"          1028444644 3
    4 "FSUSA00043" "US Fund Large Growth"               9311174747 5
    4 "FSUSA00086" "US Fund Foreign Large Blend"        2804070361 2
    4 "FSUSA000CW" "US Fund Mid-Cap Growth"             2665420540 4
    4 "FSUSA000KE" "US Fund Large Value"                1756595511 4
    4 "FSUSA000LF" "US Fund Foreign Large Growth"        284198965 2
    4 "FSUSA000P2" "US Fund Large Growth"               1167810239 5
    4 "FSUSA000TC" "US Fund Large Value"                 535085911 3
    4 "FSUSA0025J" "US Fund Small Growth"               2079969745 5
    4 "FSUSA003S9" "US Fund Foreign Large Blend"        1056503571 2
    4 "FSUSA00484" "US Fund Global Real Estate"          143143094 3
    4 "FSUSA004DZ" "US Fund Large Growth"                603430136 4
    4 "FSUSA004H1" "US Fund Diversified Emerging Mkts"  1105397162 2
    4 "FSUSA008LH" "US Fund Large Growth"                243709319 3
    4 "FSUSA008YB" "US Fund Large Value"                 361190798 1
    4 "FSUSA0096H" "US Fund Mid-Cap Value"              2801128272 3
    4 "FSUSA00F3D" "US Fund Foreign Large Value"         160165694 1
    4 "FSUSA04CK3" "US Fund World Large Stock"           697864292 3
    4 "FSUSA04WWI" "US Fund World Large Stock"          1263614874 3
    4 "FSUSA067TD" "US Fund Global Real Estate"          333149963 4
    4 "FSUSA0BHKE" "US Fund Diversified Emerging Mkts"   136377981 3
    5 "FS00009OKT" "US Fund Diversified Emerging Mkts"   111211189 4
    5 "FS0000A49H" "US Fund Small Blend"                 111205991 5
    5 "FS0000ACLY" "US Fund World Large Stock"           455585406 3
    5 "FS0000AYPQ" "US Fund Large Blend"                  86090540 4
    5 "FS0000AYPS" "US Fund Diversified Emerging Mkts"     8530810 4
    5 "FS0000B09O" "US Fund Foreign Large Value"          22585015 4
    5 "FS0000B09P" "US Fund World Large Stock"            22893462 4
    5 "FSUSA001NS" "US Fund Technology"                 1603499487 4
    5 "FSUSA001YD" "US Fund Small Value"                 925852498 3
    5 "FSUSA002JV" "US Fund Mid-Cap Value"              1301896777 4
    5 "FSUSA002JW" "US Fund Large Growth"               1030282535 3
    5 "FSUSA002Z8" "US Fund Health"                      151471445 3
    5 "FSUSA0039D" "US Fund Mid-Cap Growth"              314239001 3
    5 "FSUSA0042E" "US Fund World Small/Mid Stock"       107960339 4
    5 "FSUSA004SE" "US Fund Large Value"                1273969094 2
    5 "FSUSA004TJ" "US Fund Large Value"                 337895092 3
    5 "FSUSA00JHG" "US Fund Foreign Large Value"         163190493 2
    5 "FSUSA04ZCI" "US Fund Diversified Emerging Mkts"   338634311 3
    5 "FSUSA05G3P" "US Fund Natural Resources"            10615093 2
    5 "FSUSA08QRU" "US Fund Natural Resources"           598703296 5
    5 "FSUSA0ALX6" "US Fund Small Growth"                 18827297 1
    5 "FSUSA0ALX7" "US Fund Small Growth"                 18854533 2
    5 "FSUSA0ALXN" "US Fund Foreign Small/Mid Growth"     95577747 2
    6 "FSUSA00014" "US Fund Foreign Large Value"        2675812991 4
    6 "FSUSA00016" "US Fund Large Value"                5288098888 3
    6 "FSUSA004F4" "US Fund Small Value"                5919363831 4
    6 "FSUSA06GDU" "US Fund Mid-Cap Value"               487245999 3
    6 "FSUSA0APQ4" "US Fund Small Blend"                  84239783 4
    7 "FS00008MIZ" "US Fund Large Blend"                 463733528 2
    7 "FS0000BKUF" "US Fund Global Real Estate"          360211220 4
    7 "FS0000BLNZ" "US Fund Large Growth"                468149053 3
    7 "FS0000CAJW" "US Fund Foreign Large Growth"          9259732 4
    7 "FSUSA0007B" "US Fund Large Blend"                2752907319 3
    7 "FSUSA0007J" "US Fund Large Value"                2155078235 4
    7 "FSUSA001FZ" "US Fund Large Value"               11904884206 4
    7 "FSUSA002B1" "US Fund Large Value"                2519529989 3
    7 "FSUSA002LU" "US Fund Large Growth"               1183426447 3
    7 "FSUSA002LY" "US Fund Large Growth"               7972358501 3
    7 "FSUSA002LZ" "US Fund Mid-Cap Growth"             4705111879 3
    end
    label var firm "group(mngmcompany)" 
    label var fundid "FundId" 
    label var category "Morningstar Category" 
    label var rating "Morningstar Rating Overall"
    Thanks,
    Vivian
    Last edited by Vivian Zijin Xu; 03 Sep 2019, 20:12. Reason: I added a sample data FYI.

  • #2
    Code:
    isid fundid
    
    preserve
    ds category rating, not
    rename (`r(varlist)') match_=
    tempfile copy
    save `copy'
    restore
    
    
    //  FORM ALL POSSIBLE PAIRS THAT MATCH ON CATEGORY & RATING
    joinby category rating using `copy', unmatched(master)
    
    //  ELIMINATE THOSE THAT BELONG TO THE SAME FIRM
    drop if firm == match_firm
    
    //  NOW PICK THE ONE CLOSEST IN SIZE
    gen delta = abs(size - match_size)
    by fundid (delta), sort: keep if _n == 1

    Comment


    • #3
      Hi Clyde, thanks a lot for your help, it perfectly solves the problem for me.

      Comment

      Working...
      X