Announcement

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

  • Making Variables/Factors for paper on Structural Breaks

    • isin1: Is International Security Identification Number
    • name: Company Name
    • date1: Dates
    • adjustedprice1: Adjusted Price
    • week: week number in STATA format.
    • ln_return: bysort isin1: generate ln_return = ln(adjustedprice1[_n]/adjustedprice1[_n-1])
    • counter: egen counter = count(isin1), by(week) Counts unique isin codes for that week
    • equity: Book value of equity
    • mktcap: Market capitalization
    I am trying to make some variables/factors but are having great difficulties.

    These factors are:
    1. Market Beta
      • Market beta is estimated using weekly returns and equal-weighted market returns for the three-year period ending in month t-1 (with at least 52 weeks of returns).
    2. Momentum
      • Momentum is computed as the 11-month cumulative return from month t-12 through month t-2.
    3. Book-to-Market Value
      • Book-to-market value is the book value of equity divided by the prior year-end market capitalization.

    For equity values there are 109k missing out of 350k.





    . dataex isin1 name date1 adjustedprice1 week ln_return equity mktcap counter

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long isin1 str40 name float(date1 adjustedprice1 week ln_return) str19 equity str15 mktcap float counter
    1 "RGI (Antilles)"                13349      66.5 1900           . "1801313000"      "4485879328"      152
    1 "RGI (Antilles)"                13356        66 1901 -.007547206 "1801313000"      "4452150912"      152
    1 "RGI (Antilles)"                13363        66 1902           0 "1801313000"      "4452150912"      148
    1 "RGI (Antilles)"                13370      67.5 1903  .022472857 "1801313000"      "4553336160"      151
    1 "RGI (Antilles)"                13377        66 1904 -.022472857 "1801313000"      "4452150912"      159
    1 "RGI (Antilles)"                13384      62.5 1905  -.05448819 "1801313000"      "4216052000"      156
    1 "RGI (Antilles)"                13391        63 1906   .00796817 "1801313000"      "4249780416"      167
    1 "RGI (Antilles)"                13398        62 1907 -.016000342 "1801313000"      "4182323584"      155
    1 "RGI (Antilles)"                13405        67 1908   .07755823 "1801313000"      "4519607744"      162
    1 "RGI (Antilles)"                13412        67 1909           0 "1801313000"      "4519607744"      160
    1 "RGI (Antilles)"                13419        65 1910  -.03030535 "1801313000"      "4384694080"      163
    1 "RGI (Antilles)"                13426      61.5 1911   -.0553501 "1801313000"      "4148595168"      165
    1 "RGI (Antilles)"                13433        61 1912 -.008163311 "1801313000"      "4114866752"      165
    1 "RGI (Antilles)"                13440        61 1913           0 "1801313000"      "4114866752"      172
    1 "RGI (Antilles)"                13447      62.5 1914   .02429269 "1801313000"      "4216052000"      172
    1 "RGI (Antilles)"                13454      61.5 1915 -.016129382 "1801313000"      "4148595168"      170
    1 "RGI (Antilles)"                13461        63 1916   .02409755 "1801313000"      "4249780416"      167
    1 "RGI (Antilles)"                13468        65 1917  .031252544 "1801313000"      "4384694080"      170
    1 "RGI (Antilles)"                13475        66 1918  .015267472 "1801313000"      "4452150912"      170
    1 "RGI (Antilles)"                13482        66 1919           0 "1801313000"      "4452150912"      176
    1 "RGI (Antilles)"                13489        64 1920  -.03077166 "1801313000"      "4317237248"      168
    1 "RGI (Antilles)"                13496        63 1921 -.015748357 "1801313000"      "4249780416"      171
    1 "RGI (Antilles)"                13503      63.5 1922   .00790518 "1801313000"      "4352793428"      172
    1 "RGI (Antilles)"                13513        65 1923  .023347365 "1801313000"      "4455615320"      173
    1 "RGI (Antilles)"                13521      66.5 1924   .02281468 ""                "4558437212"      162
    1 "RGI (Antilles)"                13528        71 1925   .06547793 ""                "4866902888"      172
    1 "RGI (Antilles)"                13535        73 1926  .027779564 ""                "5003998744"      174
    1 "RGI (Antilles)"                13541      75.5 1927  .033673216 ""                "5175368564"      177
    2 "African Petroleum Corporation" 19877 1.1050867 2829           . "2370472987,4359" "788736074,39999" 215
    2 "African Petroleum Corporation" 19884   1.39337 2830    .2318016 "2370472987,4359" "994493311,19999" 214
    2 "African Petroleum Corporation" 19891 1.1435245 2831   -.1976102 "2370472987,4359" "816170372,63999" 211
    2 "African Petroleum Corporation" 19898 1.2492285 2832   .08841096 "2370472987,4359" "891614692,8"     214
    2 "African Petroleum Corporation" 19905 1.0378206 2833  -.18540323 "2370472987,4359" "740726052,48"    215
    2 "African Petroleum Corporation" 19912 1.0858678 2834   .04525653 "2370472987,4359" "775018925,27999" 212
    2 "African Petroleum Corporation" 19919 1.0570395 2835 -.026907373 "2370472987,4359" "754443201,6"     205
    2 "African Petroleum Corporation" 19926 1.0186017 2836 -.037041314 "2370472987,4359" "727008903,36"    204
    2 "African Petroleum Corporation" 19933  .9897733 2837  -.02871008 "2370472987,4359" "706433179,68"    210
    2 "African Petroleum Corporation" 19940  .9128977 2838  -.08085213 "2370472987,4359" "651564583,19999" 212
    2 "African Petroleum Corporation" 19947  .9321166 2839   .02083411 "2370472987,4359" "665281732,31999" 212
    2 "African Petroleum Corporation" 19954  .8168032 2840  -.13205974 "2370472987,4359" "582978837,59999" 215
    2 "African Petroleum Corporation" 19961  .7207087 2841  -.12516314 "2370472987,4359" "514393092"       217
    2 "African Petroleum Corporation" 19968   .768756 2842  .064538516 "2370472987,4359" "548685964,8"     214
    2 "African Petroleum Corporation" 19975  .7975843 2843   .03681394 "2370472987,4359" "569261688,47999" 214
    2 "African Petroleum Corporation" 19982  .7110993 2844   -.1147755 "2370472987,4359" "507534517,43999" 215
    2 "African Petroleum Corporation" 19989  .6726615 2845  -.05556983 "2370472987,4359" "480100219,19999" 212
    2 "African Petroleum Corporation" 19996  .7495371 2846   .10821354 "2370472987,4359" "534968815,68"    215
    2 "African Petroleum Corporation" 20003  .7303182 2847 -.025975436 "2370472987,4359" "521251666,56"    216
    2 "African Petroleum Corporation" 20010  .7495371 2848  .025975436 "2370472987,4359" "534968815,68"    213
    2 "African Petroleum Corporation" 20017   .663052 2849   -.1226023 "2370472987,4359" "473241644,63999" 220
    2 "African Petroleum Corporation" 20024  .6246142 2850  -.05971921 "2370472987,4359" "445807346,4"     215
    2 "African Petroleum Corporation" 20031  .5861764 2851  -.06351348 "2370472987,4359" "418373048,15999" 217
    2 "African Petroleum Corporation" 20038  .4900819 2852  -.17904817 "2370472987,4359" "349787302,56"    220
    2 "African Petroleum Corporation" 20044 .39398745 2853  -.21825354 "2370472987,4359" "281201556,95999" 218
    2 "African Petroleum Corporation" 20052  .3747685 2854  -.05001048 "2370472987,4359" "267484407,84"    215
    2 "African Petroleum Corporation" 20059  .3267213 2855  -.13720112 "2370472987,4359" "233191535,04"    216
    2 "African Petroleum Corporation" 20066   .192189 2856   -.5306282 "2370472987,4359" "137171491,2"     214
    2 "African Petroleum Corporation" 20073 .20179844 2857   .04879015 "2370472987,4359" "144030065,75999" 217
    2 "African Petroleum Corporation" 20080 .26906458 2858   .28768203 "2370472987,4359" "192040087,68"    219
    2 "African Petroleum Corporation" 20087  .2498457 2859 -.074107945 "2370472987,4359" "178322938,56"    213
    2 "African Petroleum Corporation" 20095 .25945514 2860   .03774037 "2432887470,5098" "185181513,12"    212
    2 "African Petroleum Corporation" 20102 .20179844 2861  -.25131446 "2432887470,5098" "144030065,75999" 213
    2 "African Petroleum Corporation" 20109 .24023624 2862    .1743534 "2432887470,5098" "171464364"       217
    2 "African Petroleum Corporation" 20116  .6150048 2863    .9400073 "2432887470,5098" "438948771,84"    214
    2 "African Petroleum Corporation" 20123  .6246142 2864  .015504205 "2432887470,5098" "445807346,4"     215
    2 "African Petroleum Corporation" 20130       .43 2865    -.373349 "2432887470,5098" "318261563,09999" 216
    2 "African Petroleum Corporation" 20137       .38 2866  -.12361398 "2432887470,5098" "281254404,6"     216
    2 "African Petroleum Corporation" 20144       .37 2867  -.02666822 "2432887470,5098" "273852972,89999" 213
    2 "African Petroleum Corporation" 20151       .38 2868   .02666822 "2432887470,5098" "281254404,6"     215
    2 "African Petroleum Corporation" 20158       .38 2869           0 "2432887470,5098" "281254404,6"     215
    2 "African Petroleum Corporation" 20165       .36 2870  -.05406717 "2432887470,5098" "348909763,31999" 216
    2 "African Petroleum Corporation" 20172       .31 2871  -.14953177 "2432887470,5098" "300450073,96999" 214
    2 "African Petroleum Corporation" 20179       .34 2872   .09237333 "2432887470,5098" "329525887,58"    210
    2 "African Petroleum Corporation" 20186       .33 2873 -.029852934 "2432887470,5098" "319833949,71"    205
    2 "African Petroleum Corporation" 20193       .31 2874  -.06252039 "2432887470,5098" "300450073,96999" 215
    2 "African Petroleum Corporation" 20200       .42 2875    .3036824 "2432887470,5098" "407061390,53999" 213
    2 "African Petroleum Corporation" 20207       .36 2876   -.1541506 "2432887470,5098" "348909763,31999" 211
    2 "African Petroleum Corporation" 20214       .35 2877 -.028170934 "2432887470,5098" "339217825,44999" 211
    2 "African Petroleum Corporation" 20221       .34 2878  -.02898751 "2432887470,5098" "329525887,58"    213
    2 "African Petroleum Corporation" 20228       .35 2879   .02898751 "2432887470,5098" "339217825,44999" 208
    2 "African Petroleum Corporation" 20235       .33 2880  -.05884044 "2432887470,5098" "319833949,71"    206
    2 "African Petroleum Corporation" 20242       .36 2881   .08701137 "2432887470,5098" "348909763,31999" 213
    2 "African Petroleum Corporation" 20249       .38 2882   .05406717 "2432887470,5098" "368293639,06"    214
    2 "African Petroleum Corporation" 20256       .34 2883  -.11122561 "2432887470,5098" "329525887,58"    214
    2 "African Petroleum Corporation" 20263       .36 2884   .05715844 "2432887470,5098" "348909763,31999" 213
    2 "African Petroleum Corporation" 20270       .34 2885  -.05715844 "2432887470,5098" "329525887,58"    216
    2 "African Petroleum Corporation" 20277       .29 2886  -.15906474 "2432887470,5098" "281066198,22999" 212
    2 "African Petroleum Corporation" 20284        .3 2887   .03390162 "2432887470,5098" "290758136,09999" 216
    2 "African Petroleum Corporation" 20291       .31 2888   .03278979 "2432887470,5098" "300450073,96999" 213
    2 "African Petroleum Corporation" 20298        .3 2889  -.03278979 "2432887470,5098" "290758136,09999" 211
    2 "African Petroleum Corporation" 20305       .29 2890  -.03390162 "2432887470,5098" "281066198,22999" 214
    2 "African Petroleum Corporation" 20312       .27 2891   -.0714589 "2432887470,5098" "261682322,49"    216
    2 "African Petroleum Corporation" 20319       .28 2892   .03636761 "2432887470,5098" "271374260,36"    213
    2 "African Petroleum Corporation" 20326       .24 2893   -.1541507 "2432887470,5098" "232606508,87999" 217
    2 "African Petroleum Corporation" 20333       .24 2894           0 "2432887470,5098" "232606508,87999" 216
    2 "African Petroleum Corporation" 20340       .24 2895           0 "2432887470,5098" "232606508,87999" 211
    2 "African Petroleum Corporation" 20347       .28 2896    .1541507 "2432887470,5098" "271374260,36"    213
    2 "African Petroleum Corporation" 20354       .25 2897  -.11332869 "2432887470,5098" "242298446,75"    213
    2 "African Petroleum Corporation" 20361       .25 2898           0 "2432887470,5098" "242298446,75"    213
    2 "African Petroleum Corporation" 20368       .26 2899   .03922068 "2432887470,5098" "251990384,62"    214
    2 "African Petroleum Corporation" 20375       .23 2900  -.12260227 "2432887470,5098" "222914571,01"    214
    end
    format %tdDD/NN/CCYY date1
    label values isin1 isin1
    label def isin1 1 "ANN7425Q1095", modify
    label def isin1 2 "AU000000AOQ0", modify
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 349787 observations
    Use the count() option to list more



  • #2
    I think I figured out Momemtum. I used adjusted price with weekly returns: code: by isin1: gen cumulative_return = (adjustedprice1[_n]-adjustedprice1[_n-51])/adjustedprice1[_n-51]

    Comment

    Working...
    X