makeIndex: Convert a return series into a cumulative wealth index...

Description Usage Arguments Value Examples

View source: R/makeIndex.R

Description

This function is a flexible function that converts xts objects into cumulative wealth indices. It alllows the user to pass raw price or return series and also can handle FX data where inversion of the series is necessary before computing cumulative wealth. There is also a flag for controlling the removal of NA's in the data. Note that the default behavior for the function is to omit the first return datum. The function returns and xts object of the same length that was passed. This means that the first return is lost due to starting at 100 at the first date. To make full use of ALL of the return data, the return object would have to be expanded by -1 date value. This behavior is not supported.

Usage

1
makeIndex(x, inv = FALSE, ret = TRUE, na.rm = TRUE)

Arguments

x

and xts object containing either raw price or return data.

inv

a flag that tells the function whether to invert the series before computing returns. Useful for FX data.

ret

a flag indicating whether return or price data has been passed to the function. Default is TRUE.

na.rm

a flag indicating whether NAs should be removed from the data before computing returns. Default is TRUE.

Value

an xts object starting at 100 and evolving as the arithmetic returns of x.

Examples

1
2
3
4
dts <- seq(Sys.Date()-4, Sys.Date(), 1)
returns <- matrix(rnorm(5),ncol = 1) / 100
ret.xts <- xts(returns, dts)
makeIndex(ret.xts)

gtog/dMisc documentation built on May 17, 2019, 8:57 a.m.