HT create a new vector in data frame that takes correlation of existing vectors
Posted
by Milktrader
on Stack Overflow
See other posts from Stack Overflow
or by Milktrader
Published on 2010-03-18T01:11:33Z
Indexed on
2010/03/18
1:41 UTC
Read the original article
Hit count: 351
r
|correlation
I have a time series of two indexes, with each row representing the closing price on the same day. I'd like to go to row 30 and lookback over the last 30 'days' and calculate the pearson correlation. And then store that value in a new vector. Then, repeat the calculation for the entire time series.
It is a trivial task in Excel, so I'm convinced it can be done in R. I don't know the method to use though.
© Stack Overflow or respective owner