Skip to content

CRAN Task View: Anomaly Detection with R πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›οΈπŸ›’πŸ›’

Notifications You must be signed in to change notification settings

pridiltal/ctv-AnomalyDetection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

87 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CRAN Task View: Anomaly Detection with R

Maintainer: Priyanga Dilini Talagala, Rob J. Hyndman
Contact: pritalagala at gmail.com
Version: 2025-03-15
Citation: Priyanga Dilini Talagala, Rob J. Hyndman (2025). CRAN Task View: Anomaly Detection with R. Version 2025-03-15.

This CRAN Task View provides a comprehensive list of R packages for anomaly detection. Anomaly detection problems have many different facets, and detection techniques are influenced by factors such as how anomalies are defined, the type of input data, and the expected output. These variations lead to diverse problem formulations, requiring different analytical approaches. This Task View aims to help users navigate the available tools by organizing them based on their applicability to different data types and detection methodologies.

Anomalies are often referred to by alternative names such as outliers, novelties, odd values, extreme values, faults, and aberrations, depending on the application domain. This Task View considers all these variations and categorizes relevant R packages accordingly. The overview covers methods applicable to univariate, multivariate, spatial, temporal, and functional data, ensuring users can find suitable tools for various analytical needs.

Packages included in this Task View are selected based on methodological robustness, active maintenance, and clear documentation. R packages that do not primarily focus on anomaly detection but offer substantial functionalities for anomaly detection have been included. However, packages where anomaly detection is only a minor feature with very limited functions have been excluded. Additionally, tools that are outdated, redundant, or lack sufficient support have not been considered.

To facilitate navigation, the Task View is structured into well-defined sections, including Univariate Outlier Detection, Multivariate Detection (further categorized into density-based, distance-based, clustering-based, angle-based, and decision tree-based methods), Temporal Data, Spatial and Spatio-Temporal Data, Functional Data, and other specialized approaches.

Please note that this Task View is in its early stages and will be updated periodically. Contributions, suggestions, and recommendations for additional packages or refinements are welcome. Contact the Task View maintainer for further details or to propose enhancements.

Univariate Outlier Detection

  • Univariate outlier detection methods focus on values in a single feature space. Package univOutl includes various methods for detecting univariate outliers, e.g. the Hidiroglou-Berthelot method. Methods to deal with skewed distribution are also included in this package.
  • The dixonTest package provides Dixon's ratio test for outlier detection in small and normally distributed samples.
  • The hotspots package supports univariate outlier detection by identifying values that are disproportionately high based on both the deviance of any given value from a statistical distribution and its similarity to other values.
  • The outliers package provides a collection of tests commonly used for identifying outliers . For most functions the input is a numeric vector. If argument is a data frame, then outlier is calculated for each column by sapply. The same behavior is applied by apply when the matrix is given.
  • The extremevalues package offers outlier detection and plot functions for univariate data. In this work a value in the data is an outlier when it is unlikely to be drawn from the estimated distribution.
  • The funModeling package provides tools for outlier detection using top/bottom X%, Tukey’s boxplot definition and Hampel’s method.
  • The alphaOutlier package provides Alpha-Outlier regions (as proposed by Davies and Gather (1993)) for well-known probability distributions.

Multivariate Outlier Detection

  • Under multivariate, high-dimensional or multidimensional scenario, where the focus is on n (>2) - dimensional space, all attributes might be of same type or might be a mixture of different types such as categorical or numerical, which has a direct impact on the implementation and scope of the algorithm. The problems of anomaly detection in high-dimensional data are threefold, involving detection of: (a) global anomalies, (b) local anomalies and (c) micro clusters or clusters of anomalies. Global anomalies are very different from the dense area with respect to their attributes. In contrast, a local anomaly is only an anomaly when it is distinct from, and compared with, its local neighbourhood. Micro clusters or clusters of anomalies may cause masking problems.

Multivariate Outlier Detection: Density-based outlier detection

  • Local Outlier Factor (LOF) is an algorithm for detecting anomalous data points by measuring the local deviation of a given data point with respect to its neighbours. This algorithm with some variations is supported by many packages. The DescTools package provides functions for outlier detection using LOF and Tukey’s boxplot definition. Functions LOF() and GLOSH in package dbscan provide density based anomaly detection methods using a kd-tree to speed up kNN search. Parallel implementation of LOF which uses multiple CPUs to significantly speed up the LOF computation for large datasets is available in Rlof package. Package bigutilsr provides utility functions for outlier detection in large-scale data. It includes LOF and outlier detection method based on departure from histogram.
  • The SMLoutliers package provides an implementation of the Local Correlation Integral method (Lof: Identifying density-based local outliers) for outlier detection in multivariate data which consists of numeric values.
  • The ldbod package provides flexible functions for computing local density-based outlier scores. It allows for subsampling of input data or a user specified reference data set to compute outlier scores against, so both unsupervised and semi-supervised outlier detection can be done.
  • The kernlab package provides kernel-based machine learning methods including one-class Support Vector Machines for novelty detection.
  • The amelie package implements anomaly detection as binary classification for multivariate
  • The estimated density ratio function in densratio package can be used in many applications such as anomaly detection, change-point detection, covariate shift adaptation.
  • The lookout package detects outliers using leave-one-out kernel density estimates and extreme value theory. The bandwidth for kernel density estimates is computed using persistent homology, a technique in topological data analysis. It also has the capability to explore the birth and the cessation of outliers with changing bandwidth and significance levels via persisting_outliers().
  • The Weighted BACON (blocked adaptive computationally-efficient outlier nominators) algorithms in wbacon implement a weighted variant of the BACON algorithms for multivariate outlier detection and robust linear regression. The methods assume that the typical data follows an elliptically contoured distribution.

Multivariate Outlier Detection: Distance-based outlier detection

  • The HDoutliers package provides an implementation of an algorithm for univariate and multivariate outlier detection that can handle data with a mixed categorical and continuous variables and outlier masking problem.
  • The stray package implements an algorithm for detecting anomalies in high-dimensional data that addresses the limitations of 'HDoutliers' algorithm. An approach based on extreme value theory is used for the anomalous threshold calculation.
  • The Routliers package provides robust methods to detect univariate (Median Absolute Deviation method) and multivariate outliers (Mahalanobis-Minimum Covariance Determinant method).
  • The modi package implements Mahalanobis distance or depth-based algorithms for multivariate outlier detection in the presence of missing values (incomplete survey data).
  • The CerioliOutlierDetection package implements the iterated RMCD method of Cerioli (2010) for multivariate outlier detection via robust Mahalanobis distances.
  • The rrcovHD package performs outlier identification using robust multivariate methods based on robust mahalanobis distances and principal component analysis.
  • The mvoutlier package also provides various robust methods based multivariate outlier detection capabilities. This includes a Mahalanobis type method with an adaptive outlier cutoff value, a method incorporating local neighborhood and a method for compositional data.
  • Function dm.mahalanobis in DJL package implements Mahalanobis distance measure for outlier detection. In addition to the basic distance measure, boxplots are provided with potential outlier(s) to give an insight into the early stage of data cleansing task.

Multivariate Outlier Detection: Clustering-based outlier detection

  • The kmodR package presents a unified approach for simultaneously clustering and discovering outliers in high dimensional data. Their approach is formalized as a generalization of the k-MEANS problem.
  • The DMwR2 package uses hierarchical clustering to obtain a ranking of outlierness for a set of cases. The ranking is obtained on the basis of the path each case follows within the merging steps of a agglomerative hierarchical clustering method.

Multivariate Outlier Detection: Angle-based outlier detection

  • The abodOutlier package performs angle-based outlier detection on high dimensional data. A complete, a randomized and a knn based methods are available.

Multivariate Outlier Detection: Decision tree based approaches

  • Explainable outlier detection method through decision tree conditioning is facilitated by outliertree package .
  • The bagged.outliertrees package provides an explainable unsupervised outlier detection method based on an ensemble implementation of the existing OutlierTree procedure in outliertree package. The implementation takes advantage of bootstrap aggregating (bagging) to improve robustness by reducing the possible masking effect and subsequent high variance (similarly to Isolation Forest), hence the name "Bagged OutlierTrees".
  • The isotree package provides fast and multi-threaded implementation of Extended Isolation Forest, Fair-Cut Forest, SCiForest (a.k.a. Split-Criterion iForest), and regular Isolation Forest, for isolation-based outlier detection, clustered outlier detection, distance or similarity approximation, and imputation of missing values based on random or guided decision tree splitting. It also supports categorical data.
  • The outForest package provides a random forest based implementation for multivariate outlier detection. In this method each numeric variable is regressed onto all other variables by a random forest. If the scaled absolute difference between observed value and out-of-bag prediction of the corresponding random forest is suspiciously large, then a value is considered an outlier.
  • The solitude package provides an implementation of Isolation forest which detects anomalies in cross-sectional tabular data purely based on the concept of isolation without employing any distance or density measures.

Multivariate Outlier Detection: Other approaches

  • The abnormality package measures a Subject's Abnormality with Respect to a Reference Population. A methodology is introduced to address this bias to accurately measure overall abnormality in high dimensional spaces. It can be applied to datasets in which the number of observations is less than the number of features/variables, and it can be abstracted to practically any number of domains or dimensions.
  • The ICSOutlier package performs multivariate outlier detection using invariant coordinates and offers different methods to choose the appropriate components. The current implementation targets data sets with only a small percentage of outliers but future extensions are under preparation.
  • The sGMRFmix package provides an anomaly detection method for multivariate noisy sensor data using sparse Gaussian Markov random field mixtures. It can compute variable-wise anomaly scores.
  • Artificial neural networks for anomaly detection is implemented in ANN2 package.
  • The probout package estimates unsupervised outlier probabilities for multivariate numeric
  • The mrfDepth package provides tools to compute depth measures and implementations of related tasks such as outlier detection, data exploration and classification of multivariate, regression and functional data.
  • The evtclass package provides two classifiers for open set recognition and novelty detection based on extreme value theory.
  • Cellwise outliers are entries in the data matrix which are substantially higher or lower than what could be expected based on the other cells in its column as well as the other cells in its row, taking the relations between the columns into account. Package cellWise provides tools for detecting cellwise outliers and robust methods to analyze data which may contain them.
  • The Projection Congruent Subset (PCS) is a method for finding multivariate outliers by searching for a subset which minimizes a criterion. PCS is supported by FastPCS package.
  • The outlierensembles package provides ensemble functions for outlier/anomaly detection. In addition to some exiting ensemble methods for outlier detcetion, it also provides an Item Response Theory based ensemble method.

Temporal Data

  • The problems of anomaly detection for temporal data are 3-fold: (a) the detection of contextual anomalies (point anomalies) within a given series; (b) the detection of anomalous subsequences within a given series; and (c) the detection of anomalous series within a collection of series
  • The trendsegmentR package performs the detection of point anomalies and linear trend changes for univariate time series by implementing the bottom-up unbalanced wavelet transformation.
  • The anomaly package implements Collective And Point Anomaly (CAPA), Multi-Variate Collective And Point Anomaly (MVCAPA), Proportion Adaptive Segment Selection (PASS) and Bayesian Abnormal Region Detector (BARD) methods for the detection of anomalies in time series data.
  • The anomalize package enables a "tidy" workflow for detecting anomalies in data. The main functions are time_decompose(), anomalize(), and time_recompose().
  • The detectAO and detectIO functions in TSA package support detecting additive outlier and innovative outlier in time series data.
  • The washeR package performs time series outlier detection using non parametric test. An input can be a data frame (grouped time series: phenomenon+date+group+values) or a vector (single time series)
  • The tsoutliers package implements the Chen-Liu approach for detection of time series outliers such as innovational outliers, additive outliers, level shifts, temporary changes and seasonal level shifts.
  • The seasonal package provides easy-to-use interface to X-13-ARIMA-SEATS, the seasonal adjustment software by the US Census Bureau. It offers full access to almost all options and outputs of X-13, including outlier detection.
  • The npphen package implements basic and high-level functions for detection of anomalies in vector data (numerical series/ time series) and raster data (satellite derived products). Processing of very large raster files is supported.
  • the ACA package offers an interactive function for the detection of abrupt change-points or aberrations in point series.
  • The oddstream package implements an algorithm for early detection of anomalous series within a large collection of streaming time series data. The model uses time series features as inputs, and a density-based comparison to detect any significant changes in the distribution of the features.
  • The pasadr package provides a novel stealthy-attack detection mechanism that monitors time series of sensor measurements in real time for structural changes in the process behavior. It has the capability of detecting both significant deviations in the process behavior and subtle attack-indicating changes, significantly raising the bar for strategic adversaries who may attempt to maintain their malicious manipulation within the noise level.

Spatial Outliers

  • Spatial objects whose non-spatial attribute values are markedly different from those of their spatial neighbors are known as Spatial outliers or abnormal spatial patterns.
  • Enhanced False Discovery Rate (EFDR) is a tool to detect anomalies in an image. Package EFDR implements wavelet-based Enhanced FDR for detecting signals from complete or incomplete spatially aggregated data. The package also provides elementary tools to interpolate spatially irregular data onto a grid of the required size.
  • The function spatial.outlier in depth.plot package helps to identify multivariate spatial outlier within a p-variate data cloud or if any p-variate observation is an outlier with respect to a p-variate data cloud.

Spatio-Temporal Data

  • The CoordinateCleaner package provides functions for flagging of common spatial and temporal outliers (errors) in biological and paleontological collection data, for the use in conservation, ecology and paleontology.

Functional Data

  • The foutliers() function from rainbow package provides functional outlier detection methods. Bagplots and boxplots for functional data can also be used to identify outliers, which have either the lowest depth (distance from the centre) or the lowest density, respectively.
  • The adamethods package provides a collection of several algorithms to obtain archetypoids with small and large databases and with both classical multivariate data and functional data (univariate and multivariate). Some of these algorithms also allow to detect anomalies.
  • The shape.fd.outliers function in ddalpha package detects functional outliers of first three orders, based on the order extended integrated depth for functional data.
  • The fda.usc package provides tools for outlier detection in functional data (atypical curves detection) using different approaches such as likelihood ratio test, depth measures, quantiles of the bootstrap samples.
  • The fdasrvf package supports outlier detection in functional data using the square-root velocity framework which allows for elastic analysis of functional data through phase and amplitude separation.
  • The fdaoutlier package provides a collection of functions for outlier detection in functional data analysis. Methods implemented include directional outlyingness, MS-plot, total variation depth, and sequential transformations among others.

Visualization of Anomalies

  • The OutliersO3 package provides tools to aid in the display and understanding of patterns of multivariate outliers. It uses the results of identifying outliers for every possible combination of dataset variables to provide insight into why particular cases are outliers.
  • The Morpho package provides a collection of tools for Geometric Morphometrics and mesh processing. Apart from the core functions it provides a graphical interface to find outliers and/or to switch mislabeled landmarks.
  • The StatDA package provides visualization tools to locate outliers in environmental data.

Pre-processing Methods for Anomaly Detection

  • The dobin package provides dimension reduction technique for outlier detection using neighbours, constructs a set of basis vectors for outlier detection. It brings outliers to the fore-front using fewer basis vectors.

Specific Application Fields

Epidemiology

  • The ABPS package provides an implementation of the Abnormal Blood Profile Score (ABPS, part of the Athlete Biological Passport program of the World Anti-Doping Agency), which combines several blood parameters into a single score in order to detect blood doping. The package also contains functions to calculate other scores used in anti-doping programs, such as the OFF-score
  • The surveillance package implements statistical methods for aberration detection in time series of counts, proportions and categorical data, as well as for the modeling of continuous-time point processes of epidemic phenomena. The package also contains several real-world data sets, the ability to simulate outbreak data, and to visualize the results of the monitoring in a temporal, spatial or spatio-temporal fashion.
  • The outbreaker2 package supports Bayesian reconstruction of disease outbreaks using epidemiological and genetic information. It is applicable to various densely sampled epidemics, and improves previous approaches by detecting unobserved and imported cases, as well as allowing multiple introductions of the pathogen.
  • The outbreaks package provides empirical or simulated disease outbreak data, either as RData or as text files.

Other

  • The precintcon package contains functions to analyze the precipitation intensity, concentration and anomaly.
  • The survBootOutliers package provides concordance based bootstrap methods for outlier detection in survival analysis.
  • The pcadapt package provides methods to detect genetic markers involved in biological adaptation using statistical tools based on Principal Component Analysis.
  • The NMAoutlier package implements the forward search algorithm for the detection of outlying studies (studies with extreme results) in network meta-analysis.
  • The boutliers package provides methods for outlier detection and influence diagnostics for meta-analysis based on Bootstrap distributions of the influence statistics.
  • The MALDIrppa package provides methods for quality control and robust pre-processing and analysis of MALDI mass spectrometry data.
  • The qpcR package implements methods for kinetic outlier detection (KOD) in real-time polymerase chain reaction (qPCR).
  • The referenceIntervals package provides a collection of tools including outlier detcetion to allow the medical professional to calculate appropriate reference ranges (intervals) with confidence intervals around the limits for diagnostic purposes.
  • The Hampel filter is a robust outlier detector using Median Absolute Deviation (MAD). The seismicRoll package provides fast rolling functions for seismology including outlier detection with a rolling Hampel Filter.
  • The spikes package provides tool to detect election fraud from irregularities in vote-share distributions using re-sampled kernel density method.
  • The wql package stands for `water quality' provides functions including anomaly detection to assist in the processing and exploration of data from environmental monitoring programs.
  • The Grubbs‐Beck test is recommended by the federal guidelines for detection of low outliers in flood flow frequency computation in the United States. The MGBT computes the multiple Grubbs-Beck low-outlier test on positively distributed data and utilities for non-interpretive U.S. Geological Survey annual peak-stream flow data processing.
  • The envoutliers package provides three semi-parametric methods for detection of outliers in environmental data based on kernel regression and subsequent analysis of smoothing residuals
  • The extremeIndex computes an index measuring the amount of information brought by forecasts for extreme events, subject to calibration. This index is originally designed for weather or climate forecasts, but it may be used in other forecasting contexts.

Data Sets

  • The anomaly package contains lightcurve time series data from the Kepler telescope.
  • The waterData package imports U.S. Geological Survey (USGS) daily hydrologic data from USGS web services and provides functions to calculate and plot anomalies.

Miscellaneous

  • The CircOutlier package enables detection of outliers in circular-circular regression models, modifying its and estimating of models parameters.
  • The Residual Congruent Subset (RCS) is a method for finding outliers in the regression setting. RCS is supported by FastRCS package.
  • The oclust package provides a function to detect and trim outliers in Gaussian mixture model based clustering using methods described in Clark and McNicholas (2019).
  • The SeleMix package provides functions for detection of outliers and influential errors using a latent variable model. A mixture model (Gaussian contamination model) based on response(s) y and a depended set of covariates is fit to the data to quantify the impact of errors to the estimates.
  • The compositions package provides functions to detect various types of outliers in compositional datasets.
  • The kuiper.2samp package performs the two-sample Kuiper test to assess the anomaly of continuous, one-dimensional probability distributions.
  • The enpls.od() function in enpls package performs outlier detection with ensemble partial least squares.
  • The faoutlier package provides tools for detecting and summarize influential cases that can affect exploratory and confirmatory factor analysis models and structural equation models.
  • The crseEventStudy package provides a robust and powerful test of abnormal stock returns in long-horizon event studies

CRAN packages

Core: HDoutliers, OutliersO3.
Regular: abnormality, abodOutlier, ABPS, ACA, adamethods, alphaOutlier, amelie, ANN2, anomalize, anomaly, bagged.outliertrees, bigutilsr, boutliers, cellWise, CerioliOutlierDetection, CircOutlier, compositions, CoordinateCleaner, crseEventStudy, dbscan, ddalpha, densratio, depth.plot, DescTools, dixonTest, DJL, DMwR2, dobin, EFDR, enpls, envoutliers, evtclass, extremeIndex, extremevalues, faoutlier, FastPCS, FastRCS, fda.usc, fdaoutlier, fdasrvf, funModeling, hotspots, ICSOutlier, isotree, kernlab, kmodR, kuiper.2samp, ldbod, lookout, MALDIrppa, MGBT, modi, Morpho, mrfDepth, mvoutlier, NMAoutlier, npphen, oclust, oddstream, outbreaker2, outbreaks, outForest, outlierensembles, outliers, outliertree, pasadr, pcadapt, precintcon, probout, qpcR, rainbow, referenceIntervals, Rlof, Routliers, rrcovHD, seasonal, seismicRoll, SeleMix, sGMRFmix, SMLoutliers, solitude, spikes, StatDA, stray, survBootOutliers, surveillance, trendsegmentR, TSA, tsoutliers, univOutl, washeR, waterData, wbacon, wql.

Related links

About

CRAN Task View: Anomaly Detection with R πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›’πŸ›οΈπŸ›’πŸ›’

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages