Hi Statalists,
I would like to find out how to use the last quarter's data to predict the average return for next quarter and my codes are at following. However, it gives me very identical results as the actual average returns. Can you possibly spot out any issues with the codes? Many thanks for your time in advance!
Here is my partial data;
I would like to find out how to use the last quarter's data to predict the average return for next quarter and my codes are at following. However, it gives me very identical results as the actual average returns. Can you possibly spot out any issues with the codes? Many thanks for your time in advance!
Here is my partial data;
Code:
----------------------- copy starting from the next line ----------------------- * Example generated by -dataex-. To install: ssc install dataex clear input float(quarter bygroup exret_q mktrf_q) 84 1 .08590318 -.011087168 84 2 .17209125 -.011087168 84 3 .05766841 -.011087168 84 4 .015939811 -.011087168 84 5 -.01977126 -.011087168 84 6 .1233931 -.011087168 84 7 .09358002 -.011087168 84 8 .14408113 -.011087168 84 9 .14963517 -.011087168 84 10 .09070672 -.011087168 84 11 .1130465 -.011087168 84 12 -.011868538 -.011087168 84 13 .10994432 -.011087168 84 14 -.0001912009 -.011087168 84 15 .026585907 -.011087168 84 16 -.05942601 -.011087168 84.5 1 .05371221 -.02707004 84.5 2 -.02868214 -.02707004 84.5 3 .13927232 -.02707004 84.5 4 .064015485 -.02707004 84.5 5 .07615793 -.02707004 84.5 6 -.026039254 -.02707004 84.5 7 .06555213 -.02707004 84.5 8 .032332473 -.02707004 84.5 9 .1002892 -.02707004 84.5 10 -.00951099 -.02707004 84.5 11 -.02960668 -.02707004 84.5 12 .09703401 -.02707004 84.5 13 .002914127 -.02707004 84.5 14 -.2539006 -.02707004 84.5 15 .10240318 -.02707004 85 1 .0569546 -.05559152 85 2 .04265504 -.0530838 85 3 .22243753 -.0530838 85 4 .12870449 -.05021784 85 5 -.010038707 -.052698 85 6 -.004677856 -.04723245 85 7 .0041046953 -.04663537 85 8 -.13193248 -.0639506 85 9 -.04614898 -.05559152 85 10 .13520205 -.04663537 85 11 -.0661721 -.05021784 85 12 .1068162 -.05559152 85 13 -.01922232 -.068130136 85 14 -.0877021 -.05977106 85 15 -.028843585 -.068130136 85 16 .16235334 -.05559152 85.33334 5 .06810419 -.003089834 85.33334 7 .13875547 -.003089834 85.33334 8 .018073361 -.003089834 85.33334 11 .08067591 -.003089834 85.33334 12 .25473818 -.003089834 85.5 1 -.071386494 -.07772773 85.5 2 .01040912 -.07394295 85.5 3 -.10528743 -.09665161 85.5 4 -.022837397 -.06826578 85.5 5 -.13816494 -.06421067 85.5 6 -.07573078 -.08718967 85.5 7 -.08642183 -.06826578 85.5 8 .014082927 -.011494124 85.5 9 -.0260128 -.02852562 85.5 10 -.034601748 -.07772773 85.5 12 .09964185 -.011494124 85.5 13 .04836208 -.03987996 85.5 14 -.1963301 -.05880384 85.5 16 -.10116123 -.03987996 85.66666 1 .05991086 -.05342508 85.66666 2 -.014532907 -.0388223 85.66666 4 .019898146 -.0388223 85.66666 15 .014424063 -.0388223 85.75 1 .11896713 -.0776314 85.75 6 .1138752 -.0776314 85.75 9 -.12332216 -.0776314 86 1 -.2565459 -.1106719 86 2 -.15351735 -.10443074 86 3 -.1149177 -.10019606 86 4 -.09041315 -.09986393 86 5 -.199297 -.11455728 86 6 -.10960802 -.10519774 86 7 -.11579135 -.09986393 86 8 -.0495661 -.13082646 86 9 -.0006912335 -.09423164 86 10 -.1576418 -.1106719 86 11 -.1861748 -.1166594 86 12 -.014756548 -.1178772 86 13 -.09887826 -.0855041 86 14 -.05815456 -.11053155 86 15 -.21315956 -.12988606 86.2 3 -.035441846 -.03973235 86.2 6 .02619724 -.03973235 86.2 15 .017663904 -.03973235 86.2 16 -.02505945 -.03973235 86.25 3 .10454059 -.01210286 86.25 10 -.12598273 -.05565052 86.33334 1 -.07782044 -.04395874 86.33334 3 -.0694222 .01189532 86.33334 5 -.1541924 -.0998128 86.33334 7 -.024051307 .01189532 86.33334 10 -.10774209 -.0998128 86.4 7 .08607323 -.069933504 end format %tq quarter label values bygroup bygroup
Code:
* bygroup is the double sorts portfolios built up by using last quarter's data egen bygroup = group(P1 P2), label levelsof bygroup, local(bygroup) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 gen yhat = . foreach i of local bygroup { foreach j in quarter { reg exret_q mktrf_q if bygroup == `i' & quarter == `j' replace yhat = _b[_cons]+ _b[mktrf_q]*mktrf_q if bygroup == `i' & quarter == `j' } }
Comment