Hello everyone,
I am posting regarding how to calculate Buy and Hold returns using monthly returns.
My data consists of the monthly returns for various firms as downloaded from CRSP and looks like the following: (FYI columns ret1, prod & BHAR all calculated by me as explained below):
My first question is: How can I calculate the 12 month buy and hold returns (BHAR) for given month t?
where BHAR=[ ((1+ return of month 1) * (1+ return of month 2)*….*(1+return of month12)) - 1]
e.g.: Firm 1's BHAR for purchase in March 2015 =[((1+return of March 2015)*(1+return of April 2015)*(1+return of May 2015)* ...*(1+return of Feb 2016)) - 1]
(FYI using Stata /SE v 14.1)
In addition, in a previous post, I found the following code:
However, this calculates based on the calendar year taking the sum of Jan to Dec returns. I want to calculate 1 year returns using any month of the year.
I tried amending the above code using forval to calculate the 12 months difference between the dates but the resulting BHAR is incorrect.
my amended code is:
As a result, my second question is how can I amend this code so that prod=exp of the 12 months following each focal month t?
As I am still relatively new to usingforval, I'd really appreciate any advice on what I am applying incorrectly and please let me know if you need any additional information!
Thank you!
I am posting regarding how to calculate Buy and Hold returns using monthly returns.
My data consists of the monthly returns for various firms as downloaded from CRSP and looks like the following: (FYI columns ret1, prod & BHAR all calculated by me as explained below):
firm_id | date | ret | month | ret1 | prod | BHAR |
10001 | 11/30/2015 | -0.00907 | 1 | 0.99093 | -0.00911 | -1.00911 |
10001 | 12/31/2015 | -0.13215 | 2 | 0.867849 | -0.14174 | -1.14174 |
10001 | 01/29/2016 | 0.116779 | 3 | 1.116778 | 0.110448 | -0.88955 |
10001 | 02/29/2016 | -0.05529 | 4 | 0.944712 | -0.05688 | -1.05688 |
10001 | 03/31/2016 | -0.00636 | 5 | 0.993639 | -0.00638 | -1.00638 |
10001 | 04/29/2016 | -0.0557 | 6 | 0.944302 | -0.05731 | -1.05731 |
10001 | 05/31/2016 | -0.02192 | 7 | 0.978082 | -0.02216 | -1.02216 |
10001 | 06/30/2016 | -0.02101 | 8 | 0.978992 | -0.02123 | -1.02123 |
10001 | 07/29/2016 | 0.026466 | 9 | 1.026466 | 0.026122 | -0.97388 |
10001 | 08/31/2016 | 0.03662 | 10 | 1.03662 | 0.035965 | -0.96403 |
10001 | 09/30/2016 | 0.04212 | 11 | 1.04212 | 0.041257 | -0.95874 |
10001 | 10/31/2016 | 0.619948 | 12 | 1.619948 | 0.482394 | -0.51761 |
10001 | 11/30/2016 | 0.012146 | 13 | 1.012146 | 0.012073 | -0.98793 |
10001 | 12/30/2016 | 0.01 | 14 | 1.01 | 0.00995 | -0.99005 |
10002 | 01/31/1986 | .c | 1 | 0 | -1 | |
10002 | 02/28/1986 | 0.139785 | 2 | 1.139785 | 0.13084 | -0.86916 |
10002 | 03/31/1986 | 0.070755 | 3 | 1.070755 | 0.068364 | -0.93164 |
10002 | 04/30/1986 | 0.052863 | 4 | 1.052863 | 0.051514 | -0.94849 |
10002 | 05/30/1986 | -0.02092 | 5 | 0.97908 | -0.02114 | -1.02114 |
10002 | 06/30/1986 | -0.13248 | 6 | 0.867521 | -0.14212 | -1.14212 |
10002 | 07/31/1986 | 0.049261 | 7 | 1.049261 | 0.048086 | -0.95191 |
10002 | 08/29/1986 | 0 | 8 | 1 | 0 | -1 |
10002 | 09/30/1986 | 0.070423 | 9 | 1.070423 | 0.068054 | -0.93195 |
10002 | 10/31/1986 | -0.0614 | 10 | 0.938597 | -0.06337 | -1.06337 |
10002 | 11/28/1986 | 0 | 11 | 1 | 0 | -1 |
10002 | 12/31/1986 | -0.07477 | 12 | 0.925234 | -0.07771 | -1.07771 |
10002 | 01/30/1987 | 0.09596 | 13 | 1.09596 | 0.09163 | -0.90837 |
10002 | 02/27/1987 | -0.01382 | 14 | 0.986175 | -0.01392 | -1.01392 |
My first question is: How can I calculate the 12 month buy and hold returns (BHAR) for given month t?
where BHAR=[ ((1+ return of month 1) * (1+ return of month 2)*….*(1+return of month12)) - 1]
e.g.: Firm 1's BHAR for purchase in March 2015 =[((1+return of March 2015)*(1+return of April 2015)*(1+return of May 2015)* ...*(1+return of Feb 2016)) - 1]
(FYI using Stata /SE v 14.1)
In addition, in a previous post, I found the following code:
Code:
gen ret = 1+return bysort firmid year : gen prod = sum(ln(ret)) by firmid year : replace prod = exp(prod[_N]) gen buy_hold_ret= prod-1
I tried amending the above code using forval to calculate the 12 months difference between the dates but the resulting BHAR is incorrect.
my amended code is:
Code:
gen ret1=1+ret bysort permno month: gen prod=sum(ln(ret1)) forvalues i = 1/`=_N' { count if dum==1 & permno==permno[`i'] & /// inrange(month[`i']- month, 0, 12) by permno month: replace prod=exp(r(N)) in `i' } / gen BHAR=prod-1
As I am still relatively new to usingforval, I'd really appreciate any advice on what I am applying incorrectly and please let me know if you need any additional information!
Thank you!
Comment