[prev in list] [next in list] [prev in thread] [next in thread]
List: r-sig-finance
Subject: Re: [R-SIG-Finance] xts Correl on subset
From: Michael Weylandt <michael.weylandt () gmail ! com>
Date: 2013-10-29 12:12:50
Message-ID: A4657535-5A25-49B5-A3A7-39BAF0D49A04 () gmail ! com
[Download RAW message or body]
Something like:
cor(tail(merge(ret.SPY, lag(ret.MDY)), 10))
would work.
Merge your series into a single object, take the last ten obs (tail(x, 10)) and get \
the correlation matrix thereof.
MW
On Oct 29, 2013, at 7:49, "Martin Bauer" <Bauermartin@gmx.at> wrote:
> hi,
>
> How can I calculate the correlation on a subset of ie 10d Correl
>
> library(quantmod)
> indexes<-c("SPY","MDY")
> sym=getSymbols(indexes,from="2012-01-01",to=Sys.Date())
> ret.SPY=ROC(SPY[,6],type="discrete",n=1)
> ret.MDY=ROC(MDY[,6],type="discrete",n=1)
> now the part which is missing
> something like this
> Pseudo Code
> Correlation(ret.SPY,lag(ret.MDY,1),10)
>
> thanks for sharing your knowledge
>
>
> _______________________________________________
> R-SIG-Finance@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
[[alternative HTML version deleted]]
_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic