I hope you are doing all well.
I would like to calculate portfolio returns for an individual portfolio within the correct date/period.
Basically I would like to do the following steps:
Create a new variable with the following operations:
My dataset is in long format and all observations of the monthly returns have some duplicates, which is not almost the same within each period. This make sense, cause the data are in long format. My procedure follows the construction of SMB and HML factors of Fama French.
a. aggregate the returns of EMI2_SOX_bm_left within the correct monthly period with the correct groups. With groups I mean, that I need an addition (sum up) of all observations that meets the group criteria: SOX_size3 ==1 & bm_size3 ==1 (growth efficient) plus SOX_size3==1 & bm_size3==3 (value efficient).
and then
b. substract this part from EMI_2_SOX_bm_right within the correct monthly period with the correct groups. With groups I mean, that I need an addition (sum up) of all observations that meets the group criteria: SOX_size3 == 3 & bm_size3 == 1 (growth inefficient) plus SOX_size==3 & bm_size3==3 (value inefficient).
The equation is: EMI2 = (growth efficient + value efficient) - (growth inefficient + value inefficient)
My groups defines the following:
SOX_size==1 (efficient) and SOX_size==3 (inefficient)
bm_size3==1 (growth) and bm_size3==3 (value)
I am not sure if it makes sense to kill the observations before step a. I am pretty sure to code a loop, but I am a STATA beginner and not sure how to solve it. Maybe anyone of you have an idea to solve this.
Attached my datex. Thanks a lot.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float mdate double(SOX_size3 bm_size3) float(EMI2_SOX_bm_5_left EMI2_SOX_bm_5_right) 588 1 1 .05545604 . 588 1 1 .05545604 . 588 1 1 .05545604 . 588 1 1 .05545604 . 589 1 1 -.358533 . 589 1 1 -.358533 . 589 1 1 -.358533 . 589 1 1 -.358533 . 590 1 1 -.19973737 . 590 1 1 -.19973737 . 590 1 1 -.19973737 . 591 1 1 1.748989 . 591 1 1 1.748989 . 591 1 1 1.748989 . 591 1 1 1.748989 . 592 1 1 1.1182656 . 592 1 1 1.1182656 . 592 1 1 1.1182656 . 592 1 1 1.1182656 . 593 1 1 -.5835291 . 593 1 1 -.5835291 . 593 1 1 -.5835291 . 593 1 1 -.5835291 . 594 1 1 1.469477 . 594 1 1 1.469477 . 594 1 1 1.469477 . 594 1 1 1.469477 . 595 1 1 .2984718 . 595 1 1 .2984718 . 595 1 1 .2984718 . 595 1 1 .2984718 . 596 1 1 .1872612 . 596 1 1 .1872612 . 596 1 1 .1872612 . 597 1 1 .4055046 . 597 1 1 .4055046 . 597 1 1 .4055046 . 597 1 1 .4055046 . 598 1 1 .51360005 . 598 1 1 .51360005 . 598 1 1 .51360005 . 598 1 1 .51360005 . 599 1 1 1.205407 . 599 1 1 1.205407 . 599 1 1 1.205407 . 600 1 1 -.7772466 . 600 1 1 -.7772466 . 600 1 1 -.7772466 . 600 1 1 -.7772466 . 601 1 1 .069554165 . 601 1 1 .069554165 . 601 1 1 .069554165 . 601 1 1 .069554165 . 602 1 1 .6081219 . 602 1 1 .6081219 . 602 1 1 .6081219 . 602 1 1 .6081219 . 602 1 1 .6081219 . 603 1 1 .4106087 . 603 1 1 .4106087 . 603 1 1 .4106087 . 603 1 1 .4106087 . 604 1 1 -.58154786 . 604 1 1 -.58154786 . 604 1 1 -.58154786 . 604 1 1 -.58154786 . 604 1 1 -.58154786 . 605 1 1 .13896021 . 605 1 1 .13896021 . 605 1 1 .13896021 . 605 1 1 .13896021 . 606 1 1 -.14466457 . 606 1 1 -.14466457 . 606 1 1 -.14466457 . 606 1 1 -.14466457 . 607 1 1 -.6455818 . 607 1 1 -.6455818 . 607 1 1 -.6455818 . 607 1 1 -.6455818 . 608 1 1 .5520757 . 608 1 1 .5520757 . 608 1 1 .5520757 . 608 1 1 .5520757 . 608 1 1 .5520757 . 609 1 1 .4285006 . 609 1 1 .4285006 . 609 1 1 .4285006 . 609 1 1 .4285006 . 609 1 1 .4285006 . 610 1 1 .22801125 . 610 1 1 .22801125 . 610 1 1 .22801125 . 610 1 1 .22801125 . 610 1 1 .22801125 . 611 1 1 1.2872304 . 611 1 1 1.2872304 . 611 1 1 1.2872304 . 611 1 1 1.2872304 . 612 1 1 -.29343203 . 612 1 1 -.29343203 . end format %tm mdate label values SOX_size3 SOX_size3l label def SOX_size3l 1 "1 (Efficient within CO2)", modify label values bm_size3 bm_size3l label def bm_size3l 1 "Growth", modify
0 Response to Fama French: Calculating portfolio returns within sub-portfolios (aggregation of monthly returns) in different dimensions
Post a Comment