find_outliers: Detect additive outliers in weekly time series

View source: R/find_outliers.R

find_outliersR Documentation

Detect additive outliers in weekly time series

Description

Detects additive outliers (AOs) using a regression-based t-statistic search procedure following Findley et al. (1998). The function operates on a detrended series, where the trend is estimated using supsmu. Optional holiday and trading-day regressors can be included. If the number of Fourier (trigonometric) terms is not supplied via my.k_l, it is selected automatically by minimizing AICc over a grid of yearly and monthly Fourier terms.

Usage

find_outliers(
  x,
  dates,
  out.tolerance = 3.8,
  my.AO.list = NULL,
  H = NULL,
  my.k_l = NULL,
  method = "additive"
)

Arguments

x

Numeric vector containing the observed weekly time series.

dates

A vector of class "Date" corresponding to the observation dates.

out.tolerance

Numeric. Absolute t-statistic threshold used for AO inclusion. Defaults to 3.8.

my.AO.list

Optional vector of class "Date" specifying pre-defined AO dates. These dates are included in the regression and excluded from the forward search.

H

Optional matrix of holiday and trading-day regressors with nrow(H) = length(x).

my.k_l

Optional numeric vector of length two specifying the number of yearly and monthly Fourier harmonics c(k, l). If NULL, my.k_l is selected automatically by AICc.

method

Character string specifying the decomposition type. Either "additive" or "multiplicative". If "multiplicative", the series is log-transformed prior to detrending. Defaults to "additive".

Value

A list with the following components:

ao

Vector of class "Date" containing detected additive outlier dates, or NULL if none are detected.

my.k_l

Numeric vector c(k, l) giving the number of yearly and monthly Fourier terms used in the regression.

References

Findley, D.F., Monsell, B.C., Bell, W.R., Otto, M.C. and Chen, B.C. (1998). New capabilities and methods of the X-12-ARIMA seasonal-adjustment program. Journal of Business and Economic Statistics, 16(2), 127–152.

Examples



#Not run:
# Searching for additive outliers in Gasoline data
data(gasoline.data)
ao_list=find_outliers(x=gasoline.data$y,dates = gasoline.data$date)


boiwsa documentation built on Dec. 14, 2025, 5:06 p.m.