Learn R Programming

dsa (version 0.74.18)

outlier: Outlier adjustment of daily time series

Description

Outlier adjust any daily time series with an algorithm similar to that used in TRAMO. This function draws heavily from the tsoutliers package by Javier L<U+00F3>pez-de-Lacalle.

Usage

outlier(
  series,
  model,
  cval = 7,
  types = c("AO", "LS", "TC"),
  maxit.oloop = 1,
  maxit.iloop = 2,
  maxit.endloop = 1000,
  holidays = NULL,
  number.fourier = 13
)

Arguments

series

Input time series

model

ARIMA model used

cval

Critical Value for outlier Detection

types

Types of Outliers included. "AO", "LS", "TC" and "IO" permitted.

maxit.oloop

Maximum iterations of the outer loop

maxit.iloop

Maximum iterations of the inner loop

maxit.endloop

Maximum iterations of the end loop.

holidays

Holiday regressors used in regARIMA

number.fourier

Number of trigonometric regressors used to model seasonality

Details

This function is used internally in dsa()

References

L<U+00F3>pez-de-Lacalle, Javier (2017). R package tsoutliers.

Examples

Run this code
# NOT RUN {
set.seed(356)
x <- arima.sim(list(order = c(1,1,0), ar = 0.7), n = 365*4)
timeseries <- ts(x, freq=365, start=c(2001,1))
shocks <- rbinom(length(timeseries), 1, 0.002) * 1.5 * timeseries
timeseries <- timeseries + shocks
modelfit <- arima(timeseries, order = c(1,1,0))
out <- outlier(timeseries, model=modelfit, cval=8)
ts.plot(timeseries, out$series_adj, col=c("red", "black"))
Names = c("Original Series", "Outlier Adjusted")
legend(2004.2, 140, Names, col=c("red", "black"), lty=1, bty="n", cex=0.75)
# }

Run the code above in your browser using DataLab