Learn R Programming

FRAPO (version 0.3-7)

returnconvert: Convert Returns from continuous to discrete and vice versa

Description

Either continuous returns or discrete returns can be converted into the other type.

Usage

returnconvert(y, convdir = c("cont2disc", "disc2cont"), percentage = TRUE)

Arguments

y
Objects of classes: numeric, matrix, data.frame, ts, mts, timeSeries, zoo and xts are supported.
convdir
Character, the type of return conversion.
percentage
Logical, if TRUE (the default) the returns, y, are expressed as percentages.

Value

  • An object of the same class as y, containing the converted returns.

concept

  • returns
  • discrete returns
  • continuous returns

Examples

Run this code
data(StockIndex)
yc <- diff(log(StockIndex[, "SP500"])) * 100
yd <- returnseries(StockIndex[, "SP500"], method = "discrete",
                   percentage = TRUE, trim = TRUE)
yconv <- returnconvert(yd, convdir = "disc2cont",
                       percentage = TRUE)
all.equal(yc, yconv)

Run the code above in your browser using DataLab