Package 'robustarima'

Title: Robust ARIMA Modeling
Description: Functions for fitting a linear regression model with ARIMA errors using a filtered tau-estimate. The methodology is described in Maronna et al (2017, ISBN:9781119214687).
Authors: Stephen Kaluzny [aut, cre], Bill Dunlap [ctb], TIBCO Software Inc. [aut, cph]
Maintainer: Stephen Kaluzny <[email protected]>
License: BSD_3_clause + file LICENSE
Version: 0.2.7
Built: 2024-11-23 06:47:03 UTC
Source: CRAN

Help Index


Robust Fit of a REGARIMA Model and Outliers Detection

Description

Returns an object of class "arima.rob" that represents a robust fit of a linear regression model with ARIMA errors using a filtered tau-estimate. The error model may have seasonal differences and one seasonal moving average parameter. It also returns the detected outliers and level shifts.

Usage

arima.rob(formula, data, contrasts=NULL, start=NULL, end=NULL,
      p=0, q=0, d=0, sd=0, freq=1, sfreq=NULL, sma=FALSE,
      max.p=NULL, auto.ar=FALSE, n.predict=20, tol=10^(-6),
      max.fcal=2000, iter=FALSE, innov.outlier=FALSE, critv=NULL, ...)

Arguments

formula

a formula object, with the response on the left of a ~ operator, and the terms, separated by + operators, on the right.

data

a data frame or a "timeSeries" object with a data frame in the data slot, which is used to interpret the variables named in formula. If this is missing, then the variables in formula should be on the search list. Missing values are not allowed.

contrasts

the same as the contrasts argument for lm function.

start

a character string which can be passed to timeDate function to specify the starting date for the estimation. This can only be used if the data argument is a "timeSeries" data frame. The default is NULL.

end

a character string which can be passed to timeDate function to specify the ending date for the estimation. This can only be used if the data argument is a "timeSeries" data frame. The default is NULL.

p

the autoregressive order of the errors model. The default is 0.

q

the moving average order of the errors model. The default is 0.

d

the number of regular differences in the ARIMA model. It must be 0, 1 or 2. The default is 0.

sd

the number of seasonal differences. It must be 0, 1 or 2. The default is 0.

freq

the frequency of data. The default is 1.

sfreq

the seasonality frequency of data. If NULL, it is set to be equal to freq. The default is NULL.

sma

logical flag: if TRUE, the errors model includes a seasonal moving average parameter. The default is FALSE.

auto.ar

logical flag: If TRUE an AR(p) model is selected automatically using a robust AIC criterion. The default is FALSE.

max.p

the maximum order of the autoregressive stationary model that approximates the ARMA stationary model. If NULL, max.p=max(p+q,5). If q=0, then max.p is not necessary. The default is NULL.

n.predict

the maximum number of future periods for which we wish to compute the predictions. The default is 20.

tol

the tolerance for convergence.

max.fcal

the maximum number of function evaluations.

iter

a logical flag or the number of iterations to execute arima.rob with.

innov.outlier

logical flag: if TRUE, the function arima.rob looks for innovation outliers in addition to additive outliers and level shifts; otherwise, arima.rob only looks for additive outliers and level shifts. The default is FALSE.

critv

the critical value for detecting outliers. If NULL, it assumes the following default values: critv=3 if the length of the time series is less than 200; critv=3.5 if it is between 200 and 500, and critv=4 if it is greater than 500.

...

extra arguments passed to or from other methods.

Value

an object of class "arima.rob" representing the fit and the outliers detected. See arima.rob.object for details of the components of the object.

Warning

When either d or sd is greater than zero, the interpretation of the intercept in the formula is different from its usual interpretation: it represents the coefficient of the lowest order power of the time trend which can be identified. For example, if d=2 and sd=0, the intercept represents the coefficient of the term t^2.

References

Bianco, A., Garcia Ben, M., Martinez, E., and Yohai, V. (1996). Robust procedures for regression models with ARIMA errors. COMPSTAT 96, Proceedings in Computational Statistics. Ed. Albert Prat, pages. 27-38. Physica-Verlag, Heidelberg.

Bianco, A., Garcia Ben, M., Martinez, E., and Yohai, V. (1997). Outlier detection in regression models with ARIMA errors using robust estimates. mimeo.

Chang, I., Tiao, G. C., and Chen, C. (1988). Estimation of time series parameters in the presence of outliers. Technometrics, 30:193-204.

Maronna, R. A., Martin, R. D., Yohai, V. J., Salibián-Barrera. M. (2017). Robust Statistics: Theory and Practice (with R), 2nd Edition, Wiley.

Martin, R. D., Samarov, A., and Vandaele, W. (1983). Robust methods for ARIMA models. in Applied Time Series Analysis of Economic Data, E. Zellner, ed.

Yohai, V. Y., and Zamar, R. H. (1988). High breakdown-point estimates of regression by means of the minimization of an efficient scale. Journal of the American Statistical Association, 83:406-413.

See Also

arima.rob.object.

Examples

frip.rr <- arima.rob(log(frip.dat) ~ 1, p=2, d=1)

Robust REGARIMA Model and Outliers Detection Objects

Description

These are objects of class "arima.rob" which represent the robust fit of a regression model with ARIMA errors. It also contains information about the detected outliers.

Arguments

The following components must be included in a legitimate "arima.rob" object:

x

the model matrix.

y

the response variable.

model

a list with the following named components: "freq" which is the frequency of the original data, "sfreq" which is the seasonal frequency of the original data, "d" which is the number of regular differences, "sd" which is the number of seasonal differences, "ar" which is the estimated AR coefficients, "ma" which is the estimated MA coefficients, "sma" which is the seasonal MA coefficient if estimated.

regcoef

the estimates of regression coefficients.

regcoef.cov

the estimated covariance matrix of the regression coefficients.

innov

the estimated innovations.

innov.acf

a series whose autocorrelations or partial autocorrelations are the robust estimates of the innovation autocorrelations or partial autocorrelations.

regresid

the estimated regression residuals cleaned of additive outliers by the robust filter.

regresid.acf

a series whose autocorrelations or partial autocorrelations are the robust estimates of the autocorrelations or partial autocorrelations of the differenced regression residuals.

sigma.innov

a robust estimate of the innovation scale.

sigma.regresid

an estimate of the scale of the differenced regression residuals.

sigma.first

the first estimate of the innovation scale based only on the scale of the differenced model and the ARMA parameters.

tuning.c

the bandwidth of the robust filter.

y.robust

the response series cleaned of outliers by the robust filter.

y.cleaned

the response series cleaned of additive outliers and level shifts after the outliers detection procedure.

predict.error

the fitted and predicted regression errors.

predict.scales

the standard deviations of the fitted and predicted regression errors.

n.predict

the number of predicted observations, which is equal to the n.predict argument passed to the arima.rob function that produced the "arima.rob" object.

tauef

the inverse of the estimated efficiency factor of the tau-estimate with respect to the LS-estimate.

inf

information about the outcome of the last optimization procedure: inf=1 indicates that the procedure converged, and inf=0 that the procedure did not converge.

innov.outlier

logical flag, the same as the innov.outlier argument passed to the arima.rob function that produced the "arima.rob" object.

outliers

an object of class "outliers", which contains all the detected outliers (and level shifts).

outliers.iter

optionally a list of objects of class "outliers", if the iter argument passed to the arima.rob function that produced the "arima.rob" object is non-zero.

n0

the number of missing innovations at the beginning.

call

an image of the call that produced the object, but with the arguments all named and with the actual formula included as the formula argument.

assign

the same as the assign component of an "lm" object.

contrasts

the same as the contrasts component of an "lm" object.

terms

the same as the terms component of an "lm" object.

rank

the same as the rank component of an "lm" object.

Generation

This class of objects is returned from the arima.rob function.

Methods

coef, formula, outliers, predict, print, summary.

See Also

arima.rob, outliers, outliers.object.


Use coef on an arima.rob Object

Description

This is a method for the function coef() for objects inheriting from class "arima.rob". See coef or coef.default for the general behavior of this function and for the interpretation of object.

Usage

## S3 method for class 'arima.rob'
coef(object, ...)

Arguments

object

an object of class "arima.rob".

...

extra arguments passed to or from other methods. The coef method here ignore these arguments.

Value

a named vector of the model coefficients.


Monthly Industrial Production of France

Description

A "timeSeries" vector containing the monthly industrial production of France from January 1960 to December 1989.

Usage

frip.dat

Format

A "timeSeries" vector


Monthly Imports and Import Taxes of Argentina

Description

The import.dat data frame has 96 rows and 2 columns. The sample runs from January 1983 to December 1990.

Usage

import.dat

Format

A data frame with 96 observations and 2 columns:

taxes

monthly import taxes of Argentina.

import

monthly imports of Argentina.


Monthly Import Taxes of Argentina

Description

The newtaxes.dat data frame has 10 rows and 1 column. The sample runs from January to October 1992.

Usage

newtaxes.dat

Format

A data frame with 10 rows and 1 column:

taxes

monthly import taxes of Argentina.


Outliers Extraction for an <code>arima.rob</code> Object

Description

Returns an object of class "outliers".

Usage

outliers(object, iter=NULL)

Arguments

object

an object of class "arima.rob".

iter

a number specifying from which iteration to extract the detected outliers, if the iter argument passed to the function arima.rob that produced object is non-zero. The default is set to NULL.

Value

an object of class "outliers". If iter is NULL, the object contains all the detected outliers (and level shifts). If iter is not NULL, the object contains the outliers (and level shifts) detected in iteration iter. See outliers.object for components of the returned object.

See Also

outliers.object, arima.rob, arima.rob.object.

Examples

frip.rr <- arima.rob(log(frip.dat) ~ 1, p=2, d=1, iter=2)
frip.outliers.all <- outliers(frip.rr)
frip.outliers.2 <- outliers(frip.rr, iter=2)

Outliers Objects Extracted from <code>arima.rob</code> Objects

Description

These are objects of class "outliers" extracted an object of class "arima.rob", which contain information about the detected outliers (and level shifts).

Arguments

The following components must be included in a legitimate "outliers" object:

nout

the number of outliers (and level shifts) detected.

outlier.index

the index of each detected outlier (or level shift).

outlier.type

the type of each detected outlier (or level shift): 1=innovation outlier, 2=additive outlier, 3=level shift.

outlier.impact

the size of each detected outlier (or level shift).

outlier.t.statistics

the t-statistics for each detected outlier (or level shift).

outlier.positions

the "timeDate" objects associated with the detected outliers if the original data is a "timeSeries" object.

sigma0

the estimate of the innovation scale before correcting the outliers.

sigma

the estimate of the innovation scale after correcting the outliers.

ierror

the error indicator: if ierror > 0 the search for outliers was stopped, the algorithm detected too many outliers.

Generation

This class of objects is returned from the outliers function.

Methods

print, summary.

See Also

outliers arima.rob, arima.rob.object.


Use predict on an arima.rob Object

Description

Predicts from a fitted "arima.rob" object.

Usage

## S3 method for class 'arima.rob'
predict(object, n.predict=1, newdata=NULL,
                  olddata=NULL, se.fit=FALSE, ...)

Arguments

object

an object of class "arima.rob".

n.predict

the number of predictions to be returned.

newdata

a data frame containing the future values of exogenous variables, if any, at which predictions are required.

olddata

a data frame containing the original data used to fit object. This is only required if tslag is used to create distributed lags of exogenous variables in the original call that generated object.

se.fit

logical flag: if TRUE, pointwise standard errors are computed along with the predictions.

...

extra arguments passed to or from other methods. The predict method here ignore these arguments.

Details

This function is a method for the generic function predict for class "arima.rob". It can be invoked by calling predict for an object of the appropriate class, or directly by calling predict.arima.rob regardless of the class of the object.

Value

a list containing the following components:

values

the predicted values.

std.err

the pointwise standard errors for the predictions (if se.fit=TRUE).

See Also

arima.rob

Examples

import.rr <- arima.rob(import ~ taxes-1, data=import.dat, p=2, d=1)
import.hat <- predict(import.rr, 5, newdata=newtaxes.dat, se=TRUE)

Use print on an arima.rob Object

Description

This is a method for the function print() for objects inheriting from class "arima.rob". See print or print.default for the general behavior of this function and for the interpretation of x.

Usage

## S3 method for class 'arima.rob'
print(x, digits = 4, ...)

Arguments

x

an object of class "arima.rob".

digits

the number of digits to display.

...

extra arguments passed to or from other methods.

Value

invisibly returns x. Typically called for the printing side effect.

See Also

print.


Use print on an outliers Object

Description

This is a method for the function print for objects inheriting from class "outliers". See print or print.default for the general behavior of this function and for the interpretation of x.

Usage

## S3 method for class 'outliers'
print(x, digits = 4, ...)

Arguments

x

an object of class "outliers".

digits

the number of digits to display.

...

extra arguments passed to or from other methods.

Value

invisibly returns x. Typically called for the printing side effect.

See Also

outliers, print.


Use print on a summary.arima.rob Object

Description

This is a method for the function print for objects inheriting from class "summary.arima.rob". See print or print.default for the general behavior of this function and for the interpretation of x.

Usage

## S3 method for class 'summary.arima.rob'
print(x, digits = 4, ...)

Arguments

x

an object of class "summary.arima.rob".

digits

the number of digits to display.

...

extra arguments passed to or from other methods.

Value

invisibly returns x. Typically called for the printing side effect.

See Also

print summary.arima.rob.


Use print on a summary.outliers Object

Description

This is a method for the function print() for objects inheriting from class "summary.outliers". See print or print.default for the general behavior of this function and for the interpretation of x.

Usage

## S3 method for class 'summary.outliers'
print(x, digits = 4, ...)

Arguments

x

an object of class "summary.outliers".

digits

the number of digits to display.

...

extra arguments passed to or from other methods.

Value

invisibly returns x. Typically called for the printing side effect.

See Also

print, summary.outliers.


Summary Method for arima.rob Objects

Description

Returns a summary list for an "arima.rob" object.

Usage

## S3 method for class 'arima.rob'
summary(object, correlation = FALSE, ...)

Arguments

object

an object of class "arima.rob".

correlation

a logical flag: if TRUE, correlation matrices of regression coefficients and ARIMA coefficients are also produced. The default is FALSE.

...

extra arguments passed to or from other methods. The summary method here ignore these arguments.

Details

This function is a method for the generic function summary for class "arima.rob". It can be invoked by calling summary for an object of the appropriate class, or directly by calling summary.arima.rob regardless of the class of the object.

Value

an object of class "summary.arima.rob" which must contain the following components:

ARIMA.model

the same list as the model component of object. See arima.rob.object for details.

reg.coef

a matrix with four columns, containing the regression coefficients, their standard errors, the t-statistics and the corresponding p-values.

regcoef.cov

the estimated covariance matrix for the regression coefficients.

regcoef.corr

the estimated correlation matrix for the regression coefficients. This is only present if corr=T.

AR.coef

a matrix with four columns, containing the AR coefficients, their standard errors, the t-statistics and the p-values.

MA.coef

a matrix with four columns, containing the MA coefficients, their standard errors, the t-statistics and the p-values.

sMA.coef

an array which contains the seasonal moving average parameter, its standard error, the t-statistic and the p-value.

ARIMA.cov

the estimated covariance matrix of the ARMA coefficients.

ARIMA.corr

the estimated correlation matrix of the ARMA coefficients. This is only present if corr=T.

n

the length of the time series.

df

the number of degrees of freedom for the model.

sigma

the estimate of the innovations scale.

call

the image of the original call to arima.rob.

outliers

an object of class "summary.outliers".

See Also

arima.rob, arima.rob.object, summary.

Examples

frip.rr <- arima.rob(log(frip.dat) ~ 1, p=2, d=1)
summary(frip.rr)

Summary Method for outliers Objects

Description

Returns an object of class "summary.outliers" containing a summary list for an "outliers" object. A null value will be returned if printing is invoked.

Usage

## S3 method for class 'outliers'
summary(object, ...)

Arguments

object

an object of class "outliers".

...

extra arguments passed to or from other methods. The summary method here ignore these arguments.

Details

This function is a method for the generic function summary for class "outliers". It can be invoked by calling summary for an object of the appropriate class, or directly by calling summary.outliers regardless of the class of the object.

Value

a list is returned with the following components:

nout

number of outliers (and level shifts) detected.

outliers.table

the index (or "timeDate" information if the argument data passed to arima.rob is of class "timeSeries"), type, impact and t value for each of the detected outlier (or level shift).

sigma0

the estimate of the innovation scale before correcting outliers.

sigma

the estimate of the innovation scale after correcting outliers.

See Also

outliers, outliers.object, summary.

Examples

frip.rr <- arima.rob(log(frip.dat) ~ 1, p=2, d=1)
frip.outliers <- outliers(frip.rr)
summary(frip.outliers)

Use <code>vcov()</code> on an <code>arima.rob</code> Model Object

Description

This is a method for the function vcov() for objects inheriting from class "arima.rob". See vcov for the general behavior of this function and for the interpretation of object.

Usage

## S3 method for class 'arima.rob'
vcov(object, nterm=1000, ...)

Arguments

object

an object inheriting from class "arima.rob".

nterm

an interger specifying the number of terms.

...

extra arguments passed to or from other methods. The method here ignore these arguments.

Value

the variance-covariance matrix of fitted arima.rob model returned from a call arima.rob.

See Also

arima.rob.object, vcov.