Using ARIMA to Create a Model in R

I'm trying to get understand why the values for my model are different when using two different functions.

The first one is from Example 9.2 (International Visitors to Australia), using the deterministic trend model: https://www.otexts.org/fpp/9/1. The formula being used in the example is:

y_t = intercept of AR + coefficient of X * value of X at t0 + AR coefficient * value of X at t-1 (error = 0)

The second one is using the fitted function in the "forecast" library in R.

X1, ..., X5 are independent variables. Y is the dependent variable. I am running an AR1 function.

AR1 <- arima(datasource[,"Y"], order = c(1,0,0), xreg = datasource[,c("X1", "X2", "X3", "X4", "X5")]))
fitted(AR1)


Very simply put, why are the forecasted values between the two not the same? Thanks in advance.

• Could you be even more specific as to what the two models are and what methods you use to estimate each of the models? So far you do not tell us what the second model is, just that it is obtained using function fitted (applied on some unknown object). You also do not tell us how the two models were estimated: e.g. exact maximum likelihood, conditional maximum likelihood, conditional sum of squares or other techniques. – Richard Hardy May 19 '15 at 13:37
• Sorry about that. X1...X5 are independent variables Y is the dependent variable I am running an AR1 function. AR1 <- arima(datasource[,"Y"], order = c(1,0,0), xreg = datasource[,c("X1", "X2", "X3", "X4", "X5")])) fitted(AR1) Let me know if you need anything else. – Ray May 19 '15 at 13:47
• Please edit your question to include the details you have given in the comment. That will help the other people reading your post. – Richard Hardy May 19 '15 at 13:48
• I think you might have misunderstood the model in Example 9.2 of the textbook you are citing. Try reading it again carefully and check whether the formula you are giving (y_t = intercept of AR + ...) really corresponds to the one in the textbook. You may read a useful blog post by Rob J. Hyndman about ARIMAX models, too. – Richard Hardy May 19 '15 at 15:21
• I re-read it and my formula is an accurate representation of what is mentioned in the textbook. The only difference that I see is that I changed up my formula a bit to represent an AR(1) model, rather than an AR(2) model as shown in the textbook. Let me know if you see any other differences. If you do, my assumption would be that it would have to do with the value of t, which I am assuming is the value of the independent variables. – Ray May 19 '15 at 15:37