Kindly consider the below data example:
From this data, following is needed on rolling basis:
1. Monthly standard deviation, skewness and kurtosis of rt. For each month, previous 36 months of rt data should be used.
2. Beta (slope coefficient), idiovol (standard deviation of residuals) and idskew (skewness of residuals) obtained from least square regressions of rt (dependent)on mkt (independent) data using previous 36 months.
3. Third, from a separate regression of rt on mkt and mkt squared using previous 36 months data, generate coskew (as beta coefficient of mkt squared term).
As a whole these are seven monthly variables to be generated.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float stock_id str54 stock int date float(rt mkt) 1 "3M India Ltd." 15310 -.0887372 -.03955433 1 "3M India Ltd." 15341 -.026404494 .021463245 1 "3M India Ltd." 15372 .04250817 .07242663 1 "3M India Ltd." 15400 .149262 -.02732929 1 "3M India Ltd." 15431 .008990207 -.04528218 1 "3M India Ltd." 15461 -.10039777 -.0853004 1 "3M India Ltd." 15492 .008666431 .002052819 1 "3M India Ltd." 15522 .05207785 -.118447 1 "3M India Ltd." 15553 .05333333 .0436935 1 "3M India Ltd." 15584 -.003164557 -.04591998 1 "3M India Ltd." 15614 .003174603 -.012602217 1 "3M India Ltd." 15645 -.008227848 .04842421 1 "3M India Ltd." 15675 -.034620292 .04941667 1 "3M India Ltd." 15706 -.022806147 -.033169586 1 "3M India Ltd." 15737 -.06308135 .009157823 1 "3M India Ltd." 15765 -.13267148 -.0782898 1 "3M India Ltd." 15796 .1862643 -.010596635 1 "3M India Ltd." 15826 .10526316 .09825777 1 "3M India Ltd." 15857 .06095238 .06033916 1 "3M India Ltd." 15887 .0041891085 .04996381 1 "3M India Ltd." 15918 .10250298 .136254 1 "3M India Ltd." 15949 .11783784 .003297209 1 "3M India Ltd." 15979 .003384913 .06014735 1 "3M India Ltd." 16010 .2060241 .0712712 1 "3M India Ltd." 16040 .03886114 .18632157 1 "3M India Ltd." 16071 -.2037696 -.07444008 1 "3M India Ltd." 16102 -.02415459 .006037154 1 "3M India Ltd." 16131 .02722772 .007745117 1 "3M India Ltd." 16162 .1827711 .008075608 1 "3M India Ltd." 16192 -.17327085 -.1837298 1 "3M India Ltd." 16223 .06653524 .05848542 1 "3M India Ltd." 16253 .016751386 .05154314 1 "3M India Ltd." 16284 .03397341 -.002812333 1 "3M India Ltd." 16315 .1354945 .09279332 1 "3M India Ltd." 16345 -.04432401 .005587839 1 "3M India Ltd." 16376 .067341775 .07218837 1 "3M India Ltd." 16406 .0975332 .0309204 1 "3M India Ltd." 16437 -.006310512 -.030511327 2 "3P Land Holdings Ltd." 15310 -.04444445 -.03955433 2 "3P Land Holdings Ltd." 15341 -.011627907 .021463245 2 "3P Land Holdings Ltd." 15372 .2235294 .07242663 2 "3P Land Holdings Ltd." 15400 -.09615385 -.02732929 2 "3P Land Holdings Ltd." 15431 -.28723404 -.04528218 2 "3P Land Holdings Ltd." 15461 .9701493 -.0853004 2 "3P Land Holdings Ltd." 15492 .25757575 .002052819 2 "3P Land Holdings Ltd." 15522 -.1566265 -.118447 2 "3P Land Holdings Ltd." 15553 -.3214286 .0436935 2 "3P Land Holdings Ltd." 15584 -.15789473 -.04591998 2 "3P Land Holdings Ltd." 15614 0 -.012602217 2 "3P Land Holdings Ltd." 15645 0 .04842421 2 "3P Land Holdings Ltd." 15675 .125 .04941667 2 "3P Land Holdings Ltd." 15706 -.12777779 -.033169586 2 "3P Land Holdings Ltd." 15737 .2101911 .009157823 2 "3P Land Holdings Ltd." 15765 -.2105263 -.0782898 2 "3P Land Holdings Ltd." 15796 .13333334 -.010596635 2 "3P Land Holdings Ltd." 15826 -.1117647 .09825777 2 "3P Land Holdings Ltd." 15857 .3642384 .06033916 2 "3P Land Holdings Ltd." 15887 -.05339806 .04996381 2 "3P Land Holdings Ltd." 15918 .11794872 .136254 2 "3P Land Holdings Ltd." 15949 -.0825688 .003297209 2 "3P Land Holdings Ltd." 15979 -.19 .06014735 2 "3P Land Holdings Ltd." 16010 .4691358 .0712712 2 "3P Land Holdings Ltd." 16040 .25210086 .18632157 2 "3P Land Holdings Ltd." 16071 -.3389262 -.07444008 2 "3P Land Holdings Ltd." 16102 .11675127 .006037154 2 "3P Land Holdings Ltd." 16131 .0909091 .007745117 2 "3P Land Holdings Ltd." 16162 -.06666667 .008075608 2 "3P Land Holdings Ltd." 16192 .25 -.1837298 2 "3P Land Holdings Ltd." 16223 -.14285715 .05848542 2 "3P Land Holdings Ltd." 16253 .15833333 .05154314 2 "3P Land Holdings Ltd." 16284 .26258993 -.002812333 2 "3P Land Holdings Ltd." 16315 .36182335 .09279332 2 "3P Land Holdings Ltd." 16345 .10878661 .005587839 2 "3P Land Holdings Ltd." 16376 .10377359 .07218837 2 "3P Land Holdings Ltd." 16406 .14529915 .0309204 2 "3P Land Holdings Ltd." 16437 -.19701493 -.030511327 3 "A B B India Ltd." 15310 -.004149378 -.03955433 3 "A B B India Ltd." 15341 .09068628 .021463245 3 "A B B India Ltd." 15372 .154382 .07242663 3 "A B B India Ltd." 15400 .03387191 -.02732929 3 "A B B India Ltd." 15431 .002824327 -.04528218 3 "A B B India Ltd." 15461 -.07641757 -.0853004 3 "A B B India Ltd." 15492 .09270177 .002052819 3 "A B B India Ltd." 15522 .031069767 -.118447 3 "A B B India Ltd." 15553 .01930711 .0436935 3 "A B B India Ltd." 15584 -.00495663 -.04591998 3 "A B B India Ltd." 15614 -.14659314 -.012602217 3 "A B B India Ltd." 15645 -.0002084636 .04842421 3 "A B B India Ltd." 15675 .036905754 .04941667 3 "A B B India Ltd." 15706 .12306455 -.033169586 3 "A B B India Ltd." 15737 .14753805 .009157823 3 "A B B India Ltd." 15765 -.1015759 -.0782898 3 "A B B India Ltd." 15796 .07033692 -.010596635 3 "A B B India Ltd." 15826 .11487912 .09825777 3 "A B B India Ltd." 15857 .07335177 .06033916 3 "A B B India Ltd." 15887 .028338984 .04996381 3 "A B B India Ltd." 15918 .2542194 .136254 3 "A B B India Ltd." 15949 .003153911 .003297209 3 "A B B India Ltd." 15979 .09955984 .06014735 3 "A B B India Ltd." 16010 .010293557 .0712712 end format %td date
1. Monthly standard deviation, skewness and kurtosis of rt. For each month, previous 36 months of rt data should be used.
2. Beta (slope coefficient), idiovol (standard deviation of residuals) and idskew (skewness of residuals) obtained from least square regressions of rt (dependent)on mkt (independent) data using previous 36 months.
3. Third, from a separate regression of rt on mkt and mkt squared using previous 36 months data, generate coskew (as beta coefficient of mkt squared term).
As a whole these are seven monthly variables to be generated.
Comment