returns: Lagged returns

Description Usage Arguments Value Note See Also Examples

View source: R/ts.R

Description

Calculates returns between values with specified lag.

Usage

1
returns(x, lag = 1, na_padding = TRUE)

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).

Value

Numeric vector with 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, logReturns

Examples

1
2
3
4
returns(1:10)
returns(c(1, 2, 4, 8, 16, 32))

returns(c(1, 2, 4, 8, 16, 32), lag = 2)

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