# 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")