focus-methods: Methods for Detector, Statistics and Offline Result Objects

focus-methodsR Documentation

Methods for Detector, Statistics and Offline Result Objects

Description

Print, summary and plot methods for the S3 classes returned by the main functions of the package: "focus_detector" objects, created by detector_create(); "focus_statistics" objects, returned by get_statistics(); and "focus_offline" objects, returned by focus_offline().

Usage

## S3 method for class 'focus_detector'
print(x, ...)

## S3 method for class 'focus_statistics'
print(x, digits = max(3L, getOption("digits") - 3L), ...)

## S3 method for class 'focus_offline'
print(x, digits = max(3L, getOption("digits") - 3L), ...)

## S3 method for class 'focus_offline'
summary(object, ...)

## S3 method for class 'summary.focus_offline'
print(x, digits = max(3L, getOption("digits") - 3L), ...)

## S3 method for class 'focus_offline'
plot(
  x,
  type = "l",
  lty = 1,
  col = NULL,
  xlab = "Time",
  ylab = "Statistic",
  main = NULL,
  ...
)

Arguments

x, object

An object of class "focus_detector", "focus_statistics", "focus_offline" or "summary.focus_offline", as appropriate.

...

Further arguments passed to or from other methods (for plot, to matplot()).

digits

Number of significant digits used to print the statistics.

type, lty, col, xlab, ylab, main

Graphical parameters passed to matplot(). By default, one solid line is drawn per test statistic.

Details

The print methods give a compact description of the object: for a detector, its type, the number of observations processed and the number of candidate changepoints currently stored; for the statistics, the current time, changepoint estimate and test statistic(s); for an offline result, the detector type and family, the threshold(s) and the detection, if any.

The summary method for "focus_offline" objects additionally reports, for each test statistic, its maximum over time, the time at which the maximum is attained, the changepoint estimate at that time and the threshold.

The plot method for "focus_offline" objects draws the trace of the test statistic(s) over time, with the finite threshold(s) as dashed horizontal lines and, if a detection occurred, the detection time and the estimated changepoint as dotted vertical lines.

Value

The print and plot methods return x invisibly. The summary method returns an object of class "summary.focus_offline": a list with the elements type, family, shape, n, detection_time and detected_changepoint of the offline result, the number of final candidates n_candidates, and statistics, a data frame with one row per test statistic.

Examples

set.seed(123)
Y <- c(rnorm(100, mean = 0), rnorm(100, mean = 2))

# Online interface
det <- detector_create(type = "univariate")
for (y in Y[1:120]) detector_update(det, y)
det
get_statistics(det, family = "gaussian")

# Offline interface
res <- focus_offline(Y, threshold = 20, type = "univariate",
                     family = "gaussian")
res
summary(res)
plot(res)


focus documentation built on Sept. 17, 2026, 1:08 a.m.