tsoutliers (version 0.6-8)

outliers.effects: 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, freq = 12)

Value

A n

\(\times\)

nrow(mo) or n

\(\times\)

length(ind) matrix containing by columns each outlier.

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.

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.

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ómez, V. and Maravall, A. (1996). Programs TRAMO and SEATS. Instructions for the user. Banco de Españ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ñ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

Run this code
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 <- c(1, -1)
p2 <- c(1, rep(0, 3), -1)
p1xp2 <- c(1, -1, 0, 0, -1, 1)
p1b <- c(1, -0.6)
p2b <- c(1, rep(0, 3), -0.6)
p2bxp2b <- c(1, -0.6, 0, 0, -0.6, 0.36)
io2 <- outliers.effects(mo, n, pars = list(arcoefs = -p1xp2[-1], 
  macoefs = p2bxp2b[-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)]))

# the temporary change with parameter 0.7 is equivalent to 
# an IO for an AR(1) model with coefficient 0.7
mo <- outliers("IO", 10)
io3 <- outliers.effects(mo, n = n, pars = list(arcoefs = c(0.7), macoefs = c(0)))
all.equal(io3, tc, check.attributes=FALSE)

# the temporary change with parameter 0.7 is equivalent to 
# an IO for an AR(1) model with coefficient 0.7
mo <- outliers("IO", 10)
io4 <- outliers.effects(mo, n = n, pars = list(arcoefs = 1, macoefs = 0))
all.equal(io4, ls, check.attributes=FALSE)

# 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")

Run the code above in your browser using DataCamp Workspace