Fabian Stolz
Fabian Stolz

Reputation: 2095

How do I use arima for simulating concrete values?

We analyzed a data set with acf and pcf and saw the necessity to use arima. Arima was executed and delivers coefficients. Now we want use it to forecast a random value. As I get it right the prediction of forecast or predict is the expected value. However, we want to create random values normally distributed around this prediction - as it was observed in the original data. How can we handle this easy?

Thanks! best, F!

> summary(arima_res)
      Length Class  Mode     
coef        4    -none- numeric  
sigma2      1    -none- numeric  
var.coef   16    -none- numeric  
mask        4    -none- logical  
loglik      1    -none- numeric  
aic         1    -none- numeric  
arma        7    -none- numeric  
residuals 852    ts     numeric  
call        3    -none- call     
series      1    -none- character
code        1    -none- numeric  
n.cond      1    -none- numeric  
model      10    -none- list     

Upvotes: 0

Views: 251

Answers (1)

Rob Hyndman
Rob Hyndman

Reputation: 31800

Use the forecast package. Then use simulate(fit) where fit is the output from arima() or Arima(). Here is a quick example:

library(forecast)
fit <- Arima(USAccDeaths,order=c(0,1,1),seasonal=c(0,1,1))
plot(USAccDeaths,xlim=c(1973,1980),ylim=c(6000,12000))
for(i in 1:10)
  lines(simulate(fit,nsim=24),col="blue")

The means of the simulated values are equal to the point forecasts generated by forecast(fit). The percentiles of the simulated values are equal to the prediction intervals obtained in the same way. (Not exactly, because this is a simulation, but asymptotically.)

Upvotes: 1

Related Questions