I'm working on some analysis of herding in the FTSE 100 companies using CSAD as a measure and have come across a problem I can't seem to navigate. I want to group the return data I have calculated from getsymbols for the FTSE 100 companies based on the idiosyncratic volatility (IVOL) which I have calculated with the following code:
foreach i of varlist r* {
regress `i' marketreturn
predict temp, resid
gen l`i' = temp
drop temp
}
foreach g of varlist l* {
egen ivo`g' = sd(`g')
}
drop l*
the formula for IVOL is the SD of the residual of the regression of the individual stock return (depvar) and market return (indepvar)
this has generated a new variable (ivol (ticker symbol)) for each ticker symbol which is the IVOL value for the whole time period I'm assessing, (I'm using daily data spanning roughly 2 years) so this is an IVOL across the whole time period. I would prefer to do a monthly calculation for ivol
but could not work out how to do this.
I want to use the IVOL values to group the return variables (r (ticker symbol)) in three groups high IVOL med IVOL and low IVOL so I can run three separate regressions but as they are all individual variables I cannot use sort.
This is some example data of just three of the 100 ticker symbols both return on each and IVOL, and then market return and CSAD. market return and CSAD is irrelevant for this issue but are useful for context.
input float(rAAL_L rABF_L rADM_L ivolrAAL_L ivolrABF_L ivolrADM_L marketreturn CSAD)
-.012693928 .0028985536 .008987719 .016522266 .017822612 .013433126 .0019799867 .007097834
.005102094 -.005367514 .01031409 .016522266 .017822612 .013433126 .02037216 .00869989
-.000710697 -.01203816 -.0041762795 .016522266 .017822612 .013433126 -.0005990755 .008090226
-.009956293 -.016386602 -.003261873 .016522266 .017822612 .013433126 -.011083074 .011534536
-.007285748 -.017513841 .0004674552 .016522266 .017822612 .013433126 -.003157762 .00826433
-.011474112 .005217381 -.005140207 .016522266 .017822612 .013433126 .008188129 .008555441
-.005123835 -.0021626167 .0004697114 .016522266 .017822612 .013433126 .00056108064 .007501436
.020390896 -.0013003607 .019718375 .016522266 .017822612 .013433126 .008089009 .0088896025
-.009064644 -.01909726 -.01151019 .016522266 .017822612 .013433126 .00086224 .00933866
.01413716 .002654917 -.0013973204 .016522266 .017822612 .013433126 .005516214 .009386916
-.00471505 .022947917 -.006063407 .016522266 .017822612 .013433126 -.002376801 .008638217
.006488153 .017256258 .01032371 .016522266 .017822612 .013433126 -.005582077 .008813342
.033459596 -.01229863 .01439862 .016522266 .017822612 .013433126 .006880976 .01200508
foreach i of varlist r* {
regress `i' marketreturn
predict temp, resid
gen l`i' = temp
drop temp
}
foreach g of varlist l* {
egen ivo`g' = sd(`g')
}
drop l*
the formula for IVOL is the SD of the residual of the regression of the individual stock return (depvar) and market return (indepvar)
this has generated a new variable (ivol (ticker symbol)) for each ticker symbol which is the IVOL value for the whole time period I'm assessing, (I'm using daily data spanning roughly 2 years) so this is an IVOL across the whole time period. I would prefer to do a monthly calculation for ivol
I want to use the IVOL values to group the return variables (r (ticker symbol)) in three groups high IVOL med IVOL and low IVOL so I can run three separate regressions but as they are all individual variables I cannot use sort.
This is some example data of just three of the 100 ticker symbols both return on each and IVOL, and then market return and CSAD. market return and CSAD is irrelevant for this issue but are useful for context.
input float(rAAL_L rABF_L rADM_L ivolrAAL_L ivolrABF_L ivolrADM_L marketreturn CSAD)
-.012693928 .0028985536 .008987719 .016522266 .017822612 .013433126 .0019799867 .007097834
.005102094 -.005367514 .01031409 .016522266 .017822612 .013433126 .02037216 .00869989
-.000710697 -.01203816 -.0041762795 .016522266 .017822612 .013433126 -.0005990755 .008090226
-.009956293 -.016386602 -.003261873 .016522266 .017822612 .013433126 -.011083074 .011534536
-.007285748 -.017513841 .0004674552 .016522266 .017822612 .013433126 -.003157762 .00826433
-.011474112 .005217381 -.005140207 .016522266 .017822612 .013433126 .008188129 .008555441
-.005123835 -.0021626167 .0004697114 .016522266 .017822612 .013433126 .00056108064 .007501436
.020390896 -.0013003607 .019718375 .016522266 .017822612 .013433126 .008089009 .0088896025
-.009064644 -.01909726 -.01151019 .016522266 .017822612 .013433126 .00086224 .00933866
.01413716 .002654917 -.0013973204 .016522266 .017822612 .013433126 .005516214 .009386916
-.00471505 .022947917 -.006063407 .016522266 .017822612 .013433126 -.002376801 .008638217
.006488153 .017256258 .01032371 .016522266 .017822612 .013433126 -.005582077 .008813342
.033459596 -.01229863 .01439862 .016522266 .017822612 .013433126 .006880976 .01200508

Comment