Learn R Programming

highfrequency (version 1.0.1)

makeReturns: Compute log returns

Description

Convenience function to calculate log-returns, also used extensively internally. Accepts xts and matrix-like objects. If you use this with a data.table object, remember to not pass the DT column. $$ \mbox{log return}_t = (\log(\mbox{PRICE}_{t})-\log(\mbox{PRICE}_{t-1})). $$

Usage

makeReturns(ts)

Value

Depending on input, either a matrix or an xts object containing the log returns.

Arguments

ts

a possibly multivariate matrix-like object containing prices in levels. If ts is an xts object, we return an xts object. Other types will result in a matrix

Author

Jonathan Cornelissen, Kris Boudt, and Emil Sjoerup

Details

Note: the first (row of) observation(s) is set to zero.