Forecasting using ARIMAX in R

15,454

R has a built-in ARIMAX procedure called arima. To get the X part, use the xreg= argument. If you don't have exogenous variables and don't use xreg=, note that the the "Intercept" result may not indicate what you think it indicates.

So if you're using a ARIMAX(1, 2, 3)(1, 0, 0) model with dependent variable sales (monthly data), and an exogenous variable nasdaq (and you have a prediction for nasdaq of nasdaq.pred), you'd do:

model <- arima (sales, order=c(1, 2, 3), seasonal=list (order=c(1, 0, 0), freq=12),
                xreg=nasdaq)

pred <- predict (model, newxreg=nasdaq.predict)
Share:
15,454
Admin
Author by

Admin

Updated on June 25, 2022

Comments

  • Admin
    Admin almost 2 years

    I used to forecast sales of computers at a weekly level in SAS, based on broadly two parameters - Pricing and Marketing spends (vehicle level - hence several variables). This was easy in SAS as I could use PROC ARIMA.

    Could you help me to transition to R? I have imported the dataset, performed the auto.arima and analysed p - values for some variables. However I am unaware as to how to proceed with forecasting, for the next 26 weeks. Any help would be greatly appreciated!

  • Rafael Bento
    Rafael Bento about 6 years
    I think you mean TSA::arimax()