Re: [R] question about xreg of arima

From: Richard Saba <>
Date: Sat, 12 Jan 2008 10:28:39 -0600


A constant term is not included in the model if any differencing is specified. The xreg= parameter is used to add other explanatory variables to the model. In your case xreg=1:length(x) adds a vector of 1's to the model. Robert Shumway and David Stoffer's website for their "Time Series Analysis an its Applications with R Examples" text has several very helpful documents posted on the site ( specific to time series analysis. The R ISSUES document address your question.  



>I am trying to understand exactly what xreg does in arima. The
documentation for xreg says:"xreg Optionally, a vector or matrix of external regressors, which must have >the same number of rows as x." What does this mean with regard to the action of xreg in arima?    

>Apparently somehow xreg made the following two arima fit equivalent in R:

>arima(x, order=c(1,1,1), xreg=1:length(x))

>is the same as

> arima(diff(x), order=c(1,0,1))

>While I understand the latter fit (I think), I am puzzled with regard to
the former. Does anyone know what the former is doing to arima, and why it works as it does?



Richard Saba Department of Economics Auburn University Auburn, AL 36849 USA [[alternative HTML version deleted]] ______________________________________________ mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code.
Received on Sat 12 Jan 2008 - 16:35:11 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 13 Jan 2008 - 15:30:05 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive