Last data update: 2014.03.03

R: Create the Pattern of Different Types of Outliers
outliers.effectsR Documentation

Create the Pattern of Different Types of Outliers

Description

These functions create a unit or weighted impulse for the five types of outliers considered in the package.

Usage

outliers.effects(mo, n, weights = FALSE, delta = 0.7, 
  pars = NULL, n.start = 50, freq = 12)

Arguments

mo

a data frame defining the type, location and weight of the outliers to be created.

n

a numeric. The length of the variable that will contain the outlier.

weights

logical. If TRUE, the outliers are weighted by the values in column "coefhat" of the data frame mo. Otherwise, unit weights are considered.

delta

a numeric. Parameter of the temporary change type of outlier.

pars

a list containing the parameters of the time series model fitted to the data. Only for innovational outlier. See the details section in locate.outliers.

n.start

a numeric. The number of warming observations added to the input passed to the Kalman filter. Only for innovational outlier and pars of class "stsmSS".

freq

a numeric. The periodicity of the data. Only for seasonal level shift.

Details

These functions delineate the effect of each type of outlier on the observed data. See the example below for a representation of the outliers.

The function outliers.effects operates directly on the output returned by time. The remaining functions are called by outliers.effects and can be used as a simpler interface to define some outliers. They generate the type of outliers indicated by their names.

The column names of the data frame mo must follow the same convention as the output returned by locate.outliers: the column containing the observation at which the outlier sparks is named "ind"; the column containing the weights is named "coefhat" and the type of outlier is specified in a column named "type". The column "ind" should contain the index time point, not the time point in terms of year and season as given by time.

Value

A n \times nrow(mo) or n \times length(ind) matrix containing by columns each outlier.

References

Chen, C. and Liu, Lon-Mu (1993). ‘Joint Estimation of Model Parameters and Outlier Effects in Time Series’. Journal of the American Statistical Association, 88(421), pp. 284-297.

G<c3><83><c2><b3>mez, V. and Maravall, A. (1996). Programs TRAMO and SEATS. Instructions for the user. Banco de Espa<c3><83><c2><b1>a, Servicio de Estudios. Working paper number 9628. http://www.bde.es/f/webbde/SES/Secciones/Publicaciones/PublicacionesSeriadas/DocumentosTrabajo/96/Fich/dt9628e.pdf

Kaiser, R., and Maravall, A. (1999). Seasonal Outliers in Time Series. Banco de Espa<c3><83><c2><b1>a, Servicio de Estudios. Working paper number 9915. http://www.bde.es/f/webbde/SES/Secciones/Publicaciones/PublicacionesSeriadas/DocumentosTrabajo/99/Fic/dt9915e.pdf

See Also

locate.outliers, remove.outliers, tso.

Examples

n <- 30
# innovative outlier based on ARMA(3, 2) model
mo <- outliers("IO", 10)
io <- outliers.effects(mo, n, pars = list(arcoefs = c(0.8, -0.6, 0.2), 
  macoefs = c(-0.5, 0.2)))
plot(c(io[seq.int(10)], rep(NA, 20)), type = "s", ylim = range(io), 
  ylab = "io", main = "IO based on ARMA(3,2)")
lines(c(rep(NA, 9), io[-seq.int(9)]))

# innovative outlier based on Airlines model ARIMA(0,1,1)(0,1,1)
p1 <- polynom::polynomial(c(1, -1))
p2 <- polynom::polynomial(c(1, rep(0, 3), -1))
p1b <- polynom::polynomial(c(1, -0.6))
p2b <- polynom::polynomial(c(1, rep(0, 3), -0.6))
io2 <- outliers.effects(mo, n, pars = list(arcoefs = -coef(p1 * p2)[-1], 
  macoefs = coef(p1b * p2b)[-1]))
plot(c(io2[seq.int(10)], rep(NA, 20)), type = "s", ylim = range(io2), 
  main = "IO based on ARIMA(0,1,1)(0,1,1)", ylab = "io2")
lines(c(rep(NA, 9), io2[-seq.int(9)]))

# additive outlier
mo <- outliers("AO", 10)
ao <- outliers.effects(mo, n)
plot(ao, type = "h", main = "AO: additive outlier")

# level shift
mo <- outliers("LS", 10)
ls <- outliers.effects(mo, n)
plot(ls, type = "s", main = "LS: level shift")

# temporary change
mo <- outliers("TC", 10)
tc <- outliers.effects(mo, n)
plot(c(tc[seq.int(10)], rep(NA, 20)), type = "s", 
  main = "TC: temporary change", ylab = "tc")
lines(c(rep(NA, 9), tc[-seq.int(9)]))

# seasonal level shift (quarterly data)
mo <- outliers("SLS", 10)
sls <- outliers.effects(mo, n, freq = 4)
plot(sls, type = "h", main = "SLS: seasonal level shift")

Results