Description Usage Arguments Details Value Note References See Also Examples

These functions implement the inner and outer loops based of the procedure to locate outliers following the approach described in Chen and Liu (1993) .

1 2 3 4 5 6 | ```
locate.outliers.oloop(y, fit, types = c("AO", "LS", "TC"),
cval = NULL, maxit.iloop = 4, maxit.oloop = 4,
delta = 0.7, n.start = 50, logfile = NULL)
locate.outliers.iloop(resid, pars, cval = 3.5,
types = c("AO", "LS", "TC"), maxit = 4, delta = 0.7, n.start = 50,
logfile = NULL)
``` |

`y` |
a time series. |

`fit` |
an |

.

`resid` |
a time series. Residuals from a time series model fitted to the data. |

`pars` |
a list containing the parameters of the model fitted to the data.
See details in |

`cval` |
a numeric. The critical value to determine the significance of each type of outlier. |

`types` |
a character vector indicating the type of outlier to be considered by the
detection procedure among the following:
innovational outliers ( |

`maxit` |
a numeric. The maximum number of iterations in the inner loop. |

`maxit.iloop` |
a numeric. Same as argument as |

`maxit.oloop` |
a numeric. The maximum number of iterations in the outer loop. |

`delta` |
a numeric. Parameter of the temporary change type of outlier. |

`n.start` |
a numeric. The number of warming observations added to the
input passed to the Kalman filter. Used only if |

`logfile` |
a character or |

See also the details section in `locate.outliers`

.

The function `locate.outliers.iloop`

iterates around the function
`locate.outliers`

until no additional outliers are found or the maximum number
of iterations is reached.
After each iteration, the effect of the outliers on the residuals of the fitted model
is removed and the *t*-statistics are obtained again for the modified residuals.
No model selection or refit of the model is conducted within this loop.

The function `locate.outliers.oloop`

is the outer loop of the procedure to locate
outliers. It iterates around the function `locate.outliers.iloop`

.
At the end of each iteration the detected outliers are removed from the original
data. Then, the time series model is fitted (or selected) again for the adjusted series
and a new search for outliers is executed. The outer loop stops when no additional outliers
are detected.

In function `locate.outliers.oloop`

,
if no value is specified for argument `cval`

a default value based on the sample size
is used. Let *n* be the number of observations. If *n ≤ 50* then `cval`

is set
equal to *3.0*; If *n ≥ 450* then `cval`

is set equal to *4.0*;
otherwise `cval`

is set equal to *3 + 0.0025 * (n - 50)*.

`locate.outliers.iloop`

returns a data frame defining by rows each
detected outlier. The data frame follows the same format as the output from
`locate.outliers`

.

`locate.outliers.oloop`

returns a list containing the following elements:
`fit`

: information from the last fitted model that will be required by
other functions in the automatic procedure (parameter estimates, residuals and
number of observations);
`outliers`

: a data frame defining by rows the detected outliers;
`iter`

: the number of iterations employed by the outer loop.

In `locate.outliers.iloop`

the default critical value, `cval`

, is set equal to *3.5* and,
hence, it is not based on the sample size.
`locate.outliers.oloop`

uses a default critical value based on the
sampel size as in `tso`

.

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

G<c3><b3>mez, V. and Taguas, D. (1995).
*Detecci<c3><b3>n y Correcci<c3><b3>n Autom<c3><a1>tica de Outliers con TRAMO:
Una Aplicaci<c3><b3>n al IPC de Bienes Industriales no Energ<c3><a9>ticos*.
Ministerio de Econom<c3><ad>a y Hacienda. Document number D-95006.
http://www.sepg.pap.minhap.gob.es/sitios/sepg/es-ES/Presupuestos/Documentacion/Documents/DOCUMENTOS%20DE%20TRABAJO/D95006.pdf

L<c3><b3>pez-de-Lacalle, J. (2014).
‘Structural Time Series Models’. **R** package version 1.2.
https://CRAN.R-project.org/package=stsm

Kaiser, R., and Maravall, A. (1999).
*Seasonal Outliers in Time Series*.
Banco de Espa<c3><b1>a, Servicio de Estudios. Working paper number 9915.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
# additional outliers may be detected in the inner or outlier loops
# in this case, the inner does not find further potential outliers
# and stops in the first iteration, while the outer loop detects
# a new outlier
data("hicp")
y <- log(hicp[["011600"]])
fit <- arima(y, order = c(1, 1, 0), seasonal = list(order = c(2, 0, 2)))
resid <- residuals(fit)
pars <- coefs2poly(fit)
otypes <- c("AO", "LS", "TC")
mo0 <- locate.outliers(resid, pars, types = otypes)
mo0
mo1 <- locate.outliers.iloop(resid, pars, types = otypes)
mo1
mo2 <- locate.outliers.oloop(y, fit, types = otypes)
mo2$iter
mo2$outliers
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.