[R] Stock Price Correlation to Index Price Levels

From: Kalish, Josh <josh.kalish_at_credit-suisse.com>
Date: Tue, 12 Jun 2007 18:27:50 +0100


This is probably trivial to most people out there, but I'm struggling with this.

I have a data set which contains the closing prices (properly adjusted for dividends and splits) for several hundred securities and the closing prices for a general stock market index (S&P 500). I have no problem getting it into R with RODBC and manipulating it. There are no missing values. I can easily turn the closing price series into a daily return series.

I'm trying to determine for each of the securities it's correlation to the index both in terms of an overall "beta" and the variance associated with the name. For example a security might happen to average out to looking like it tracks the index, but the variance may be so high that it is not reliable. I need to figure out how to score these names against the index.

I've looked at the cor() and cov() functions, but I couldn't figure out exactly how to use them to get this information.

I can put this data into excel and cover up with the mean of daily return for each name divided by the index return. I can also come up with the variance of this, which is a good start. I'd much rather do this in R, and I'm sure it's much more suited for this. Also, there may be a better approach to this and I would be interested in any suggestions.

To give you a practical example, at the end of the day I may have long and short positions in twenty names in a trading account. If there is a net exposure to the index then I can hedge it with index futures. But, if there's low correlation, then I can't.


Josh Kalish

Please access the attached hyperlink for an important electr...{{dropped}}

R-help_at_stat.math.ethz.ch 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. Received on Tue 12 Jun 2007 - 17:33:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 14 Jun 2007 - 02:32:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.