Do you apply ARIMA model to new data?

2

I am using the "forecast" package from R to adjust ARIMA models to my data. In the models I use external regressors in the following way:

library("forecast")
Modelo<-arima(log(Recupera), order=c(12,1,1), xreg = Colocacion, include.mean=FALSE)

To make predictions I use the following instruction:

Pronostico<-forecast(Modelo, xreg = Colocacion_Prueba)

My problem arises when I want to apply the model to updated data:

Nuevo_Pronosostico<-forecast(object=log(Recupera_Actualizado), model=Modelo, xreg=Colocacion_Futura)

But I generate an error:

Error in stats::arima(x = x, order = order, seasonal = seasonal, xreg = xreg,  : 
  lengths of 'x' and 'xreg' do not match

I have proven that in xreg the whole history of the external regressor is included but it does not work for me.

I hope you can help me ...

    
asked by Gaspar 08.05.2018 в 01:33
source

1 answer

0

I already managed to solve the problem, in fact I had to "update" my model in a certain way. What I did was the following:

library("forecast")
Modelo<-arima(log(Recupera), order=c(12,1,1), xreg = Colocacion, include.mean=FALSE)

Once I have the model, I must update it to the latest data before making the forecast:

Modelo_Actualizado<-Arima(Log_Recuperacion_Actualizado, model=Modelo, xreg=Log_Colocacion_Actualizado)

Note that the function I applied is with a capital A (it is not the same as the one with which the model was created).

After this, I can already make a forecast with the updated model:

  Pronostico<-forecast(Modelo_Actualizado, xreg=Log_Colocacion_Pronosicada)
    
answered by 20.06.2018 / 17:21
source