1

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.

user3022875
  • 8,598
  • 26
  • 103
  • 167

1 Answers1

3

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.

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
  • Please see edit. I transposed my data because I have 1 day; only 4 hours of data. I still get an error about the data type of my log retruns. Do I need a k parameter if my data is already agrregated into 30 seconds buckets. I am passing in log returns spaced 30 seconds apart for 5 hours. – user3022875 Jun 12 '15 at 18:15
  • @user3022875: your edit has multiple typos and other errors (e.g. you transpose `logRet` twice). Why are you passing `dim(t(logRet))` to `spotvol`... that doesn't make sense. – Joshua Ulrich Jun 12 '15 at 18:38
  • 2
    The documentation explains `k`. It says it, along with `on`, describes the periodicity of `data` when `data` is returns. You said your data are sampled at 30-second intervals, so `on="seconds"` and `k=30`. – Joshua Ulrich Jun 12 '15 at 20:06
  • Can you see edit? I transpose my data so I have 1 row and 665 columns. I am 4h hours of log returns where I take the last tick in 30- second buckets. There are 665 total obervations. Any idea what ""Periodicity estimation requires at least 50 observations. \n Periodic component set to unity"" means? Is it possible to use spot vol on log returns broken into 30-second intervals? – user3022875 Jun 12 '15 at 21:41
  • It means you need at least 50 days of data to use that estimation method. – Joshua Ulrich Jun 12 '15 at 23:19