Dear all,
I am working with an unbalanced panel dataset where the panel var is the fund number and the time var is the month. Thus, I am working with monthly time series but with gaps. What I want is to calculate the 3-year Sharpe ratio and also the 3-year jensens alpha for each fund. So, if I am at year 1992 I would like to calculate the Sharpe ratio for that year using the monthy observations of the years 1992 1991 1990. To do so i need the mean and sd of the excess returns of each fund during that period. In addition, I would like to estimate the Jensens Alpha by running the CAPM model using again the monthly observations from years 1992 1991 1990. To do so I could use the statsby command and use the coefficients of a regression running during that period. I haved tried many commands like rollreg, movavg, ma etc and also some locals with foreach/forvalues but I cant employ them as I dont have a balanced panel and I dont want to eliminate funds because I might have one or two gaps.
this is an example of my dataset
crsp_f~o r_year month mktrf smb hml umd ExcessR~s |
|---------------------------------------------------------------------------|
2 1997 1 . . . . . |
2 1997 2 -.0049 -.0261 .0469 -.0204 . |
2 1997 3 -.0503 -.0032 .0386 .0094 -.0181431 |
2 1997 4 .0404 -.0519 -.0102 .0489 .0117428 |
2 1997 5 .0674 .0483 -.0438 -.0519 .0372053 |
|---------------------------------------------------------------------------|
2 1997 6 .041 .015 .0072 .0259 .0310222 |
2 1997 7 .0733 -.0252 -.0013 .0384 .0402394 |
2 1997 8 -.0415 .0734 .0137 -.0252 -.0292168 |
2 1997 9 .0535 .0268 -.0025 .0145 .0381404 |
2 1998 1 .0015 -.0094 -.0207 .001 .0056473 |
|---------------------------------------------------------------------------|
2 1998 2 .0703 .0032 -.0086 -.011 .0395531 |
2 1998 3 .0476 -.0099 .0123 .0214 .0277491 |
2 1998 4 .0073 .0048 .0027 .0078 .0005439 |
2 1998 5 -.0307 -.0354 .0412 .0189 -.0093562 |
2 1998 6 .0318 -.0315 -.0222 .0726 .002362 |
|---------------------------------------------------------------------------|
2 1998 7 -.0246 -.0492 -.0115 .0371 -.0232616 |
2 1998 8 -.1608 -.0575 .0524 .0187 -.091043 |
2 1998 9 .0615 -.0015 -.0388 -.0063 .0222817 |
2 1998 10 .0713 -.032 -.0277 -.0535 .0311223 |
2 1998 11 .061 .0114 -.0343 .0118 .0300834 |
|---------------------------------------------------------------------------|
2 1998 12 .0616 -.003 -.047 .0904 .0168859 |
7 1994 1 .0287 .0014 .021 .0001 .0183894 |
7 1994 2 -.0256 .0272 -.0141 -.0026 -.0170168 |
7 1994 3 -.0478 -.0096 .0134 -.0132 -.0656004 |
7 1994 4 .0068 -.0091 .0169 .0041 -.0032034 |
|---------------------------------------------------------------------------|
7 1994 5 .0058 -.0201 .0018 -.0216 -.0093189 |
7 1994 6 -.0303 -.0048 .0168 -.0083 -.0506594 |
7 1994 7 .0282 -.0178 .0098 .0019 .0199595 |
7 1994 8 .0401 .0145 -.0347 .0154 .0419298 |
7 1994 9 -.0231 .0268 -.0181 .0131 -.0135341 |
|---------------------------------------------------------------------------|
7 1994 10 .0134 -.022 -.0236 .0145 .0129598 |
7 1994 11 -.0404 -.0017 -.0005 -.0019 -.0433825 |
7 1994 12 .0086 .0005 .0026 .035 .0152948 |
Thanks in advance!
Best,
J.M.
I am working with an unbalanced panel dataset where the panel var is the fund number and the time var is the month. Thus, I am working with monthly time series but with gaps. What I want is to calculate the 3-year Sharpe ratio and also the 3-year jensens alpha for each fund. So, if I am at year 1992 I would like to calculate the Sharpe ratio for that year using the monthy observations of the years 1992 1991 1990. To do so i need the mean and sd of the excess returns of each fund during that period. In addition, I would like to estimate the Jensens Alpha by running the CAPM model using again the monthly observations from years 1992 1991 1990. To do so I could use the statsby command and use the coefficients of a regression running during that period. I haved tried many commands like rollreg, movavg, ma etc and also some locals with foreach/forvalues but I cant employ them as I dont have a balanced panel and I dont want to eliminate funds because I might have one or two gaps.
this is an example of my dataset
crsp_f~o r_year month mktrf smb hml umd ExcessR~s |
|---------------------------------------------------------------------------|
2 1997 1 . . . . . |
2 1997 2 -.0049 -.0261 .0469 -.0204 . |
2 1997 3 -.0503 -.0032 .0386 .0094 -.0181431 |
2 1997 4 .0404 -.0519 -.0102 .0489 .0117428 |
2 1997 5 .0674 .0483 -.0438 -.0519 .0372053 |
|---------------------------------------------------------------------------|
2 1997 6 .041 .015 .0072 .0259 .0310222 |
2 1997 7 .0733 -.0252 -.0013 .0384 .0402394 |
2 1997 8 -.0415 .0734 .0137 -.0252 -.0292168 |
2 1997 9 .0535 .0268 -.0025 .0145 .0381404 |
2 1998 1 .0015 -.0094 -.0207 .001 .0056473 |
|---------------------------------------------------------------------------|
2 1998 2 .0703 .0032 -.0086 -.011 .0395531 |
2 1998 3 .0476 -.0099 .0123 .0214 .0277491 |
2 1998 4 .0073 .0048 .0027 .0078 .0005439 |
2 1998 5 -.0307 -.0354 .0412 .0189 -.0093562 |
2 1998 6 .0318 -.0315 -.0222 .0726 .002362 |
|---------------------------------------------------------------------------|
2 1998 7 -.0246 -.0492 -.0115 .0371 -.0232616 |
2 1998 8 -.1608 -.0575 .0524 .0187 -.091043 |
2 1998 9 .0615 -.0015 -.0388 -.0063 .0222817 |
2 1998 10 .0713 -.032 -.0277 -.0535 .0311223 |
2 1998 11 .061 .0114 -.0343 .0118 .0300834 |
|---------------------------------------------------------------------------|
2 1998 12 .0616 -.003 -.047 .0904 .0168859 |
7 1994 1 .0287 .0014 .021 .0001 .0183894 |
7 1994 2 -.0256 .0272 -.0141 -.0026 -.0170168 |
7 1994 3 -.0478 -.0096 .0134 -.0132 -.0656004 |
7 1994 4 .0068 -.0091 .0169 .0041 -.0032034 |
|---------------------------------------------------------------------------|
7 1994 5 .0058 -.0201 .0018 -.0216 -.0093189 |
7 1994 6 -.0303 -.0048 .0168 -.0083 -.0506594 |
7 1994 7 .0282 -.0178 .0098 .0019 .0199595 |
7 1994 8 .0401 .0145 -.0347 .0154 .0419298 |
7 1994 9 -.0231 .0268 -.0181 .0131 -.0135341 |
|---------------------------------------------------------------------------|
7 1994 10 .0134 -.022 -.0236 .0145 .0129598 |
7 1994 11 -.0404 -.0017 -.0005 -.0019 -.0433825 |
7 1994 12 .0086 .0005 .0026 .035 .0152948 |
Thanks in advance!
Best,
J.M.
Comment