Learn R Programming

highfrequency (version 1.0.1)

rTPQuar: Realized tri-power quarticity

Description

Calculate the rTPQuar, defined in Andersen et al. (2012).

Assume there are \(N\) equispaced returns \(r_{t,i}\) in period \(t\), \(i=1, \ldots,N\). Then, the rTPQuar is given by $$ \mbox{rTPQuar}_{t}=N\frac{N}{N-2} \left(\frac{\Gamma \left(0.5\right)}{ 2^{2/3}\Gamma \left(7/6\right)} \right)^{3} \sum_{i=3}^{N} \mbox({|r_{t,i}|}^{4/3} {|r_{t,i-1}|}^{4/3} {|r_{t,i-2}|}^{4/3}) $$

Usage

rTPQuar(rData, alignBy = NULL, alignPeriod = NULL, makeReturns = FALSE)

Value

  • In case the input is an xts object with data from one day, a numeric of the same length as the number of assets.

  • If the input data spans multiple days and is in xts format, an xts will be returned.

  • If the input data is a data.table object, the function returns a data.table with the same column names as the input data, containing the date and the realized measures.

Arguments

rData

an xts or data.table object containing returns or prices, possibly for multiple assets over multiple days.

alignBy

character, indicating the time scale in which alignPeriod is expressed. Possible values are: "secs", "seconds", "mins", "minutes", "hours".

alignPeriod

positive numeric, indicating the number of periods to aggregate over. For example, to aggregate based on a 5-minute frequency, set alignPeriod = 5 and alignBy = "minutes".

makeReturns

boolean, should be TRUE when rData contains prices instead of returns. FALSE by default.

Author

Giang Nguyen, Jonathan Cornelissen, Kris Boudt, and Emil Sjoerup.

References

Andersen, T. G., Dobrev, D., and Schaumburg, E. (2012). Jump-robust volatility estimation using nearest neighbor truncation. Journal of Econometrics, 169, 75-93.

Examples

Run this code
tpq <- rTPQuar(rData = sampleTData[, list(DT, PRICE)], alignBy = "minutes",
              alignPeriod = 5, makeReturns = TRUE)
tpq

Run the code above in your browser using DataLab