3
$\begingroup$

I have some data which i am trying to work on. I am pretty new to R though, but i love R. First, I fit an arima model to this data and used the detectIO function in R to detect a single influential outlier (IO). I then incorporated this IO into my model and then developed an arimax model, now with the IO. I first used this model:

Model2 = arimax(mydata, order=c(0,2,1),
                seasonal=list(order=c(0,0,1), period=12), io=c(48))

Then later, used the model below after seeing a similar code in a book:

Model4 = arima(mydata, order = c(0, 2, 1),
               seasonal=list(order = c(0, 0, 1), period = 12), 
               xtransf=data.frame(I48=1*(seq(mydata)==48), I48=1*(seq(mydata)==48)), 
               transfer=list(c(0,0), c(1,0)))

I then run the predict function on these two models and I keep getting this error:

> predict(Model4, n.ahead=24)

Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),  :
  attempt to set an attribute on NULL

I don't know what I am doing wrong. I don't know if I am using the right functions and codes? Does there really exist a predict function on arimax?

I would also appreciate if I get any help on how to set-up the xtransf with some real data values.

$\endgroup$
9
  • $\begingroup$ you should include your predict code in your question. if that's where the error is coming from, it'd help to be able to see your code. $\endgroup$ Apr 12, 2013 at 3:05
  • $\begingroup$ please format your code as code by selecting all code areas and pressing Ctrl+K $\endgroup$
    – grssnbchr
    Apr 12, 2013 at 9:25
  • $\begingroup$ @ClarkW.Griswold: my predict code was: predict(Model4, n.ahead=24) $\endgroup$
    – b2amen
    Apr 12, 2013 at 13:02
  • $\begingroup$ @wnstnsmth: thanks for the nice editing work. but how will i do that with the mac os? $\endgroup$
    – b2amen
    Apr 12, 2013 at 13:05
  • $\begingroup$ I didn't do the editing, someone else did, but on Mac it should be Cmd+K $\endgroup$
    – grssnbchr
    Apr 12, 2013 at 14:00

3 Answers 3

2
$\begingroup$

I don't know about arimax. Your second example, using arima, could be:

foo <- arima (mydata, order=c(0, 2, 1), seasonal=list (order=c(0, 0, 1), period=12), 
    xreg=as.numeric (seq (mydata) == 48))

predict (foo, 10, newxreg=0)

Not sure if I got it right, but hopefully that will put you on the right track.

$\endgroup$
10
  • $\begingroup$ Thanks for looking. It really helped and my predict-code is working now. I did not detect any more outlier after incorporating this model. thanks a lot. But could you explain to me a little bit more about the xreg function used and the newreg=0 function. I have been seeing the xreg function but i thought it is only used on an additive outlier. @Wayne $\endgroup$
    – b2amen
    Apr 12, 2013 at 12:51
  • $\begingroup$ @ Wayne: thanks. could you check the post just right above this. thanks $\endgroup$
    – b2amen
    Apr 12, 2013 at 13:06
  • $\begingroup$ xreg is used to specify covariates and in this case I specified an anomaly indicator, which is additive. The newxreg is used in the predict to specify new values of the variable you put into xreg -- you have to supply all variables for the prediction that you did for the original. $\endgroup$
    – Wayne
    Apr 12, 2013 at 13:24
  • $\begingroup$ @b2amen if you found the answer useful can you select the tick next to it to indicate your question is resolved? thanks. $\endgroup$ Apr 13, 2013 at 2:11
  • $\begingroup$ @PeterEllis: thanks a lot. I have done exactly that. $\endgroup$
    – b2amen
    Apr 23, 2013 at 21:05
3
$\begingroup$

There is no predict() method for arimax models. Strange but true. The author of TSA has written functions that enable you to fit a transfer model, but not use it for forecasting.

$\endgroup$
7
  • $\begingroup$ Thanks a lot Rob. Okay! But could you help me set-up an arima model then, that I could use for prediction Model2 = arima(mydata, order=c(0,2,1), seasonal=list(order=c(0,0,1), period=12)) This is a model i first used. Then i used the detectIO(Model2) function to detect an I0=48. Could you help me set up an arima model with an incorporated IO=48, that i could use for prediction or forecasting. $\endgroup$
    – b2amen
    Apr 16, 2013 at 14:46
  • $\begingroup$ @Wayne has already done that for you. $\endgroup$ Apr 16, 2013 at 23:43
  • $\begingroup$ thanks. Wayne really helped and I appreciate. I just thought you had some other ideas which might differ. Thanks anyways $\endgroup$
    – b2amen
    Apr 17, 2013 at 1:49
  • $\begingroup$ The only other suggestion I have is to use Arima and forecast from the forecast package in place of arima and predict from the stats package. $\endgroup$ Apr 17, 2013 at 1:53
  • $\begingroup$ Thanks a lot Rob. I appreciate. You are really awesome. Your data site is really helpful too. $\endgroup$
    – b2amen
    Apr 23, 2013 at 22:26
1
$\begingroup$

It appears that the "predict" function can be applied if the arimax function is given an already differenciated time series (in case of non stationary data) or as it is in case of stationary data. Basically when both the order d and D are set to 0. Hope it helps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.