tsOutliers: Identification of statistical outliers in time series

View source: R/tsOutliers.R

tsOutliersR Documentation

Identification of statistical outliers in time series

Description

This function identifies statistical outliers in a ts object based on upper and lower quantile criteria. The function body is mainly taken from stats.stackexchange.com.

Usage

tsOutliers(
  x,
  lower_quantile = 0.2,
  upper_quantile = 0.8,
  plot = FALSE,
  index = FALSE,
  ...
)

Arguments

x

Numeric. A vector of observed time-series values.

lower_quantile

Numeric, default is 0.2. The lower quantile limit.

upper_quantile

Numeric, default is 0.8. The upper quantile limit.

plot

Logical, default is FALSE. If TRUE, a time-series plot including identified outliers is generated.

index

Logical, default is FALSE. If TRUE, a vector holding the indices of identified outliers is returned rather than the statistically obtained scores for each measured value.

...

Additional arguments passed to ts.

Value

A numeric vector of scores or, if index = TRUE, a vector holding the indices of identified outliers.

Author(s)

Florian Detsch

See Also

ts

Examples

# Random time-series values
set.seed(10)
x <- rnorm(100, 0, 2)

# Return indices of outliers incl. visualization
tsOutliers(x, lower_quantile = .35, upper_quantile = .7, 
           plot = TRUE, index = TRUE)


environmentalinformatics-marburg/GSODTools documentation built on Jan. 5, 2024, 12:19 a.m.