PaulJr
2012-Nov-14 15:30 UTC
[R] Time Series with External Regressors in R Problems with XReg
Hello everyone, Hope you all are doing great! I have been fitting arima models and performing forecasts pretty straightforwardly in R. However, I wanted to add a couple of regressors to the arima model to see if it could improve the accuracy of the forecasts but have had a hard time trying to do so. I used the following R function: arima(x, order = c(0, 0, 0), seasonal = list(order = c(0, 0, 0), period = NA), xreg = NULL, include.mean = TRUE, transform.pars = TRUE, fixed = NULL, init = NULL, method = c("CSS-ML", "ML", "CSS"), n.cond, optim.method = "BFGS", optim.control = list(), kappa = 1e6) Now, I know that you don?t need all the parameters in the function so I basically fit the model using this sentence:> var1.fit<-arima(response$cargotonnage, order=c(3,0,0), xreg=explanatory, > include.mean=FALSE) > var1.fitNow the weird thing here is that R was actually able to fit the model, however, when I wanted to make predictions (see below):> var1.pred<-predict(var1.fit, n.ahead=12)R popped the following error: [b]Error in predict.Arima(var1.fit, n.ahead = 12) : 'xreg' and 'newxreg' have different numbers of columns>Which is weird beaucse 1. I made sure that my regressor matrix had the same amount of rows as my univariate time series and 2. R was able to fit the model I was suggesting. Has anyone done arima models including external regressors in R? Does anyone has any idea of what could be happening? Best regards, Paul -- View this message in context: http://r.789695.n4.nabble.com/Time-Series-with-External-Regressors-in-R-Problems-with-XReg-tp4649500.html Sent from the R help mailing list archive at Nabble.com.
Possibly Parallel Threads
- forecast & xreg
- predict.Arima error "'xreg' and 'newxreg' have different numbers of columns"
- storing lm() results and other objects in a list
- Using the R predict function to forecast a model fit with auto.arima function
- predict.Arima: warnings from xreg magic