Josh Kalish wrote: >Thanks to all of the people who responded. What I >was trying to do is >to >turn my matrix or frame containing index level >returns and stock >returns >into a matrix of "betas". I don't really need to >worry about risk-free >interest rates. I just need to be able to come up >with a number that >shows >the expected index correlation.
>I was able finally to figure out how to use cor() to >get what I think >is an >R^2 value. But, I'm trying to also figure out the >ratio of >correlation. >For example, some stocks correlate very well and cor() returns a value >of >.92. But, how do you then figure out if the stock >should have a 1.5:1 >correlation? >The way I would do it by hand is to turn the closes >into daily returns >and >then get the mean() return for each stock against the >index by day. I >can't >find an example as hard as I look, but this must be >very common. If X is a vector of daily returns (today's close - yesterday's close) for your index (in dollars) and Y is the vector of daily returns for your stock (in dollars), then to hedge 1 share of your stock you need to hold u = -(1/r)*(Sy/Sx) units of the index, where r is the correlation coefficient, Sx is the standard deviation of daily returns of the index and Sy is the standard deviation of daily returns of Y. In R, u <- -(1/cor(X,Y))*(sd(Y)/sd(X)) In this case your stock is "fully" hedged by the index (but the index of course is not "fully" hedged by the stock, unless the correlation coefficient is +/- 1). Hope this helps, Moshe Olshansky. ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
