anomalies: Anomaly Indentification

Description Usage Arguments Value Examples

View source: R/anomalies.R

Description

Function to idendtify anomalies in time series data. Function similar to Seasonal ESD approach here : https://arxiv.org/pdf/1704.07706.pdf

Usage

1
2
3
anomalies(df, index_var = NULL, x_var = NULL, ts_frequency = 1,
  stl_args = list(s.window = "periodic"), confidence = 0.99,
  direction = "both")

Arguments

df

input data.frame

index_var

optional column name of index variable. default is NULL which uses the first column in the input data.frame

x_var

optional column name of numeric variable to analyze. efault is NULL which uses the second column in the input data.frame

ts_frequency

time series frequency. default is 1

stl_args

list of arguments to pass to stl function. s.window argument required - default is 'periodic'

confidence

anomaly threshold confidence level. higher levels increase the anomaly threshold

direction

direction of anomaly idendification. Options are 'positive', 'negative', or 'both'

Value

data.frame with input dataset, stl components and flag for anomalies

Examples

1
2
3
4
5
6
7
8
9
library(tibble)
set.seed(319)
 n <- 100
  df <- tibble(index = 1:n,
               x = as.numeric(arima.sim(model = list(0,0,0), n),
                                        rand.gen = function(x) rt(x, 4)))

anoms <- anomalies(df, "index", "x", ts_frequency = 5, 
                   confidence = 0.95, direction = "both")

chrishaarstick/madtstools documentation built on May 28, 2019, 11:04 p.m.