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                                 
for (i in 2:100) z[i]=cons+phi*z[i-1]+e[i]   

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) 

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[1] <- 4.1
for (i in 2:100) z[i]=cons+phi*z[i-1]+e[i]   

you can write


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

  • $\begingroup$ your answer is wonderful $\endgroup$ – Daniel James Mar 31 at 6:43
  • $\begingroup$ is it permitted for me to ask you a question; or can you give me a private privilege to chat with you alone? $\endgroup$ – Daniel James Mar 31 at 6:51
  • $\begingroup$ please help me look at this stackoverflow.com/questions/60970948/… $\endgroup$ – Daniel James Apr 1 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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