[R] price returns conversion

Murali Menon feanor0 at hotmail.com
Wed Aug 6 17:15:48 CEST 2008


folks,

is there a better way to convert a daily series of price returns to a monthly one than as follows:

library(xts)

a <- xts(rnorm(100) / 100, order.by = as.Date(1:100))

am <- diff(to.monthly(cumsum(a))[, 4]) # [, 4] for Close levels

the problem with this is that the entire first month of returns is lost owing to the differencing. i would have to prefix the first month's returns manually, which seems a bit ugly.

if i had the original series in levels, then there's no issue, of course, but all i have in this instance are returns series.

cheers,

murali



_________________________________________________________________

 Contest



More information about the R-help mailing list