# Constants and ARIMA Models in R

# Constants and ARIMA Models in R

Join the DZone community and get the full member experience.

Join For Free**This post is from my new book Forecasting: principles and practice, available freely online at OTexts.com/fpp/.**

A non-seasonal ARIMA model can be written as

(1)

(2)

where is the backshift operator, and is the mean of . R uses the parametrization of equation (2).

Thus, the inclusion of a constant in a non-stationary ARIMA model is equivalent to inducing a polynomial trend of order in the forecast function. (If the constant is omitted, the forecast function includes a polynomial trend of order .) When , we have the special case that is the mean of .

### Including constants in ARIMA models using R

#### arima()

By default, the `arima()`

command in R sets when and provides an estimate of when . The parameter is called the “intercept” in the R output. It will be close to the sample mean of the time series, but usually not identical to it as the sample mean is not the maximum likelihood estimate when .

The `arima()`

command has an argument `include.mean`

which only has an effect when and is `TRUE`

by default. Setting `include.mean=FALSE`

will force .

#### Arima()

The `Arima()`

command from the forecast package provides more flexibility on the inclusion of a constant. It has an argument `include.mean`

which has identical functionality to the corresponding argument for `arima()`

. It also has an argument `include.drift`

which allows when . For , no constant is allowed as a quadratic or higher order trend is particularly dangerous when forecasting. The parameter is called the “drift” in the R output when .

There is also an argument `include.constant`

which, if `TRUE`

, will set `include.mean=TRUE`

if and `include.drift=TRUE`

when . If `include.constant=FALSE`

, both `include.mean`

and `include.drift`

will be set to `FALSE`

. If `include.constant`

is used, the values of `include.mean=TRUE`

and `include.drift=TRUE`

are ignored.

When and `include.drift=TRUE`

, the fitted model from `Arima()`

is

In this case, the R output will label as the “intercept” and as the “drift” coefficient.

#### auto.arima()

The `auto.arima()`

function automates the inclusion of a constant. By default, for or , a constant will be included if it improves the AIC value; for the constant is always omitted. If `allowdrift=FALSE`

is specified, then the constant is only allowed when .

### Eventual forecast functions

The eventual forecast function (EFF) is the limit of as a function of the forecast horizon as .

The constant has an important effect on the long-term forecasts obtained from these models.

- If and , the EFF will go to zero.
- If and , the EFF will go to a non-zero constant determined by the last few observations.
- If and , the EFF will follow a straight line with intercept and slope determined by the last few observations.
- If and , the EFF will go to the mean of the data.
- If and , the EFF will follow a straight line with slope equal to the mean of the differenced data.
- If and , the EFF will follow a quadratic trend.

### Seasonal ARIMA models

If a seasonal model is used, all of the above will hold with replaced by where is the order of seasonal differencing and is the order of non-seasonal differencing.Published at DZone with permission of Rob J Hyndman , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

## {{ parent.title || parent.header.title}}

{{ parent.tldr }}

## {{ parent.linkDescription }}

{{ parent.urlSource.name }}