capa.cc: Collective and point anomalies in cross-correlated...

Description Usage Arguments Value Examples

View source: R/method_capacc.R

Description

A method for detecting anomalous segments and points based on CAPA-CC by Tveten, Eckley, Fearnhead (2020).

Usage

1
2
3
4
5
6
7
8
9
capa.cc(
  x,
  Q,
  b = 1,
  b_point = 1,
  min_seg_len = 2,
  max_seg_len = 10^8,
  transform = centralise
)

Arguments

x

An n x p data matrix where each row is an observation vector.

Q

An estimate of the precision matrix. See robust_sparse_precision. Must be a sparse matrix from the Matrix package.

b

The scaling factor for the collective anomaly penalty. Defaults to 1.

b_point

The scaling factor for the point anomaly penalty. Defaults to 1.

min_seg_len

The minimum segment length. Defaults to 2.

max_seg_len

The maximum segment length. Defaults to 10^8.

transform

A function used to centre the data prior to analysis by capa.cc. This can, for example, be used to compensate for the effects of autocorrelation in the data. The default value is transform=centralise, which centrailises the data by the median. Other choices are available in the anomaly package, for example anomaly::robustscale and anomaly::ac_corrected), and a user defined function can also be specified.

Value

An S3 class of type capacc with the following components:

x

The input data matrix.

anoms

A data frame with four columns: start (start-point of the anomaly), end (end-point of an anomaly), variate (which variable is affected) and size (the estimated size of the mean component for the given variate).

Examples

1
2
3
4
5
6
library(capacc)
x <- simulate_cor()$x
Q <- robust_sparse_precision(x, adjacency_mat(banded_neighbours(2, ncol(x)), sparse = FALSE))
res <- capa.cc(x, Q, b = 1, min_seg_len = 5)
plot(res)
collective_anomalies(res)

Tveten/capacc documentation built on Sept. 29, 2021, 5:31 a.m.