Description Usage Arguments Value Author(s) References Examples
Function returns the rTPVar, defined in Andersen et al. (2012).
Assume there is N equispaced returns in period t. Let r_{t,i} be a return (with i=1, …,N) in period t.
Then, the rTPVar is given by
\mbox{rTPVar}_{t}=\frac{N}{N-2} ≤ft( 2^{1/3} \frac{Γ ≤ft(5/6\right)}{ Γ ≤ft(1/2\right)} \right)^{-3} ∑_{i=3}^{N} \mbox({|r_{t,i}|}^{2/3} {|r_{t,i-1}|}^{2/3} {|r_{t,i-2}|}^{2/3})
1 | rTPVar (rdata, align.by=NULL, align.period=NULL, makeReturns=FALSE,...)
|
rdata |
a zoo/xts object containing all returns in period t for one asset. |
align.by |
a string, align the tick data to "seconds"|"minutes"|"hours" |
align.period |
an integer, align the tick data to this many [seconds|minutes|hours]. |
makeReturns |
boolean, should be TRUE when rdata contains prices instead of returns. FALSE by default. |
... |
additional arguments. |
numeric
Giang Nguyen, Jonathan Cornelissen and Kris Boudt
Andersen, T. G., D. Dobrev, and E. Schaumburg (2012). Jump-robust volatility estimation using nearest neighbor truncation. Journal of Econometrics, 169(1), 75- 93.
1 2 3 | data(sample_tdata)
rTPVar(rdata= sample_tdata$PRICE, align.by= "minutes", align.period =5, makeReturns= TRUE)
rTPVar
|
Loading required package: xts
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
[1] 2.773664e-09
function (rdata, align.by = NULL, align.period = NULL, makeReturns = FALSE,
...)
{
if (hasArg(data)) {
rdata = data
}
multixts = .multixts(rdata)
if (multixts) {
result = apply.daily(rdata, rTPVar, align.by, align.period,
makeReturns)
return(result)
}
if (!multixts) {
if ((!is.null(align.by)) && (!is.null(align.period))) {
rdata = .aggregatets(rdata, on = align.by, k = align.period)
}
if (makeReturns) {
rdata = makeReturns(rdata)
}
q = as.numeric(rdata)
q = abs(rollapply(q, width = 3, FUN = prod, align = "left"))
N = length(q) + 2
rTPVar = N/(N - 2) * gamma(1/2)^2/(4 * gamma(7/6)^2) *
sum(q^(4/3))
return(rTPVar)
}
}
<environment: namespace:highfrequency>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.