3
$\begingroup$

With the arima function I found some nice results, however now I have trouble interpreting them for use outside R. I am currently struggling with the MA terms, here is a short example:

ser=c(1, 14, 3, 9)        #Example series
mod=arima(ser,c(0,0,1))   #From {stats} library
mod

#Series: ser
#ARIMA(0,0,1) with non-zero mean
#
#Coefficients:
#          ma1  intercept
#      -0.9999     7.1000
#s.e.   0.5982     0.8762
#
#sigma^2 estimated as 7.676:  log likelihood = -10.56
#AIC = 27.11   AICc = Inf   BIC = 25.27

mod$resid

#Time Series:
#Start = 1
#End = 4
#Frequency = 1
#[1] -4.3136670  3.1436951 -1.3280435  0.6708065

predict(mod,n.ahead=5)

#$pred
#Time Series:
#Start = 5
#End = 9
#Frequency = 1
#[1] 6.500081 7.100027 7.100027 7.100027 7.100027
#
#$se
#Time Series:
#Start = 5
#End = 9
#Frequency = 1
#[1] 3.034798 3.917908 3.917908 3.917908 3.917908
?arima

When looking at the specification this formula is presented: X[t] = a[1]X[t-1] + … + a[p]X[t-p] + e[t] + b[1]e[t-1] + … + b[q]e[t-q]

Given my choice of AR and MA terms, and considering that I have included a constant this should reduce to: X[t] = e[t] + b[1]e[t-1] + constant

However this does not hold up when i compare the results from R with manual calculations: 6.500081 != 6.429261 == -0.9999 * 0.6708065 + 7.1000

Furthermore I can also not succeed in reproducing the insample errors, assuming i know the first one this should be possible: -4.3136670 * -0.9999 +7.1000 != 14 - 3.1436951 3.1436951 * -0.9999 +7.1000 != 3 + 1.3280435 -1.3280435 * -0.9999 +7.1000 != 9 - 0.6708065

I hope someone can shed some light on this matter so I will actually be able to use the nice results that I have obtained.

$\endgroup$
4
  • $\begingroup$ Crossposted from http://stackoverflow.com/questions/8617369/ma-terms-in-arima $\endgroup$ Commented Dec 27, 2011 at 0:40
  • $\begingroup$ I just tried this with a much longer series, e <- rnorm(1001); y <- e[-1] + 0.5*e[-1001] and the numbers came out fine. I also replicated your problem. I have no idea what happened with your series; I can only suspect its shortness caused some problem! Very interesting. $\endgroup$
    – jbowman
    Commented Dec 27, 2011 at 1:19
  • 1
    $\begingroup$ AN MA 1 coefficient of -.999999 indicates that you have a very questionable model. Try using the Box-Jenkins method of identification in order to form your model. If you post your data I will try and help you ( after the new year ! ) $\endgroup$
    – IrishStat
    Commented Dec 27, 2011 at 4:05
  • 1
    $\begingroup$ Thank you very much for the replies, I have tried whether it is caused by the length by substituting the first line with ser=rep(c(1, 14, 3, 9),100) but this still did not provide the desired result. Therefore I conclude it must be the awkwardness of the test model that is causing the problem as suggested by IrishStat . I will leave it open for a few days, but if there are no new insights I will accept this answer $\endgroup$ Commented Dec 27, 2011 at 9:34

1 Answer 1

2
$\begingroup$

I tried to debug predict. Predict function is calling KalmanForecast(...). The above function calling a foreign function (.Call("KalmanFore"...) ). So I stopped here. I checked the help and found this line "Finite-history prediction is used, via KalmanForecast.This is only statistically efficient if the MA part of the fit is invertible, so predict.Arima will give a warning for non-invertible MA models." (see the R help). The above case is near non-invertible case(theta= -0.9999) and this would be the reason for the discrepancy.

$\endgroup$
1
  • $\begingroup$ Yeah I suppose this must be the cause of the problem. It would be nice though if these strange results were accompanied by a warning. Either way, I am now confident enough to interpret the result I obtained by modeling an actual dataset (which is definately invertable) $\endgroup$ Commented Dec 28, 2011 at 12:30

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.