Learn R Programming

tsoutliers (version 0.3)

coefs2poly: Product of the Polynomials in an ARIMA Model

Description

This function collapses the polynomials of an ARIMA model into two polynomials: the product of the autoregressive polynomials and the product of the moving average polynomials.

Usage

coefs2poly(x, morder, add = TRUE, ...)

Arguments

x
a numeric vector containing the coefficients from the fitted ARIMA model or an Arima object returned by arima.
morder
a numeric vector. The order of the fitted model as returned by arima in element arma. Ignored if x is an Arima object.
add
logical. If TRUE, the polynomial of the differencing filter (if present in the model) is multiplied byt the stationary autoregressive polynomial. Otherwise only the coefficients of the product of the stationary polynomials is returned.
...
Further arguments to be passed to other functions. Currently ignored.

Value

  • A list containing the elements: arcoefs, the coefficients of the product of the autoregressive polynomials; macoefs, the coefficients of the product of the moving average polynomials. This list is of class "ArimaPars" so that it can be recognized by outliers.tstatistics.

Details

In practice, the version coefs2poly.Arima may be more convenient since it requires passing only one argument defining the model. However, since only the coefficients of the model and the order of the model is required by this function, there is no need to pass the complete Arima object.

See Also

polynomial, Ops.polynomial.

Examples

Run this code
# ARIMA(0,1,1)(0,1,1) model
fit <- arima(log(AirPassengers), order = c(0,1,1), 
  seasonal = list(order = c(0,1,1)))
coefs <- coef(fit)

# "coefs2poly" returns the coefficients of the product of 
# the non-seasonal and the seasonal moving average polynomials
pma <- polynom::polynomial(c(1, coefs[1]))
psma <- polynom::polynomial(c(1, rep(0, 11), coefs[2]))
coef(pma * psma)[-1]
coefs2poly(coef(fit), fit$arma)$macoefs

# since the model does not contain an autoregressive part
# the product of the regular and the seasonal differencing 
# filter is returned if "add = TRUE"
coefs2poly(coef(fit), fit$arma)$arcoefs
# an empty set nothing is returned if "add = FALSE"
coefs2poly(coef(fit), fit$arma, add = FALSE)$arcoefs

# in a model with non-seasonal part and no differencing filter 
# no multiplication of polynomials are involved and 
# the output coincides with "coef"
fit <- arima(log(AirPassengers), order = c(1,0,1))
coef(fit)
coefs2poly(coef(fit), fit$arma)

Run the code above in your browser using DataLab