Fitting arima Models with Exogenous Variables

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Fitting arima Models with Exogenous Variables

PaulJr
Dear friends,

I have 5 exogenous variables which I´d like to incorporate into my
auto.arima model.

I was able to incorporate the xreg, and I understand that newxreg should be
the forecast of my exogenous variables, but I have not been able to get it
to work.

Newxreg should only have one column? Should newxreg have the same number of
rows of the training data?

This is the error I keep getting but I don´t quite understand:

Error in forecast.Arima(ModelAfit, h = 12, newxreg = NewXreg) :
  No regressors provided
In addition: Warning message:
In forecast.Arima(ModelAfit, h = 12, newxreg = NewXreg) :
  The non-existent newxreg arguments will be ignored.

Any help will be greatly appreciated,

Best regards,

Paul

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: [FORGED] Fitting arima Models with Exogenous Variables

Rolf Turner
On 21/01/17 02:29, Paul Bernal wrote:

> Dear friends,
>
> I have 5 exogenous variables which I´d like to incorporate into my
> auto.arima model.
>
> I was able to incorporate the xreg, and I understand that newxreg should be
> the forecast of my exogenous variables, but I have not been able to get it
> to work.
>
> Newxreg should only have one column? Should newxreg have the same number of
> rows of the training data?
>
> This is the error I keep getting but I don´t quite understand:
>
> Error in forecast.Arima(ModelAfit, h = 12, newxreg = NewXreg) :
>   No regressors provided
> In addition: Warning message:
> In forecast.Arima(ModelAfit, h = 12, newxreg = NewXreg) :
>   The non-existent newxreg arguments will be ignored.
>
> Any help will be greatly appreciated,

You need to provide a *reproducible example*.  (Including data ---
built-in data set, dput output, or simulation recipe with a seed set ---
and an indication of what *packages* you are using.)

cheers,

Rolf Turner

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

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: [FORGED] Fitting arima Models with Exogenous Variables

Rolf Turner

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,


______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: [FORGED] Fitting arima Models with Exogenous Variables

Rolf Turner

I am re-sending this since I have been told that the attachments that I
made did not get through.  So I am trying again with *.dput attachments.

You will need to read them in using dget().

cheers,

Rolf Turner

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

On 24/01/17 10:35, Rolf Turner wrote:

>
> 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
>
> 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,




______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

TrainingDat.dput (8K) Download Attachment
ExogVars.dput (12K) Download Attachment