ocd {ocd} | R Documentation |
ocd: A package for high-dimensional multiscale online changepoint detection
Description
The ocd package provides the S3 class ChangepointDetector
that
processes data sequentially using the getData
function and
aims to detect change as soon as it occurs online subject to false alarm
rates.
References
Chen, Y., Wang, T. and Samworth, R. J. (2020) High-dimensional multiscale online changepoint detection Preprint. arxiv:2003.03668.
See Also
ChangepointDetector
for detailed usage.
Examples
set.seed(2020)
p <- 100
thresh <- setNames(c(11.62, 179.48, 54.87), c('diag', 'off_d', 'off_s'))
detector <- ChangepointDetector(dim=p, method='ocd', beta=1, thresh=thresh)
old_mean <- rnorm(p); new_mean <- old_mean + c(rnorm(p/4), rep(0,3*p/4)) / sqrt(p/4)
# using functional semantics native in R
detector <- setStatus(detector, 'estimating')
for (i in 1:10000){
x_new <- rnorm(p, mean=old_mean)
detector <- getData(detector, x_new)
}
print(detector)
detector <- setStatus(detector, 'monitoring')
for (i in 1:200){
x_new <- rnorm(p, old_mean * (i < 100) + new_mean * (i>=100))
detector <- getData(detector, x_new)
}
print(detector)
## Not run:
# alternative way to write the above using the piping semantics
library(magrittr)
detector %<>% reset
detector %<>% setStatus('estimating')
for (i in 1:10000){
x_new <- rnorm(p, mean=old_mean)
detector %<>% getData(x_new)
}
detector %>% print
detector %<>% setStatus('monitoring')
for (i in 1:200){
x_new <- rnorm(p, old_mean * (i < 100) + new_mean * (i>=100))
detector %<>% getData(x_new)
}
detector %>% print
## End(Not run)
[Package ocd version 1.1 Index]