# ACF of IMA(1,1) in R

I generate the IMA(1,1) process in R to see ACF for different values of Theta. The graphs show that ACF is always positive for both positive and negative values of Theta, is it correct or I'm wrong somewhere?

theta <- 0.9
d <- ts(matrix(0,ncol=1,nrow=100))
e <- ts(rnorm(100,0,1))
d[1] <- e[1]
for(i in 2:100)
d[i] <- d[i-1]-theta*(e[i-1]+e[i])
acf(d,10)


Theta=0.9 Theta=-0.9

-
That's correct; it's the "I" in "IMA" that makes it so. – jbowman Dec 15 '12 at 17:21

PS: After the comment I'm feeling in doubt of what I've done. Please correct me if I'm wrong.

UPD: I think this part d[i] <- d[i-1] - theta*(e[i-1] + e[i]) should be this d[i] <- d[i-1] - theta*e[i-1] + e[i] cause in ARMA only previous random parts: $\varepsilon_{i}$ - is multiplied by $\theta$'s.

UPD: With the help of jbowman I've checked the idea of positive ACF with more correct modeling.

R does have the functions to model the general ARIMA process and much more:

imap.sim <- arima.sim(model=list(order=c(0,1,1), ma=0.9), n=100) # modeling with positive theta
iman.sim <- arima.sim(model=list(order=c(0,1,1), ma=0.9), n=100) # modeling with negative theta
ts.plot(imap.sim) # plotting
ts.plot(iman.sim)
imap.acf <- acf(imap.sim, type="correlation", plot=T)
iman.acf <- acf(iman.sim, type="correlation", plot=T)


And the results:

• With positive theta:
• With negative theta:
-
I believe the correct syntax for the arima simulation is iman.sim <- arima.sim(model=list(order=c(0,1,1), ma=-0.9), n=100). I think the d=1 is ignored, and you're actually generating an MA(1) process; the first order autocorrelation of roughly (+/-) 0.5 would support this hypothesis. I agree, however, that arima.sim is the way to go. – jbowman Dec 15 '12 at 18:42