logReturns: Lagged log-returns

Description Usage Arguments Value Note See Also Examples

View source: R/ts.R

Description

Calculates log-returns between values with specified lag.

Usage

1
logReturns(x, lag = 1, na_padding = TRUE, base = exp(1))

Arguments

x

A numeric vector containing the values for which returns are calculated.

lag

Integer indicating which lag to use (default: 1).

na_padding

Flag whether to pad truncated values with NA's (default: TRUE).

base

A positive number giving the base with respect to which the logarithm is computed. Default is e, i.e. exp(1).

Value

Numeric vector with log-returns of specified lag.

Note

Parameter na_padding behaves slightly different from diff in order to achieve consistency with lead and lag.

See Also

diff, returns

Examples

1
2
3
logReturns(1:10)
logReturns(c(1, 2, 4, 8, 16, 32), base = 2)
logReturns(c(1, 2, 4, 8, 16, 32), base = 2, na_padding = FALSE)

sfeuerriegel/ResearchGroupTools documentation built on May 29, 2019, 8:01 p.m.