[R-sig-finance] using yahoo and other data to calculate CAPM and FF betas

Andrew West jgalt70 at yahoo.com
Thu Apr 6 15:59:26 CEST 2006


Thanks to some help from others on the list last year
I was able to improve a function for calculating CAPM
beta coefficients and Fama-French calculations, using
data gathered from the internet.

I have begun working on a more challenging calculation
of Fama-French betas, using a panel data set. After a
couple of days, I now have a roughly working function
allowing one to give a list of stocks (should be
within same industry) to estimate coefficients using
mixed-effects models and compare this to least-squares
modelling. The problem right now is that the function
is not very smart, and I haven't been able to figure
out how to prevent the function from crashing when one
of the companies in the list has a late start or
missing data. Aligning multiple time series into a
panel data dataframe is tough for non-programmers like
me! 

The first function is getrffBeta, requiring a number
of packages. It's activated by typing something like:
getrffBeta("GE", 60) 
[this indicates you want to analyse GE, using a
rolling 60 month window.]

The second, rougher function is getpanelBeta. It's
activated by typing something like:
getpanelbeta(c("BNI","CSX","NSC","UNP"),"2000-01-01")
[the list of stocks and the starting date of your
analysis]
I hope this proves to be of use to someone, and would
welcome any feedback and/or improvements regarding
this code. 

Because YahooMail destroys the code formatting, I'm
attaching the functions as 2 text (r) files.

Regards,
Andrew West


__________________________________________________


-------------- next part --------------
A non-text attachment was scrubbed...
Name: getrffBeta.r
Type: application/octet-stream
Size: 4864 bytes
Desc: pat753074949
Url : https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20060406/3ffc5687/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getpanelbeta.r
Type: application/octet-stream
Size: 2014 bytes
Desc: pat628913167
Url : https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20060406/3ffc5687/attachment-0001.obj 


More information about the R-sig-finance mailing list