# Simulation of ARIMA (1,1,0) series

I have fitted the ARIMA models to the original time series, and the best model is ARIMA(1,1,0). Now I want to simulate the series from that model. I wrote the simple AR(1) model, but I couldn't understand how to adjust the difference within the model ARI(1,1,0). The following R code for AR(1) series is:

phi= -0.7048
z=rep(0,100)
e=rnorm(n=100,0,0.345)
cons=2.1
z=4.1
for (i in 2:100) z[i]=cons+phi*z[i-1]+e[i]
plot(ts(Y))


How do i include the difference term ARI(1,1) in above code. Any one help me in this regard.

If you want to simulate ARIMA you can use arima.sim in R, there is no need to do it by hand. This will generate the series you want.

e <- rnorm(100,0,0.345)
arima.sim(n=100,model=list(ar=-0.7048,order=c(1,1,0)),start.innov=4.1,n.start=1,innov=2.1+e)


You can look at the code of how this is achieved by typing arima.sim in R command line. Alternatively if you do it yourself, the function you are probably looking is diffinv. It computes the inverse of lagged differences.

For recursive sequences R has a nice function filter. So instead of using loop

z <- rep(NA,100)
z <- 4.1
for (i in 2:100) z[i]=cons+phi*z[i-1]+e[i]


you can write

filter(c(4.1,2.1+e),filter=-0.7048,method="recursive")


This will give the identical result to arima.sim example above:

diffinv(filter(c(4.1,2.1+e),filter=-0.7048,method="recursive")[-1])

• your answer is wonderful – Daniel James Mar 31 at 6:43
• is it permitted for me to ask you a question; or can you give me a private privilege to chat with you alone? – Daniel James Mar 31 at 6:51