For my Master's thesis I have to calculate 'Market Model Adjusted Return' with market model parameters computed over the five-year period ending in July 2008 & 'Idiosyncratic Risk', which is computed as the residual variance from the market model estimated over the five-year period ending in July 2008, using monthly data. There are over 3,000 companies in my dataset.
I was able to get the the market model parameters for 'Market Model Adjusted Return' by using: rangestat (reg) lnret marketreturn, interval(crisis 0 0) by(PERMNO)
However, this command doesn't give residuals for the variable 'Idiosyncratic Risk'. So I need a command that does give me, for each company, 1 residual for the regression lnret marketreturn in the five-year period ending in July 2008 (crisis==0).
Could anyone please help me with the code to obtain the residuals?
Thank you,
Julia
*crisis is a dummy variable set to 1 if NamesDate is between 20030731-20080731
*lnret is the natural logarithm of return
*beta2 and alpha2 are market model parameters calculated with rangestat if crisis==0
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long(PERMNO NamesDate) float lnret double marketreturn float(crisis beta2 alpha2) 10002 20030731 . .021749 0 1.215891 -.019994756 10002 20030829 .0024891114 .023516 0 1.215891 -.019994756 10002 20030930 -.06350322 -.010602 0 1.215891 -.019994756 10002 20031031 .021618923 .058836 0 1.215891 -.019994756 10002 20031128 .02242965 .015052 0 1.215891 -.019994756 10002 20031231 .015094626 .043848 0 1.215891 -.019994756 10002 20040130 .005602255 .022013 0 1.215891 -.019994756 10002 20040227 .11370549 .013994 0 1.215891 -.019994756 10002 20040331 -.031516396 -.011991 0 1.215891 -.019994756 10002 20040430 -.03727863 -.02556 0 1.215891 -.019994756 10002 20040528 .015896713 .012374 0 1.215891 -.019994756 10002 20040630 .023095714 .020039 0 1.215891 -.019994756 10002 20040730 .003418807 -.038765 0 1.215891 -.019994756 10002 20040831 .022498136 .001083 0 1.215891 -.019994756 10002 20040930 .04459684 .019085 0 1.215891 -.019994756 10002 20041029 .01058211 .016579 0 1.215891 -.019994756 10002 20041130 .1142681 .044313 0 1.215891 -.019994756 10002 20041231 .14444579 .033422 0 1.215891 -.019994756 10002 20050131 -.14210112 -.027405 0 1.215891 -.019994756 10002 20050228 -.0338208 .020839 0 1.215891 -.019994756 10002 20050331 -.019570095 -.018583 0 1.215891 -.019994756 10002 20050429 -.06902816 -.026569 0 1.215891 -.019994756 10002 20050531 .04553296 .03615 0 1.215891 -.019994756 10002 20050630 -.012213892 .009902 0 1.215891 -.019994756 10002 20050729 .07637298 .042229 0 1.215891 -.019994756 10002 20050831 .032208152 -.007761 0 1.215891 -.019994756 10002 20050930 -.12146459 .009338 0 1.215891 -.019994756 10002 20051031 -.04563126 -.021981 0 1.215891 -.019994756 10002 20051130 .09125499 .03807 0 1.215891 -.019994756 10002 20051230 -.0039721997 .001886 0 1.215891 -.019994756 10002 20060131 .029413885 .038935 0 1.215891 -.019994756 10002 20060228 .06363232 -.003553 0 1.215891 -.019994756 10002 20060331 .0040714825 .017575 0 1.215891 -.019994756 10002 20060428 -.069638036 .011492 0 1.215891 -.019994756 10002 20060531 .04819071 -.033021 0 1.215891 -.019994756 10002 20060630 .07933284 -.001883 0 1.215891 -.019994756 10002 20060731 .1580993 -.002918 0 1.215891 -.019994756 10002 20060831 -.034792554 .022974 0 1.215891 -.019994756 10002 20060929 .04923845 .018105 0 1.215891 -.019994756 10002 20061031 -.129187 .036087 0 1.215891 -.019994756 10002 20061130 -.012315427 .021338 0 1.215891 -.019994756 10002 20061229 .05269669 .009153 0 1.215891 -.019994756 10002 20070131 -.1723402 .018461 0 1.215891 -.019994756 10002 20070228 .032519467 -.015979 0 1.215891 -.019994756 10002 20070330 -.04752913 .011475 0 1.215891 -.019994756 10002 20070430 -.05488146 .038449 0 1.215891 -.019994756 10002 20070531 .00049912656 .036643 0 1.215891 -.019994756 10002 20070629 .04679216 -.016128 0 1.215891 -.019994756 10002 20070731 -.18346506 -.032764 0 1.215891 -.019994756 10002 20070831 -.073580034 .009677 0 1.215891 -.019994756 10002 20070928 -.018018505 .039325 0 1.215891 -.019994756 10002 20071031 -.16751015 .024655 0 1.215891 -.019994756 10002 20071130 -.08022805 -.051276 0 1.215891 -.019994756 10002 20071231 -.02851517 -.006511 0 1.215891 -.019994756 10002 20080131 .02045061 -.063243 0 1.215891 -.019994756 10002 20080229 -.1166703 -.023605 0 1.215891 -.019994756 10002 20080331 -.022080014 -.01216 0 1.215891 -.019994756 10002 20080430 .01018056 .049736 0 1.215891 -.019994756 10002 20080530 -.07651915 .021494 0 1.215891 -.019994756 10002 20080630 -.4230138 -.080241 0 1.215891 -.019994756 10002 20080731 .12934968 -.01469 0 1.215891 -.019994756 10002 20080829 .1180793 .008576 1 1.215891 -.019994756 10002 20080930 .4411555 -.09977 1 1.215891 -.019994756 10002 20081031 -.05161427 -.186131 1 1.215891 -.019994756 10002 20081128 .0016038496 -.08735 1 1.215891 -.019994756 10002 20081231 .16779345 .019088 1 1.215891 -.019994756 10002 20090130 -.50924605 -.078704 1 1.215891 -.019994756 10002 20090227 -.374386 -.103448 1 1.215891 -.019994756 10002 20090331 .037011463 .083479 1 1.215891 -.019994756 10025 20030731 . .021749 0 1.53617 .0039992216 10025 20030829 .06628192 .023516 0 1.53617 .0039992216 10025 20030930 .04980763 -.010602 0 1.53617 .0039992216 10025 20031031 -.16551444 .058836 0 1.53617 .0039992216 10025 20031128 -.035281815 .015052 0 1.53617 .0039992216 10025 20031231 .29651722 .043848 0 1.53617 .0039992216 10025 20040130 .12175683 .022013 0 1.53617 .0039992216 10025 20040227 .003629768 .013994 0 1.53617 .0039992216 10025 20040331 -.0312813 -.011991 0 1.53617 .0039992216 10025 20040430 .10965037 -.02556 0 1.53617 .0039992216 10025 20040528 -.11527362 .012374 0 1.53617 .0039992216 10025 20040630 .04232462 .020039 0 1.53617 .0039992216 10025 20040730 -.04138521 -.038765 0 1.53617 .0039992216 10025 20040831 -.017045867 .001083 0 1.53617 .0039992216 10025 20040930 .02359713 .019085 0 1.53617 .0039992216 10025 20041029 .03122384 .016579 0 1.53617 .0039992216 10025 20041130 -.006349228 .044313 0 1.53617 .0039992216 10025 20041231 .2942573 .033422 0 1.53617 .0039992216 10025 20050131 .24526983 -.027405 0 1.53617 .0039992216 10025 20050228 .079022 .020839 0 1.53617 .0039992216 10025 20050331 -.032381408 -.018583 0 1.53617 .0039992216 10025 20050429 -.06052969 -.026569 0 1.53617 .0039992216 10025 20050531 -.07597175 .03615 0 1.53617 .0039992216 10025 20050630 .06895418 .009902 0 1.53617 .0039992216 10025 20050729 .059413 .042229 0 1.53617 .0039992216 10025 20050831 .04442957 -.007761 0 1.53617 .0039992216 10025 20050930 .07341018 .009338 0 1.53617 .0039992216 10025 20051031 -.0822381 -.021981 0 1.53617 .0039992216 10025 20051130 .12487333 .03807 0 1.53617 .0039992216 10025 20051230 .0833816 .001886 0 1.53617 .0039992216 10025 20060131 .03922071 .038935 0 1.53617 .0039992216 end
0 Response to Residual variance from the market model for multiple companies
Post a Comment