Announcement

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

  • Create variable that calculates difference in matched observation and "normal observation" of a variable

    Hi all,

    For my thesis I need to extract the difference in Issue Yield between green bonds and conventional bonds. First, I have identified matches (based on different characteristics and Mahalonobis Distance) using mahapick:

    mahapick Maturity Coupon AmountIssuedUSD, idvar(id) treated(GreenBond) genfile(MatchedGreenBonds) prime_id(prime_id_var) matchnum(matchnum_var) nummatches(1) full matchon(BondGrade)

    I am stuck however on how to create a new variable that indicates the difference in Issue Yields between the green bond and the matched conventional bond, can anyone help me?

    Thank you very much!
    Last edited by Cristina Demmers; 19 May 2021, 06:34.

  • #2
    Present a data example using dataex, clearly identifying what is a green bond, what is a conventional bond and what variable represents the match id. See

    Code:
    help dataex

    Comment


    • #3
      Sorry for my late response, I did not see your reply. I must say I am quite new with stata and have been trying to figure it out over the course of the last two weeks, so sorry if I did not understand your question correctly.
      Below you can find a data example, the variable GreenBond is a dummy, where 1=Green Bond and 0= conventional bond. The dataex only shows green bonds.

      Through the command mahapick I have been able to match green bonds with a similar conventional bond. This resulted in a dataset I will also show below. Now, I want to find the difference in YTM between the green bond and matched conventional bond, but I do not know how to create this extra variable. Essentially, I want to augment the green bond dataset with a variable that shows YTM matched conventional bond - YTM green bond.

      input float id byte GreenBond double YTM int IssueDate long Maturity double(Coupon AmountIssuedUSD)
      108 1 15.25 20080 93 15.25 281
      141 1 8 19386 94 8 443
      437 1 13.77 19374 96 13.77 276
      465 1 19.62 22027 96 19.62 200
      511 1 7 20633 97 7 300
      542 1 9 20017 97 9 1000
      656 1 13.7 22047 97 13.7 685
      685 1 15.68 22049 97 15.68 315
      743 1 5.6 20016 98 5.6 1000
      746 1 6.45 20016 98 6.45 400
      757 1 9.36 20152 98 9.36 200
      782 1 9.76 20174 102 9.76 1000
      785 1 11.89 22117 104 11.89 500
      975 1 16.37 22021 158 16.37 100
      986 1 5.19 20185 164 5.19 1391
      987 1 7.18 20185 164 7.18 1001
      997 1 9.58 20369 174 9.58 1000
      1072 1 7 19415 183 7 153
      1076 1 8.25 19387 183 8.25 190
      1078 1 8.75 19374 183 8.75 599
      1163 1 7.5 19402 184 7.5 132
      1187 1 9.82 19387 184 9.82 600
      1196 1 10.29 20359 184 10.29 1300
      1414 1 7.75 21084 186 7.75 100
      1426 1 8.5 19568 186 8.5 380
      1434 1 9 19375 186 9 325
      1484 1 12.09 21983 186 12.09 1000
      1725 1 3.25 20192 188 3.25 100
      1727 1 3.65 20972 188 3.65 100
      1728 1 3.75 19380 188 3.75 29874
      1771 1 8.75 19522 188 8.75 130
      1810 1 10 19535 188 10 125
      1817 1 10.25 19472 188 10.25 1013
      1862 1 12.57 22068 188 12.57 100
      1896 1 18.28 22084 188 18.28 100
      1905 1 20.57 22007 188 20.57 250
      1911 1 22.83 22006 188 22.83 250
      2013 1 6.37 22062 189 6.37 100
      2029 1 7.2 20629 189 7.2 100
      2122 1 11.5 19555 189 11.5 75
      2143 1 13.96 22054 189 13.96 100
      2180 1 22.55 21997 189 22.55 250
      2258 1 7.53 21979 190 7.53 1000
      2265 1 8.94 21978 190 8.94 500
      2447 1 7.4 19751 195 7.4 500
      2534 1 10.56 20353 203 10.56 1100
      2551 1 14.19 21986 207 14.19 355
      2583 1 9.21 20377 217 9.21 1100
      2643 1 6.11 20236 242 6.11 600
      2826 1 5.51 21516 279 5.51 610
      2875 1 4.77 21783 280 4.77 675
      2884 1 9.07 21978 280 9.07 500
      3084 1 9.18 19730 322 9.18 16049
      3439 1 7.25 19415 366 7.25 1000
      3456 1 8.5 19374 366 8.5 120
      3465 1 9 19387 366 9 90
      3726 1 6.75 19443 367 6.75 140
      3754 1 7.5 19442 367 7.5 185
      3764 1 7.75 19555 367 7.75 163
      3769 1 8 19415 367 8 98
      3777 1 8.2 20086 367 8.2 3469
      3788 1 9 19555 367 9 63
      3802 1 9.5 19415 367 9.5 115
      3947 1 4.27 19834 368 4.27 100
      3952 1 4.7 20541 368 4.7 625
      3954 1 4.78 19386 368 4.78 150
      3976 1 6.02 20527 368 6.02 135
      3986 1 6.32 21493 368 6.32 110
      3987 1 6.35 19953 368 6.35 1400
      3991 1 6.5 20681 368 6.5 572
      4040 1 7.8 19372 368 7.8 100
      4050 1 7.97 19372 368 7.97 139
      4052 1 7.99 22158 368 7.99 100
      4077 1 8.3 19722 368 8.3 1865
      4087 1 8.5 19474 368 8.5 327
      4089 1 8.5 19974 368 8.5 1277
      4152 1 10.06 22018 368 10.06 300
      4200 1 12.48 22025 368 12.48 300
      4361 1 3.99 20145 369 3.99 150
      4371 1 5.8 19992 369 5.8 87
      4374 1 6.05 20935 369 6.05 2644
      4380 1 6.59 19423 369 6.59 100
      4382 1 6.6 20762 369 6.6 1199
      4419 1 8.15 19472 369 8.15 950
      4428 1 8.5 19460 369 8.5 149
      4465 1 11 19368 369 11 488
      4471 1 11 22090 369 11 5000
      4472 1 11.3 22120 369 11.3 5000
      4713 1 4.66 19662 370 4.66 170
      4716 1 4.71 19955 370 4.71 125
      4719 1 4.78 20188 370 4.78 259
      4744 1 5.07 19614 370 5.07 200
      4749 1 5.15 19744 370 5.15 100
      4757 1 5.22 19381 370 5.22 810
      4760 1 5.22 19800 370 5.22 350
      4771 1 5.33 19534 370 5.33 115
      4793 1 5.6 20115 370 5.6 400
      4794 1 5.6 20115 370 5.6 190
      4817 1 5.87 19494 370 5.87 100
      4822 1 6 20111 370 6 5617

      Dataset with matched bonds:
      input float prime_id_var int matchnum_var float id
      108 0 108
      108 1 1647
      141 0 141
      141 1 1074
      437 0 437
      437 1 55
      465 0 465
      465 1 1902
      511 0 511
      511 1 61603
      542 0 542
      542 1 749
      656 0 656
      656 1 9489
      685 0 685
      685 1 686
      743 0 743
      743 1 64632
      746 0 746
      746 1 4886
      757 0 757
      757 1 8078
      782 0 782
      782 1 7860
      785 0 785
      785 1 62522
      975 0 975
      975 1 6238
      986 0 986
      986 1 64595
      987 0 987
      987 1 6623
      997 0 997
      997 1 8444
      1072 0 1072
      1072 1 1558
      1076 0 1076
      1076 1 5352
      1078 0 1078
      1078 1 1080
      1163 0 1163
      1163 1 5126
      1187 0 1187
      1187 1 1605
      1196 0 1196
      1196 1 7218
      1414 0 1414
      1414 1 10406
      1426 0 1426
      1426 1 523
      1434 0 1434
      1434 1 276
      1484 0 1484
      1484 1 6108
      1725 0 1725
      1725 1 64259
      1727 0 1727
      1727 1 64178
      1728 0 1728
      1728 1 64759
      1771 0 1771
      1771 1 1772
      1810 0 1810
      1810 1 406
      1817 0 1817
      1817 1 5899
      1862 0 1862
      1862 1 6138
      1896 0 1896
      1896 1 6258
      1905 0 1905
      1905 1 61476
      1911 0 1911
      1911 1 61477
      2013 0 2013
      2013 1 70639
      2029 0 2029
      2029 1 64376
      2122 0 2122
      2122 1 2123
      2143 0 2143
      2143 1 2280
      2180 0 2180
      2180 1 263
      2258 0 2258
      2258 1 8945
      2265 0 2265
      2265 1 2056
      2447 0 2447
      2447 1 5101
      2534 0 2534
      2534 1 8667
      2551 0 2551
      2551 1 6182
      2583 0 2583
      2583 1 4443
      2643 0 2643
      2643 1 10916
      2826 0 2826
      2826 1 68006

      Thank you for your help!

      Comment

      Working...
      X