Hi Statalisters,
I have probably another basic finance question that is bothering me for quite some time and i would love to finish that puzzle in my head.
I have CRSP daily data and want to convert the daily returns of a company (RET) into weekly returns. While there are many forum posts on this topic, I couldn't find anything specific to my case. The ascol package is often recommended, but I have my own definition of weeks that cannot be incorporated into ascol. On the other hand, my supervisor gave me the following advice, that I can also achieve weekly returns using the post and the helpful contribution by Nick Cox:
https://www.statalist.org/forums/for...f-observations
I applied this code to my case, but as you can see in my Dataex excerpt, the weekly returns look strange. A large part is e^..., which doesn't seem correct to me. Now my question is, how do I correctly calculate weekly returns, considering that my supervisor gave me the tip from Nick“s contribution!?
In the Studiy I am trying to replicate, which uses weekly returns, there is nothing specific mentioned, just that they use weekly returns (see screenshot).

I would be very happy to hear some enlightenment from you!
Max
I have probably another basic finance question that is bothering me for quite some time and i would love to finish that puzzle in my head.
I have CRSP daily data and want to convert the daily returns of a company (RET) into weekly returns. While there are many forum posts on this topic, I couldn't find anything specific to my case. The ascol package is often recommended, but I have my own definition of weeks that cannot be incorporated into ascol. On the other hand, my supervisor gave me the following advice, that I can also achieve weekly returns using the post and the helpful contribution by Nick Cox:
https://www.statalist.org/forums/for...f-observations
I applied this code to my case, but as you can see in my Dataex excerpt, the weekly returns look strange. A large part is e^..., which doesn't seem correct to me. Now my question is, how do I correctly calculate weekly returns, considering that my supervisor gave me the tip from Nick“s contribution!?
In the Studiy I am trying to replicate, which uses weekly returns, there is nothing specific mentioned, just that they use weekly returns (see screenshot).
Code:
//Week Variable: gen week_start = cond(dow(ndate)>= 3, ndate - dow(ndate) + 3, ndate - dow(ndate) -4) format week_start %tdCY!ww //Weekly Return (Nicks Code): bysort PERMCO week_start: gen double product = RET[1] by PERMCO week_start: replace product = product[_n-1] * RET if _n > 1 by PERMCO week_start: replace product = product[_N]
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long PERMCO float week_start double(RET product) 7 14607 .08875379711389542 -.007482871882422026 7 14607 -.08431044220924377 -.007482871882422026 7 14614 .014634146355092525 -5.396767325598294e-08 7 14614 -.08653846383094788 -5.396767325598294e-08 7 14614 .04736842215061188 -5.396767325598294e-08 7 14614 -.017587939277291298 -5.396767325598294e-08 7 14614 -.05115089565515518 -5.396767325598294e-08 7 14621 -.05997304618358612 -8.736279877487076e-06 7 14621 .10967741906642914 -8.736279877487076e-06 7 14621 .03811369463801384 -8.736279877487076e-06 7 14621 .03484754264354706 -8.736279877487076e-06 7 14628 .025255562737584114 8.138629232045583e-08 7 14628 .06510263681411743 8.138629232045583e-08 7 14628 -.019273128360509872 8.138629232045583e-08 7 14628 -.045480068773031235 8.138629232045583e-08 7 14628 .056470587849617004 8.138629232045583e-08 7 14635 -.018374165520071983 1.679217829475919e-09 7 14635 -.001701644971035421 1.679217829475919e-09 7 14635 -.07613636553287506 1.679217829475919e-09 7 14635 .02091020904481411 1.679217829475919e-09 7 14635 -.033734939992427826 1.679217829475919e-09 7 14642 -.014339151792228222 -1.1847343457137055e-08 7 14642 .04554079845547676 -1.1847343457137055e-08 7 14642 .04537205025553703 -1.1847343457137055e-08 7 14642 .05613425746560097 -1.1847343457137055e-08 7 14642 .00712328776717186 -1.1847343457137055e-08 7 14649 -.019586507230997086 1.1382875445827283e-08 7 14649 .0077691455371677876 1.1382875445827283e-08 7 14649 -.041850220412015915 1.1382875445827283e-08 7 14649 .06494253128767014 1.1382875445827283e-08 7 14649 .027522936463356018 1.1382875445827283e-08 7 14656 -.04096638783812523 1.956836288501856e-07 7 14656 .006571741309016943 1.956836288501856e-07 7 14656 -.03155604004859924 1.956836288501856e-07 7 14656 .023033708333969116 1.956836288501856e-07 7 14663 .02141680382192135 2.5562444197018573e-09 7 14663 -.009005376137793064 2.5562444197018573e-09 7 14663 -.04190966859459877 2.5562444197018573e-09 7 14663 .026047565042972565 2.5562444197018573e-09 7 14663 .012141280807554722 2.5562444197018573e-09 7 14670 .13685932755470276 -1.7357357060494798e-07 7 14670 -.06378896534442902 -1.7357357060494798e-07 7 14670 .04918032884597778 -1.7357357060494798e-07 7 14670 -.01806640625 -1.7357357060494798e-07 7 14670 -.022376926615834236 -1.7357357060494798e-07 7 14677 -.00712105818092823 -8.582763332071138e-10 7 14677 .0020491802133619785 -8.582763332071138e-10 7 14677 .028629856184124947 -8.582763332071138e-10 7 14677 -.03528827056288719 -8.582763332071138e-10 7 14677 -.05821741372346878 -8.582763332071138e-10 7 14684 .017505470663309097 -3.5127815228235085e-08 7 14684 .045698925852775574 -3.5127815228235085e-08 7 14684 .02827763557434082 -3.5127815228235085e-08 7 14684 -.01600000075995922 -3.5127815228235085e-08 7 14684 .09705284237861633 -3.5127815228235085e-08 7 14691 .06855025142431259 -5.021668520197894e-10 7 14691 -.01993931457400322 -5.021668520197894e-10 7 14691 -.018575850874185562 -5.021668520197894e-10 7 14691 .0063091483898460865 -5.021668520197894e-10 7 14691 -.0031347961630672216 -5.021668520197894e-10 7 14698 -.02291105128824711 1.1382873068357512e-07 7 14698 -.07494252920150757 1.1382873068357512e-07 7 14698 .08001988381147385 1.1382873068357512e-07 7 14698 -.018407730385661125 1.1382873068357512e-07 7 14698 -.04500703141093254 1.1382873068357512e-07 7 14705 .024054983630776405 -1.1439060729866343e-07 7 14705 -.039789069443941116 -1.1439060729866343e-07 7 14705 .05242136865854263 -1.1439060729866343e-07 7 14705 -.05123339593410492 -1.1439060729866343e-07 7 14705 -.04450000077486038 -1.1439060729866343e-07 7 14712 -.0852956548333168 1.57523681720501e-07 7 14712 .041762012988328934 1.57523681720501e-07 7 14712 -.017023613676428795 1.57523681720501e-07 7 14712 .10726256668567657 1.57523681720501e-07 7 14712 .024217961356043816 1.57523681720501e-07 7 14719 -.04532019793987274 7.461160165381779e-07 7 14719 -.018575850874185562 7.461160165381779e-07 7 14719 .013669821433722973 7.461160165381779e-07 7 14719 .06483402848243713 7.461160165381779e-07 7 14726 -.05455430969595909 -5.410348454035767e-09 7 14726 .04482225701212883 -5.410348454035767e-09 7 14726 -.02120315656065941 -5.410348454035767e-09 7 14726 .002015113364905119 -5.410348454035767e-09 7 14726 -.05178481712937355 -5.410348454035767e-09 7 14733 -.0238600205630064 2.2551693075384973e-08 7 14733 -.03802281245589256 2.2551693075384973e-08 7 14733 .02202145755290985 2.2551693075384973e-08 7 14733 -.02651933766901493 2.2551693075384973e-08 7 14733 -.04256526753306389 2.2551693075384973e-08 7 14740 -.058091286569833755 2.737742236996278e-07 7 14740 .035242289304733276 2.737742236996278e-07 7 14740 .04680851101875305 2.737742236996278e-07 7 14740 -.06155632808804512 2.737742236996278e-07 7 14740 .04641089215874672 2.737742236996278e-07 7 14747 -.04080425947904587 -3.3408890818480356e-08 7 14747 -.006165228318423033 -3.3408890818480356e-08 7 14747 -.06699752062559128 -3.3408890818480356e-08 7 14747 -.043218083679676056 -3.3408890818480356e-08 7 14747 -.04586518555879593 -3.3408890818480356e-08 7 14754 .021849963814020157 1.4750068917687109e-08 end format %tdCY!ww week_start
Max
Comment