Using highfrequency::spotvol(), how to set k parameter in my aggregate?

306 views Asked by At

I would like to use the spotvol() function from the highfrequency package on 30 second log returns for 5 hours of trading. I have a 665x1 matrix of 30-second log returns i.e. diff(log(prices)

logRet<- as.matrix(diff(log(r$PRICE)))
logRet<- t(logRet)
dim(logRet)
spotvol(logRet, method = "detper", on= "secs", k = 30,  dailyvol = "medrv", periodicvol = "TML")

output:

> dim(logRet)
[1]   1 665
> spotvol(logRet, method = "detper", on= "secs", k = 30,  dailyvol = "medrv", periodicvol = "TML")
[1] "Periodicity estimation requires at least 50 observations. \n          Periodic component set to unity"
  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [79] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[157] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

any idea what this means? I have 665 observations of 30-second log returns.

1

There are 1 answers

5
Joshua Ulrich On

From ?spotvol (emphasis added):

Either an ‘xts’ object, containing price data, or a ‘matrix’ containing returns. For price data, irregularly spaced observations are allowed. They will be aggregated to the level specified by parameters ‘on’ and ‘k’. For return data, the observations are assumed to be equispaced, with the time between them specified by ‘on’ and ‘k’. Return data should be in matrix form, where each row corresponds to a day, and each column to an intraday period. The output will be in the same form as the input (‘xts’ or ‘matrix’/‘numeric’).

So spotvol thinks your input data only has one observation per day, so there's nothing to aggregate.