<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>hi,</div>
<div> </div>
<div>How can I calculate the correlation on a subset of ie 10d Correl </div>
<div> </div>
<div>
<div>library(quantmod)<br/>
indexes<-c("SPY","MDY")<br/>
sym=getSymbols(indexes,from="2012-01-01",to=Sys.Date())<br/>
ret.SPY=ROC(SPY[,6],type="discrete",n=1)<br/>
ret.MDY=ROC(MDY[,6],type="discrete",n=1)</div>
<div>now the part which is missing</div>
<div>something like this </div>
<div>Pseudo Code</div>
<div>Correlation(ret.SPY,lag(ret.MDY,1),10)</div>
<div> </div>
<div>thanks for sharing your knowledge</div>
<div> </div>
<div> </div>
</div></div></body></html>