anomalousACM (version 0.1.0)

anomaly: Anomalous time-series detection

Description

anomaly is a function for detecting unusual (i.e., anomalous, abnormal, outlier) time-series in a set of time-series.

Usage

anomaly(x, n = 10, method = c("hdr", "ahull"), robust = TRUE, ordered = FALSE,
  plot = TRUE, labels = TRUE, col)

Arguments

x

A feature matrix returned by `tsmeasures` function

n

Number of unusual time-series to return

method

Bivariate outlier detection method used for detecting high density regions of the first two principal components extracted from the time-series

robust

If TRUE a robust PCA will be used for feature extraction

ordered

If TRUE, the outliers are returned in order. This only applies when method="ahull" as the outliers are always ordered when method="hdr".

plot

If TRUE, a visualization of the anomalous time-series in the first two principal compoents will be shown

labels

If TRUE, labels will be added to give the anomlous time series an ordering index.

col

A vector of length 2 giving the colours for the first and second set of points respectively (and the corresponding axes). If a single colour is specified it will be used for both sets. If missing the default colour is used.

Value

A vector showing the row index of the n most unusual time-series and a matrix of principal component scores. Returned invisibly if plot=TRUE.

Details

When method = "hdr", the outliers are those with the lowest density in the 2-dimensional PC space using a bivariate kernel density estimator. In this case, the outliers are always in order of increasing density.

When method = "ahull", the outliers are the first n scores in the 2-dimensional PC space which break away as singletons when alpha-convex hulls are used with decreasing alpha. They are not ordered by default. If ordered=TRUE, then the outliers are ordered based on when they first break away from the remaining points. This is much slower, especially for large n, and so it is turned off by default.

See Also

ahull, hdr.2d,

Examples

Run this code
# NOT RUN {
  y <- tsmeasures(dat0, window = 24)
  anomaly(y, n = 2, method = "ahull", ordered=TRUE) 
# }

Run the code above in your browser using DataCamp Workspace