From the appended dataset, I require monthly residuals series for each company (identified by a unique com_id) by regressing the monthly rt minus rf of each company on their monthly market and industry. The market and industry for each company are calculated as below:
1. The market is the cross-sectional average of rt of all companies in the sample minus the rf. The market variable is the same for all companies.
2. The industry for a company is the cross-sectional average of rt of all companies in a given industry type (identified by ind_id), excluding the rt of the company whose industry is to be calculated. The industry is therefore unique for each company.
1. The market is the cross-sectional average of rt of all companies in the sample minus the rf. The market variable is the same for all companies.
2. The industry for a company is the cross-sectional average of rt of all companies in a given industry type (identified by ind_id), excluding the rt of the company whose industry is to be calculated. The industry is therefore unique for each company.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(com_id ind_id) str52 company_name str30 industry_type int date float mdate double pr float(rt rf) 1 1 "3M India Ltd." "chemical and chemical products" 18353 603 2311.7 .03894294 .0269 1 1 "3M India Ltd." "chemical and chemical products" 18383 604 2523.25 .09151274 -.06165488 1 1 "3M India Ltd." "chemical and chemical products" 18414 605 2772.7 .0988606 -.000396616 1 1 "3M India Ltd." "chemical and chemical products" 18444 606 3497.65 .26145995 .03200635 1 1 "3M India Ltd." "chemical and chemical products" 18475 607 3305.15 -.05503695 .017044727 2 5 "A B B India Ltd." "machinery" 18353 603 791.5 -.04661527 .0269 2 5 "A B B India Ltd." "machinery" 18383 604 857.05 .08281744 -.06165488 2 5 "A B B India Ltd." "machinery" 18414 605 862.15 .005950645 -.000396616 2 5 "A B B India Ltd." "machinery" 18444 606 812.05 -.05811054 .03200635 2 5 "A B B India Ltd." "machinery" 18475 607 777 -.04316237 .017044727 3 2 "A C C Ltd." "construction material" 18353 603 906.15 -.0466095 .0269 3 2 "A C C Ltd." "construction material" 18383 604 817 -.09838327 -.06165488 3 2 "A C C Ltd." "construction material" 18414 605 874.5 .070379436 -.000396616 3 2 "A C C Ltd." "construction material" 18444 606 831.45 -.04922813 .03200635 3 2 "A C C Ltd." "construction material" 18475 607 871.8 .04852968 .017044727 4 4 "A D F Foods Ltd." "food and agro based products" 18353 603 95.7 .025174076 .0269 4 4 "A D F Foods Ltd." "food and agro based products" 18383 604 73.6 -.23093 -.06165488 4 4 "A D F Foods Ltd." "food and agro based products" 18414 605 81.3 .10461956 -.000396616 4 4 "A D F Foods Ltd." "food and agro based products" 18444 606 75.65 -.06949569 .03200635 4 4 "A D F Foods Ltd." "food and agro based products" 18475 607 69.55 -.0806345 .017044727 5 7 "A G I Greenpac Ltd." "miscellaneous" 18353 603 87.1 .12459651 .0269 5 7 "A G I Greenpac Ltd." "miscellaneous" 18383 604 86.5 -.006888634 -.06165488 5 7 "A G I Greenpac Ltd." "miscellaneous" 18414 605 92.95 .07456648 -.000396616 5 7 "A G I Greenpac Ltd." "miscellaneous" 18444 606 122.05 .31307155 .03200635 5 7 "A G I Greenpac Ltd." "miscellaneous" 18475 607 130.25 .06718558 .017044727 6 6 "A I A Engineering Ltd." "material and material products" 18353 603 392.9 -.015411602 .0269 6 6 "A I A Engineering Ltd." "material and material products" 18383 604 401.3 .021379486 -.06165488 6 6 "A I A Engineering Ltd." "material and material products" 18414 605 383.1 -.0453526 -.000396616 6 6 "A I A Engineering Ltd." "material and material products" 18444 606 357.85 -.06590968 .03200635 6 6 "A I A Engineering Ltd." "material and material products" 18475 607 361.45 .01006008 .017044727 7 8 "A I Champdany Inds. Ltd." "textile" 18353 603 29.6 .23333333 .0269 7 8 "A I Champdany Inds. Ltd." "textile" 18383 604 29 -.02027027 -.06165488 7 8 "A I Champdany Inds. Ltd." "textile" 18414 605 33.05 .13965517 -.000396616 7 8 "A I Champdany Inds. Ltd." "textile" 18444 606 35.9 .08623298 .03200635 7 8 "A I Champdany Inds. Ltd." "textile" 18475 607 39.3 .09470752 .017044727 8 1 "A M D Industries Ltd." "chemical and chemical products" 18353 603 25.65 .11038961 .0269 8 1 "A M D Industries Ltd." "chemical and chemical products" 18383 604 23.55 -.08187135 -.06165488 8 1 "A M D Industries Ltd." "chemical and chemical products" 18414 605 22.8 -.031847134 -.000396616 8 1 "A M D Industries Ltd." "chemical and chemical products" 18444 606 25 .09649123 .03200635 8 1 "A M D Industries Ltd." "chemical and chemical products" 18475 607 25.5 .02 .017044727 9 6 "A P L Apollo Tubes Ltd." "material and material products" 18353 603 12.27 .10341727 .0269 9 6 "A P L Apollo Tubes Ltd." "material and material products" 18383 604 11.27 -.0814996 -.06165488 9 6 "A P L Apollo Tubes Ltd." "material and material products" 18414 605 10.75 -.04614019 -.000396616 9 6 "A P L Apollo Tubes Ltd." "material and material products" 18444 606 12.02 .11813954 .03200635 9 6 "A P L Apollo Tubes Ltd." "material and material products" 18475 607 13.39 .1139767 .017044727 10 8 "A P M Industries Ltd." "textile" 18353 603 9.52 -.04225352 .0269 10 8 "A P M Industries Ltd." "textile" 18383 604 9.78 .027310925 -.06165488 10 8 "A P M Industries Ltd." "textile" 18414 605 11.36 .1615542 -.000396616 10 8 "A P M Industries Ltd." "textile" 18444 606 11.37 .0008802817 .03200635 10 8 "A P M Industries Ltd." "textile" 18475 607 14.05 .235708 .017044727 11 8 "A Y M Syntex Ltd." "textile" 18353 603 16.12 .30844155 .0269 11 8 "A Y M Syntex Ltd." "textile" 18383 604 15.1 -.063275434 -.06165488 11 8 "A Y M Syntex Ltd." "textile" 18414 605 14.8 -.01986755 -.000396616 11 8 "A Y M Syntex Ltd." "textile" 18444 606 14.73 -.00472973 .03200635 11 8 "A Y M Syntex Ltd." "textile" 18475 607 16.8 .14052953 .017044727 12 1 "Aarti Drugs Ltd." "chemical and chemical products" 18353 603 14.71 .15191856 .0269 12 1 "Aarti Drugs Ltd." "chemical and chemical products" 18383 604 14.95 .016315432 -.06165488 12 1 "Aarti Drugs Ltd." "chemical and chemical products" 18414 605 16.79 .12307692 -.000396616 12 1 "Aarti Drugs Ltd." "chemical and chemical products" 18444 606 17.83 .06194163 .03200635 12 1 "Aarti Drugs Ltd." "chemical and chemical products" 18475 607 17.77 -.003365115 .017044727 13 1 "Aarti Industries Ltd." "chemical and chemical products" 18353 603 12.28 .035413153 .0269 13 1 "Aarti Industries Ltd." "chemical and chemical products" 18383 604 11.94 -.027687296 -.06165488 13 1 "Aarti Industries Ltd." "chemical and chemical products" 18414 605 12.29 .02931323 -.000396616 13 1 "Aarti Industries Ltd." "chemical and chemical products" 18444 606 12.86 .04637917 .03200635 13 1 "Aarti Industries Ltd." "chemical and chemical products" 18475 607 13.63 .05987558 .017044727 14 8 "Aarvee Denims & Exports Ltd." "textile" 18353 603 63.65 -.06190125 .0269 14 8 "Aarvee Denims & Exports Ltd." "textile" 18383 604 57.1 -.10290652 -.06165488 14 8 "Aarvee Denims & Exports Ltd." "textile" 18414 605 58.7 .028021015 -.000396616 14 8 "Aarvee Denims & Exports Ltd." "textile" 18444 606 64.25 .09454855 .03200635 14 8 "Aarvee Denims & Exports Ltd." "textile" 18475 607 85.1 .3245136 .017044727 15 1 "Abbott India Ltd." "chemical and chemical products" 18353 603 936.25 .05886677 .0269 15 1 "Abbott India Ltd." "chemical and chemical products" 18383 604 1019.55 .08897197 -.06165488 15 1 "Abbott India Ltd." "chemical and chemical products" 18414 605 1141.45 .11956255 -.000396616 15 1 "Abbott India Ltd." "chemical and chemical products" 18444 606 1138.4 -.00267204 .03200635 15 1 "Abbott India Ltd." "chemical and chemical products" 18475 607 1129.7 -.007642305 .017044727 16 8 "Acknit Industries Ltd." "textile" 18353 603 29.45 -.02644628 .0269 16 8 "Acknit Industries Ltd." "textile" 18383 604 30.2 .025466893 -.06165488 16 8 "Acknit Industries Ltd." "textile" 18414 605 28.8 -.04635762 -.000396616 16 8 "Acknit Industries Ltd." "textile" 18444 606 29 .006944444 .03200635 16 8 "Acknit Industries Ltd." "textile" 18475 607 34.15 .1775862 .017044727 17 5 "Action Construction Equipment Ltd." "machinery" 18353 603 50.2 .14742857 .0269 17 5 "Action Construction Equipment Ltd." "machinery" 18383 604 48.45 -.03486056 -.06165488 17 5 "Action Construction Equipment Ltd." "machinery" 18414 605 49 .01135191 -.000396616 17 5 "Action Construction Equipment Ltd." "machinery" 18444 606 56.4 .1510204 .03200635 17 5 "Action Construction Equipment Ltd." "machinery" 18475 607 65.1 .1542553 .017044727 18 5 "Ador Fontech Ltd." "machinery" 18353 603 25.68 .4665905 .0269 18 5 "Ador Fontech Ltd." "machinery" 18383 604 26.33 .025311526 -.06165488 18 5 "Ador Fontech Ltd." "machinery" 18414 605 29.11 .10558298 -.000396616 18 5 "Ador Fontech Ltd." "machinery" 18444 606 26.34 -.0951563 .03200635 18 5 "Ador Fontech Ltd." "machinery" 18475 607 29.81 .1317388 .017044727 19 5 "Ador Welding Ltd." "machinery" 18353 603 181.6 .08095238 .0269 19 5 "Ador Welding Ltd." "machinery" 18383 604 188.15 .036068283 -.06165488 19 5 "Ador Welding Ltd." "machinery" 18414 605 212.75 .13074675 -.000396616 19 5 "Ador Welding Ltd." "machinery" 18444 606 211.75 -.004700352 .03200635 19 5 "Ador Welding Ltd." "machinery" 18475 607 203.25 -.04014168 .017044727 20 4 "Agro Tech Foods Ltd." "food and agro based products" 18353 603 265.2 .0732497 .0269 20 4 "Agro Tech Foods Ltd." "food and agro based products" 18383 604 234.95 -.11406486 -.06165488 20 4 "Agro Tech Foods Ltd." "food and agro based products" 18414 605 328.25 .39710575 -.000396616 20 4 "Agro Tech Foods Ltd." "food and agro based products" 18444 606 298.6 -.0903275 .03200635 20 4 "Agro Tech Foods Ltd." "food and agro based products" 18475 607 260.2 -.12860014 .017044727 end format %td date format %tm mdate
Comment