data.table::setDTthreads(2)
# Usage with data.table object
dat <- sampleTData[as.Date(DT) == "2018-01-02"]
# Testing every 60 seconds after 09:45:00
DBH1 <- driftBursts(dat, testTimes = seq(35100, 57600, 60), preAverage = 2, ACLag = -1L,
meanBandwidth = 300L, varianceBandwidth = 900L)
print(DBH1)
plot(DBH1, pData = dat)
# Usage with xts object (1 column)
library("xts")
dat <- xts(sampleTData[as.Date(DT) == "2018-01-03"]$PRICE,
order.by = sampleTData[as.Date(DT) == "2018-01-03"]$DT)
# Testing every 60 seconds after 09:45:00
DBH2 <- driftBursts(dat, testTimes = seq(35100, 57600, 60), preAverage = 2, ACLag = -1L,
meanBandwidth = 300L, varianceBandwidth = 900L)
plot(DBH2, pData = dat)
if (FALSE) {
# This block takes some time
dat <- xts(sampleTDataEurope$PRICE,
order.by = sampleTDataEurope$DT)
# Testing every 60 seconds after 09:00:00
system.time({DBH4 <- driftBursts(dat, testTimes = seq(32400 + 900, 63000, 60), preAverage = 2,
ACLag = -1L, meanBandwidth = 300L, varianceBandwidth = 900L)})
system.time({DBH4 <- driftBursts(dat, testTimes = seq(32400 + 900, 63000, 60), preAverage = 2,
ACLag = -1L, meanBandwidth = 300L, varianceBandwidth = 900L,
parallelize = TRUE, nCores = 8)})
plot(DBH4, pData = dat)
# The print method for DBH objects takes an argument alpha that determines the confidence level
# of the test performed
print(DBH4, alpha = 0.99)
# Additionally, criticalValue can be passed directly
print(DBH4, criticalValue = 3)
max(abs(DBH4$tStat)) > getCriticalValues(DBH4, 0.99)$quantile
}
Run the code above in your browser using DataLab