[R] [FORGED] Fitting arima Models with Exogenous Variables

Rolf Turner r.turner at auckland.ac.nz
Mon Jan 23 22:35:46 CET 2017


This should have been sent to the R-help mailing list, not to me 
personally.  I am not an expert on this sort of time series modelling
and cannot thereby provide any useful advice.  My reply to you was of a 
"generic" nature --- when making an enquiry, provide a reproducible 
example!!!

I am cc-ing this email to the R-help list, since someone on that list 
*may* be able to answer your question.  I have (re-) attached the data 
sets that you sent to me.

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

On 24/01/17 04:36, Paul Bernal wrote:
> Hello Rolf,
>
> Thank you for your kind reply. I am attaching two datasets, one with the
> historical data that I used to train the model, and the other one with
> the exogenous variables.
>
> The R code that I used is as follows:
>
>>library(forecast)
>>library(tseries)
>>library(TSA)
>>library(stats)
>>library(stats4)
>> TrainingDat<-read.csv("Training Data.csv")
>>
>> ExogVars<-read.csv("ExogenousVariables5.csv")
>> #The file ExogVars contains 5 columns, one column for each regressor
>> Model1<-auto.arima(TrainingDat[,5], xreg=ExogVars)
>>#In Model1 I was able to incorporate xreg without any trouble
>>#The problem comes when trying to incorporate newxreg
>> Model2<-auto.arima(ExoVars[1:5])
> Error in as.ts(x) : object 'ExoVars' not found
>>
>> Model2<-auto.arima(ExogVars[1:5])
>
> Error in auto.arima(ExogVars[1:5]) : No suitable ARIMA model found
>>
>> Model2<-auto.arima(ExogVars[,1])
>>
>> NewXReg<-forecast(Model2, h=12)
>>
>> Forec<-forecast(Model1, newxreg=NewXReg)
> Error in forecast.Arima(Model1, newxreg = NewXReg) :
>   No regressors provided
> In addition: Warning message:
> In forecast.Arima(Model1, newxreg = NewXReg) :
>   The non-existent newxreg arguments will be ignored.
>>
>> Forec<-forecast(Model1, newxreg=NewXReg$mean)
> Error in forecast.Arima(Model1, newxreg = NewXReg$mean) :
>   No regressors provided
> In addition: Warning message:
> In forecast.Arima(Model1, newxreg = NewXReg$mean) :
>   The non-existent newxreg arguments will be ignored.
>
> I would like to generate the forecasts for all 4 variables included in
> the Training set, along with all 5 regressors, but it seems like I can
> only chose one training variable at a time, and one regressor at a time.
>
> Please let me know if you can work this out,




More information about the R-help mailing list