# How to interpret Realized Volatility and TSRV using R

I am looking at some high frequency data and I would like to know how to interpret and compare Realized volatility (RV) and Two Scale Realized Volatility (TSRV). References below. Given X is the log return of a stock

$$[X,X]_{T}^{all} = \sum\limits_{i=1}^{n} (X_{t_{i+1}} - X_{t_{i}})^2$$

Here subscript all means use all the data. In my case my data is second by second so it would be the sum of the differences of squared log returns 1 second apart.

To compute RV in R I have a function that takes prices, takes there log, then differences, squares them and sums them up:

RV<-function(prices)
{
logprices = log(as.numeric(prices))
logreturns = diff(logprices)
return(sum(logreturns^2))
}


the Two Scale Realized Volatility (TSRV) partitons the whole sample 1 to n in to K subsamples. In my case K= 300. So there will be a moving window time301-time1, time302 -time 2...and the RV for those windows will be averaged over.

$$[X,X]_{T}^{K} = \dfrac 1K\sum\limits_{i=1}^{n-K+1} (X_{t_{i+K}} - X_{t_{i}})^2$$

THEN

$$TSRV = (1- \dfrac zn)^{-1} [X,X]_{T}^{K} - \dfrac zn [X,X]_{T}^{all}$$

where z = (n-K+1)/K.

Taking the difference between $$[X,X]_{T}^{K}$$ and $$[X,X]_{T}^{all}$$ cancels the effect of microstructure noise. The factor (1-z/n)^-1 is a coefficient to adjust for finite sample bias.

In R there is a function to calculate TSRV:

myTSRV<-function (pdata, K = 300, J = 1)
{
#pdata contains prices for a stock
#K the slow time scale = 300 seconds
#J is the fast time scale = 1 second
logprices = log(as.numeric(pdata))
n = length(logprices)
nbarK = (n - K + 1)/(K)
nbarJ = (n - J + 1)/(J)
logreturns_K = logreturns_J = c()
for (k in 1:K) {
sel = seq(k, n, K)
logreturns_K = c(logreturns_K, diff(logprices[sel]))
}
for (j in 1:J) {
sel = seq(j, n, J)
logreturns_J = c(logreturns_J, diff(logprices[sel]))
}
TSRV = adj * ((1/K) * sum(logreturns_K^2) - ((nbarK/nbarJ) *  (1/J) * sum(logreturns_J^2)))
return(TSRV)
}


I took tick data for IBM for about 2 hours and calculated the RV and and TSRV with K= 300 seconds and J= 1 second for about 2 hours.

I have a few questions.

• The RV is in the range of .00002 to .00005. How do I interpret this? In the literature RV is also called integrated variance. I want the volatility so do I need to square root these number to get to .0044 to .007?
• Even if I square root them what does .0044 or .007 mean? The volatility for IBm during those 2 hours was .44% to .7%?
• Does .0044 and .007 need to be normalized to an annual or daily number somehow? Can you suggest how?
• How does one compare the RV or TSRV from different length intervals. Let's say I have an RV that is calculated using 2 hours of data. How do I compare it to and RV using 6 hours of data?

References

All of my post is from: https://lirias.kuleuven.be/bitstream/123456789/282532/1/AFI_1048.pdf

original paper for TSRV: http://wwwf.imperial.ac.uk/~pavl/AitSahalia2005.pdf

R code getAnywhere("TSRV")

• Surprised your TSRV > RV. Can you check your calculations on longer time intervals? – onlyvix.blogspot.com Jul 16 '15 at 16:07
• Hi there - Actually I meant to say the RV is in the range of .00002 to .00005. The RV is higher than the TSRV. How does one interpret this? Do they need to be normalized/standarized to daily or annual numbers because the how do you compare two RVs one that used 5 minutes of data and one that used 6 hours? – joesyc Jul 16 '15 at 16:18
• You will usually get RV > TSRV when you use higher frequency returns in your RV calculation, ie return span less than 5 minutes. For lower frequency returns, ie return span 15 minutes, I would not expect RV to be consistently larger than TSRV. – Colin T Bowers Jul 21 '15 at 7:07
• If you are happy with my response, please click the tick mark next to my answer so that the question is marked as answered. Also, feel free to upvote (the up arrow next to my answer). Cheers. – Colin T Bowers Aug 11 '15 at 0:13

1a) For TSRV constructed using high frequency returns from NYSE market open to market close on a single day, the output should be numbers on the order of magnitude of 1e-4 to 1e-5. In other words, your numbers look about right. I got these number from calculating TSRV for IBM data myself using Kevin Sheppard's MatLab code for TSRV.

1b) RV is not called integrated variance in the literature. In a continuous-time modelling framework without jumps or microstructure noise, RV is consistent for integrated variance. If you include jumps, RV incorporates the jump component and so is consistent for quadratic variation = integrated variance plus jump variance. If you include microstructure noise, RV diverges. Note, the other answerer on this question suggested that TSRV is consistent for integrated variance, but not quadratic variation. To my knowledge, this is incorrect. See my comment on that answer for more detail. (UPDATE: The other answerer was thinking of bi-power variation BPV, not TSRV. Lot's of acronyms in this field :-)

1c) If you want an estimate of the volatility of a return spanning market open to market close then take the square root of either RV, or TSRV, (calculated using high frequency data from market open to close) and that is a valid estimator.

2) The interpretation of the square root number is that it is the volatility of a return that spans the same interval as the high frequency data you used to calculate the estimator. In the standard case, that is market open to market close.

3) Let $v_{t_a,t_b}$ denote a variance estimator spanning the interval $[t_a, t_b]$. You can always scale it up or down using the square root of time (or just time if working with volatility) so that all your estimators are on a consistent scale, e.g. annualized variance. But be aware, this is just a scaling trick so everything is measured in comparable units. Your estimator still only relates to the variance of a return spanning the interval $[t_a, t_b]$. Actually interpreting your scaled variance estimator as the variance of a return spanning a longer interval, like a year, is only meaningful under very strict modelling assumptions (e.g. constant variance). Personally, I think it is cleaner to always store with your variance estimator some record of the period it spans and refer to that.

4) See question 3. You can scale your RV from two hours to be in comparable six hour units using the square root of the time (ie multiply by square root of 3). However, see the point I made above. It would be better to compare RV and TSRV estimators that both span the same interval, since if you do a comparison of the two-hour and six-hour estimators, you are implicitly disadvantaging the two-hour estimator unless true variance is constant over the six-hour interval (which it almost certainly is not if you're working with financial data).

Removed incorrect answer. Sorry. Thank you Colin T Bowers

• I think TSRV is consistent for quadratic variation (ie integrated variance plus jump component). The question of jumps for TSRV was never really answered in the original paper of Zhang, Mykland and Ait-Sahalia as the modelling framework explicitly did not include jumps. Then the realised kernels paper came out and everyone kind of forgot about TSRV. Are you sure you're not thinking of bi-power variation or tri-power quarticity in your answer above? Both these estimators are known to be consistent for integrated variance even in the presence of jumps. – Colin T Bowers Jul 21 '15 at 6:40
• Yes, Colin, my bad, I was thinking about BPV, and what I wrote was incorrect. I upvoted your answer. – onlyvix.blogspot.com Jul 21 '15 at 23:07
• Thanks, no need to apologise :-) There are so many acronyms for these things, I agree it can get a bit confusing. – Colin T Bowers Jul 22 '15 at 0:47