xtsdiff: Normalize a time series and compute its difference to a...

Description Usage Arguments Details Value

Description

This function is typically used to calculate the efficiency of inverse funds or ETFs with respect to a benchmark such as its underlying index.

Usage

1
xtsdiff(data, k = -1, bench = NA, na.omit = TRUE)

Arguments

data

The xts time series to normalize

k

The constant (a vector) used to multiply the returns of the time series. The length of this vector must equal the number of columns in the xts matrix provided.

bench

Name of the benchmark from which to compute the differences. If NA (default), then $diff is not computed and not returned in the return list.

na.omit

Logical. Specifies whether NA rows are omitted. This effectively removes all leading rows containing NAs.

Details

An xts time series is provided. Its returns are computed and multiplied by a constant k to make it equivalent to the benchmark. A list of three quantities are retured: the returns series ($rets), a normalized equity curve ($ec), and the percentage difference between the equity curves ($diff).

If more than 2 time series are provided (more than 2 columns), all series including the benchmark are implicitly truncated to align at the start of the latest series. This is so the equity curve of the benchmark and all others start at the same time.

Value

A list containting three xts matrices: $rets contains a matrix of returns, $ec contains a matrix of equity curves, and $diff contains a matrix of differences.


jeanmarcgp/xtsanalytics documentation built on May 19, 2019, 12:38 a.m.