# Re: [R] Stock Price Correlation to Index Price Levels

From: Moshe Olshansky <m_olshansky_at_yahoo.com>
Date: Wed, 13 Jun 2007 18:11:21 -0700 (PDT)

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.

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 Thu 14 Jun 2007 - 01:18:41 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 - 03:32:16 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.