# Constants and ARIMA models in R

This post is from my new book Fore­cast­ing: prin­ci­ples and prac­tice, avail­able freely online at OTexts​.com/fpp/.

A non-​​seasonal ARIMA model can be writ­ten as

(1)

or equiv­a­lently as

(2)

where is the back­shift oper­a­tor, and is the mean of . R uses the param­e­triza­tion of equa­tion (2).

Thus, the inclu­sion of a con­stant in a non-​​stationary ARIMA model is equiv­a­lent to induc­ing a poly­no­mial trend of order in the fore­cast func­tion. (If the con­stant is omit­ted, the fore­cast func­tion includes a poly­no­mial trend of order .) When , we have the spe­cial case that is the mean of .

### Includ­ing con­stants in ARIMA mod­els using R

#### arima()

By default, the arima() com­mand in R sets when and pro­vides an esti­mate of when . The para­me­ter is called the “inter­cept” in the R out­put. It will be close to the sam­ple mean of the time series, but usu­ally not iden­ti­cal to it as the sam­ple mean is not the max­i­mum like­li­hood esti­mate when .

The arima() com­mand has an argu­ment include.mean which only has an effect when and is TRUE by default. Set­ting include.mean=FALSE will force .

#### Arima()

The Arima() com­mand from the fore­cast pack­age pro­vides more flex­i­bil­ity on the inclu­sion of a con­stant. It has an argu­ment include.mean which has iden­ti­cal func­tion­al­ity to the cor­re­spond­ing argu­ment for arima(). It also has an argu­ment include.drift which allows when . For , no con­stant is allowed as a qua­dratic or higher order trend is par­tic­u­larly dan­ger­ous when fore­cast­ing. The para­me­ter is called the “drift” in the R out­put when .

There is also an argu­ment 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 val­ues of include.mean=TRUE and include.drift=TRUE are ignored.

When and include.drift=TRUE, the fit­ted model from Arima() is

In this case, the R out­put will label as the “inter­cept” and as the “drift” coefficient.

#### auto.arima()

The auto.arima() func­tion auto­mates the inclu­sion of a con­stant. By default, for or , a con­stant will be included if it improves the AIC value; for the con­stant is always omit­ted. If allowdrift=FALSE is spec­i­fied, then the con­stant is only allowed when .

### Even­tual fore­cast functions

The even­tual fore­cast func­tion (EFF) is the limit of as a func­tion of the fore­cast hori­zon as .

The con­stant has an impor­tant effect on the long-​​term fore­casts obtained from these models.

• If and , the EFF will go to zero.
• If and , the EFF will go to a non-​​zero con­stant deter­mined by the last few observations.
• If and , the EFF will fol­low a straight line with inter­cept and slope deter­mined by the last few observations.
• If and , the EFF will go to the mean of the data.
• If and , the EFF will fol­low a straight line with slope equal to the mean of the dif­fer­enced data.
• If and , the EFF will fol­low a qua­dratic trend.

### Sea­sonal ARIMA models

If a sea­sonal model is used, all of the above will hold with replaced by where is the order of sea­sonal dif­fer­enc­ing and is the order of non-​​seasonal dif­fer­enc­ing.

### Related Posts:

• syazreen

Hi Prof,
auto.arima func­tion is great, the best model can auto­mat­i­cally be fit­ted .by hav­ing small­est error.
Hpw­ever my model required a ran­dom walk with drift model.
How to use arima() to include drift term.
arima(x,c(0,1,0)) will not give the same model as I want it to be; that is ran­dom walk with drift term is the mean.

• http://robjhyndman.com/ Rob J Hyndman

auto.arima() returns the fit­ted model.

If you need to fit it again, use
Arima(x, order=c(0,1,0), include.drift=TRUE)

• syazreen

Thanks so much!
It works exactly as what I want.

• Brian

Is it pos­si­ble the behav­ior of Arima has changed?

install.packages(“fma”)
library(fma)

mod2.

Thanks!

• http://robjhyndman.com/ Rob J Hyndman

Well spot­ted. The drift term is actu­ally redun­dant and non-​​identifiable — note the size of the stan­dard error on the drift coef­fi­cient. So it is not actu­ally fit­ting a cubic drift. I’ll fix the func­tion so it doesn’t return the parameter.

• sun­set­ter

Can auto.arima() be set to never allow non-​​zero mean, even when d=0?

• http://robjhyndman.com/ Rob J Hyndman

No. You would have to do your own mod­i­fi­ca­tion of it if you wanted to do that.

• Déb­ora Spenassato

Hi prof. Hyn­d­man,
my model using the func­tion auto. arima() is ARIMA(1,1,0) with drift (AR = 0.208 and drift =2.531). I’m hav­ing dif­fi­culty to form the equa­tion. would be deltaYt=2.531+0.208 deltaYt-​​1 + et?

Thanks,