| focus_offline | R Documentation |
Processes all data at once and returns detection results and trajectories. This is the most efficient way to run changepoint detection when all data is available upfront.
focus_offline(
Y,
threshold,
type = "univariate",
family = "gaussian",
theta0 = NULL,
dim_indexes = NULL,
quantiles = NULL,
pruning_mult = 2L,
pruning_offset = 1L,
side = "right",
shape = NULL,
anomaly_intensity = NULL,
rho = NULL,
mu0_arp = NULL
)
Y |
Numeric vector or matrix. Data array. For univariate detection, a numeric vector. For multivariate detection, a matrix with observations in rows and dimensions in columns. |
threshold |
Numeric scalar or vector. Detection threshold(s). Can be:
|
type |
Character string specifying detector type. See
|
family |
Character string specifying distribution family. See
|
theta0 |
Numeric vector. Null hypothesis parameter. Default is |
dim_indexes |
List of integer vectors. Projection index sets for
multivariate detectors. Default is |
quantiles |
Numeric vector. Quantiles for nonparametric detectors.
Default is |
pruning_mult |
Integer. Pruning multiplier parameter. Default is 2. |
pruning_offset |
Integer. Pruning offset parameter. Default is 1. |
side |
Character string. For one-sided detectors: |
shape |
Numeric scalar. Shape parameter for gamma distribution.
Default is |
anomaly_intensity |
Numeric scalar. Anomaly intensity threshold for
pruning candidates. Only candidates with sufficient signal magnitude are
retained. Default is |
rho |
Numeric vector. AR coefficients for AutoRegressive Process (ARP)
detectors. Required when |
mu0_arp |
Numeric scalar. Pre-change mean for ARP detectors (optional).
Only used when |
This function runs the complete detection algorithm in C++ for maximum efficiency. It processes observations sequentially and stops at the first detection (when any statistic exceeds its threshold).
When more than one statistic is computed (e.g., the sum and maximum
statistics of "npfocus"), a detection occurs when any statistic
exceeds its threshold.
An object of class "focus_offline", with print,
summary and plot methods (see focus-methods):
a list with components
stat |
Numeric matrix. Test statistics over time (n_obs × n_stats). Each row corresponds to one time point, each column to one statistic. |
changepoint |
Integer vector. Detected changepoints at each time point (1-based indices), or NA if no changepoint detected at that time. |
detection_time |
Integer or NULL. Time of first detection (1-based), or NULL if no detection occurred. |
detected_changepoint |
Integer or NULL. Changepoint location at detection time (1-based), or NULL if no detection occurred. |
candidates |
Data frame. Final candidate segments (see
|
threshold |
Numeric vector. Threshold(s) used for detection. |
n |
Integer. Number of observations processed. |
type |
Character. Detector type used. |
family |
Character. Distribution family used. |
shape |
Numeric or NULL. Shape parameter (for gamma family). |
# Univariate Gaussian detection
set.seed(123)
Y <- c(rnorm(100, mean = 0), rnorm(100, mean = 2))
result <- focus_offline(Y, threshold = 10, type = "univariate",
family = "gaussian")
result
summary(result)
# Plot the trace of the statistic, the threshold and the detection
plot(result)
# Poisson detection
Y_poisson <- c(rpois(100, lambda = 2), rpois(100, lambda = 5))
result_poisson <- focus_offline(Y_poisson, threshold = 10,
type = "univariate",
family = "poisson")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.