ROC function from TTR Package

sak

New Member
#1
I was trying to verify how well the lag-returns are calculated from ROC function in TTR package.

Following is the code that I am using:
Code:
library(quantmod)
library(TTR)

startDate = "2001-01-01"
endDate = "2013-12-01"
getSymbols("VXX",src="yahoo",return.class='xts',from=startDate, to=endDate)
Adjusted = VXX$VXX.Adjusted
head(ROC(Adjusted,n=10),n=20)
head(Adjusted,n=20)

When I print the numbers for adjusted prices from above and do an excel calculation of 10 day lagging returns, I get different numbers. The numbers are however same for 1 day lag returns.

10 day lag return from ROC function:

HTML:
1/30/2009	NA
2/2/2009	NA
2/3/2009	NA
2/4/2009	NA
2/5/2009	NA
2/6/2009	NA
2/9/2009	NA
2/10/2009	NA
2/11/2009	NA
2/12/2009	NA
2/13/2009	-0.025
2/17/2009	0.027
2/18/2009	0.085
2/19/2009	0.082
2/20/2009	0.134
2/23/2009	0.200
2/24/2009	0.084
2/25/2009	0.027
2/26/2009	0.052
2/27/2009	0.056
10 day lag return from excel:

HTML:
1/30/2009	1673.28		
2/2/2009	1668		
2/3/2009	1589.92		
2/4/2009	1595.84		
2/5/2009	1586.08		
2/6/2009	1563.2		
2/9/2009	1589.28		
2/10/2009	1673.6		
2/11/2009	1649.12		
2/12/2009	1644.16		
2/13/2009	1631.84		-0.022
2/17/2009	1713.44		0.078
2/18/2009	1731.52		0.085
2/19/2009	1732.48		0.092
2/20/2009	1813.12		0.160
2/23/2009	1910.08		0.202
2/24/2009	1729.28		0.033
2/25/2009	1719.2		0.042
2/26/2009	1736.32		0.056
2/27/2009	1738.72		0.065
So, why do the numbers do not match. If I increase the number of decimal places displayed, the difference is more perceptible.

Or am I doing something wrong?

Thanks guys