Dear All
Just a simple question, I need equally weighted portfolio returns and value weighted portfolio returns where the weighting is by the market capitalization (market value; mv).
***to calculate annual returns from monthly returns, I use the following code:
gen month_id=mofd(date)
label var month_id "numberical date variable; monthly frequency"
xtset permno month_id
gen annual_ret= (1+f1.ret)* (1+f2.ret)*(1+f3.ret)*(1+f4.ret)*(1+f5.ret)*(1+f6. ret)*(1+f7.ret)*(1+f8.ret)*(1+f9.ret)*(1+f10.ret)* (1+f11.ret)*(1+f12.ret)-1
**In further steps , I keep only annual_ret reported at the end of the fiscal year, then I create portfolios using the following code:
egen NYSE_portfolio = xtile(op2WA) , by(yr) p(10(10)90) // where op2WA is the ranking variable // this code rebalances portfolios every year
** In order to calculate portfolio equally weighted returns for the holding period (month 1 to 12) and post holding period (month 12 -24 and 24-36)
sort firmid yr
gen f12_24_annual_ret=f.annual_ret
gen f22_36_annual_ret=f2.annual_ret
egen portret=mean(annual_ret), by (All_portfolio yr) // this is holding return
egen f12_24_portret= mean (f12_24_annual_ret), by (All_portfolio yr)
egen f24_36_portret= mean (f12_24_ annual _ret), by (All_portfolio yr)
** In order to calculate portfolio value weighted returns where the MV is weighting variable:
egen mvweight_return = wtmean(portret), weight(crmv) by(All_portfolio yr)
1- Unfortunately, the equally weighted portfolio is identical to value weighted portfolio mean which might suggest I am doing something incorrect here
2- Can anyone spot any problems in these codes , probably also from an accounting or finance perspective , if returns are calculated the correct way ?
Thanks
Ahmed
Just a simple question, I need equally weighted portfolio returns and value weighted portfolio returns where the weighting is by the market capitalization (market value; mv).
***to calculate annual returns from monthly returns, I use the following code:
gen month_id=mofd(date)
label var month_id "numberical date variable; monthly frequency"
xtset permno month_id
gen annual_ret= (1+f1.ret)* (1+f2.ret)*(1+f3.ret)*(1+f4.ret)*(1+f5.ret)*(1+f6. ret)*(1+f7.ret)*(1+f8.ret)*(1+f9.ret)*(1+f10.ret)* (1+f11.ret)*(1+f12.ret)-1
**In further steps , I keep only annual_ret reported at the end of the fiscal year, then I create portfolios using the following code:
egen NYSE_portfolio = xtile(op2WA) , by(yr) p(10(10)90) // where op2WA is the ranking variable // this code rebalances portfolios every year
** In order to calculate portfolio equally weighted returns for the holding period (month 1 to 12) and post holding period (month 12 -24 and 24-36)
sort firmid yr
gen f12_24_annual_ret=f.annual_ret
gen f22_36_annual_ret=f2.annual_ret
egen portret=mean(annual_ret), by (All_portfolio yr) // this is holding return
egen f12_24_portret= mean (f12_24_annual_ret), by (All_portfolio yr)
egen f24_36_portret= mean (f12_24_ annual _ret), by (All_portfolio yr)
** In order to calculate portfolio value weighted returns where the MV is weighting variable:
egen mvweight_return = wtmean(portret), weight(crmv) by(All_portfolio yr)
1- Unfortunately, the equally weighted portfolio is identical to value weighted portfolio mean which might suggest I am doing something incorrect here
2- Can anyone spot any problems in these codes , probably also from an accounting or finance perspective , if returns are calculated the correct way ?
Thanks
Ahmed
Comment