predict arma: bug when xreg
Matthieu Stigler
matthieu.stigler at gmail.com
Thu Aug 26 17:32:14 CEST 2010
Please see:
LL<-length(lynx)
mod<-arima(lynx, order=c(1,0,1), xreg=1:LL)
predict(mod, n.ahead=5, newxreg=(LL+1):(LL+5))
library(fArma)
modFM<-armaFit(~arima(1,0,1), lynx, xreg=1:LL)
predict(modFM, n.ahead=5, newxreg=(LL+1):(LL+5))
This comes in my opinion from fact that indeed the argument newxreg is
passed explcitely and implicitely (through ...). I see that just removing
armaPredict.R
line 202
ans = predict(object = fit, n.ahead = n.ahead,
newxreg = newxreg, se.fit = se.fit, xreg = xreg, ...)
removing newxreg:
if (!exists("newxreg")) newxreg = NULL #remove
ans = predict(object = fit, n.ahead = n.ahead,
se.fit = se.fit, xreg = xreg, ...)
seems to solve the bug. I am not sure neither of the utility of having
if (!exists("xreg")) xreg = NULL ?
as it seems to be extracted from the x object in stats:::predict.Arima
Best
Matthieu
More information about the Rmetrics-core
mailing list