3
$\begingroup$

I have been using the forecast package in R to make forecasts based on an ARIMA model and have noticed a difference in the output of the forecast and simulate functions when calculating confidence intervals.

For example the 95% quantile calculated by the forecast function is about 0.5% higher than that based on 10000 applications of the simulate() function. Also the mean of the simulated values and the point forecasts provided by the forecast functions are slightly different.

Which one of the functions will do the job better? Or are the differences too small to worry about? (The only reason I decided to try simulate was so that a distribution could be fitted to the simulated data).

Edit 1: Example

library(forecast)

#Fit arima model to data
dm1 = arima(DAP, order = c(1,1,0), method = "ML", seasonal = list(order = c(0,1,1)))   

#Simulate 10000 times
n.mnths = 7
    n.sim = 10000
    domesticsimulator = function(i){
      simulate(dm1, nsim = n.mnths)
    }

sim.d <- sapply(1:n.sim, function(x)domesticsimulator(x))
distr.d.mat<-t(sim.d); distr.d.mat
distr.d<-data.frame(Jun = distr.d.mat[,1],Jul = distr.d.mat[,2], Aug = distr.d.mat[,3], Sep = distr.d.mat[,4], Oct = distr.d.mat[,5], Nov = distr.d.mat[,6], Dec = distr.d.mat[,7]); distr.d

#Compare to forecast
forecast(dm1)

Edit 2: Data

dput(DAP) structure(c(43032450L, 41166780L, 49992700L, 47033260L, 49152352L, 52209516L, 55810773L, 53920973L, 44213408L, 49944935L, 47059495L, 49757124L, 43815481L, 45306644L, 54147227L, 53253194L, 53030873L, 56959142L, 59614287L, 57380873L, 47671785L, 54167489L, 51782564L, 52640057L, 47977657L, 47074882L, 58838975L, 54908859L, 57323876L, 59724061L, 62396446L, 59110633L, 50600325L, 53738093L, 52766404L, 52801276L, 48886043L, 47348142L, 58286011L, 55828555L, 57145193L, 59297121L, 60838606L, 58303233L, 49949551L, 55088986L, 53852209L, 53538970L, 50022168L, 47766421L, 59244232L, 57398267L, 59285571L, 61493934L, 63457403L, 62660179L, 52310402L, 57208618L, 55047116L, 53291139L, 50245100L, 50118363L, 59213077L, 55611053L, 58047400L, 59559171L, 61401480L, 58966473L, 47680101L, 52956023L, 47658141L, 50253800L, 44825056L, 43680328L, 53534891L, 52247781L, 52951246L, 55898027L, 59468957L, 56568180L, 48235025L, 52279405L, 48584832L, 49793527L, 45501620L, 42440614L, 54424077L, 52498074L, 53842422L, 56689853L, 59142493L, 57370748L, 50304708L, 54826050L, 51420519L, 51076415L, 46305000L, 43657818L, 55649428L, 52858479L, 55982234L, 57778699L, 60310568L, 57403835L, 50982170L, 54124363L, 51660083L, 51534990L, 47080840L, 46405385L, 56200391L, 53691570L, 55749349L, 57903293L, 59688267L, 58646304L, 50134504L, 53779646L, 51844482L, 51165451L, 47814031L, 45736763L, 56564538L, 53226735L, 56557964L, 57986530L, 59306473L, 58110953L, 50761250L, 54682312L, 50538227L, 54329096L, 47941907L, 45486064L, 57729464L, 54821717L, 57145762L ), .Tsp = c(2003, 2014.33333333333, 12), class = "ts")

$\endgroup$
4
  • 2
    $\begingroup$ Please provide a reproducible example. $\endgroup$ Commented Sep 17, 2014 at 5:20
  • $\begingroup$ Hey Rob I have updated my question for you. Hope this helps. $\endgroup$
    – user135784
    Commented Sep 17, 2014 at 5:42
  • $\begingroup$ Please use dput and add the data to your question. $\endgroup$ Commented Sep 17, 2014 at 6:33
  • $\begingroup$ Hey Rob, I have now added the data as well. Cheers! $\endgroup$
    – user135784
    Commented Sep 17, 2014 at 6:51

1 Answer 1

2
$\begingroup$

I set n.sim to 100000 and got the following:

> colMeans(distr.d)
     Jun      Jul      Aug      Sep      Oct      Nov      Dec 
59203619 61179366 59454632 51541143 55539630 52401314 53576509 

> forecast(dm1, h=n.mnths)$mean
     Jun      Jul      Aug      Sep      Oct      Nov      Dec
59204206 61179995 59455479 51543002 55536766 52403951 53576033

> apply(distr.d, 2, quantile, prob=0.95)
     Jun      Jul      Aug      Sep      Oct      Nov      Dec 
60969280 63137469 61834083 54144775 58424806 55489841 56885346 

forecast(dm1, h=n.mnths, level=90)$upper[,1]
60971646 63150134 61830110 54157777 58418731 55507766 56897499

That looks pretty accurate to me. What makes you think there is a problem?

$\endgroup$
1
  • $\begingroup$ Actually sorry reason my result were so different was because I confused HI 95% with the 95 percentile rather than the upper bound of the 95% confidence interval. My mistake. Thanks for your assistance. $\endgroup$
    – user135784
    Commented Sep 17, 2014 at 12:43

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.