Solved – Use ARIMA equation outside R

I'm using R together with the forecast package to set up a ARIMA model, that will be used to predict a energy related variable. I used auto.arima() to fit different models (according to geographic region), and I need to put the model coefficients in our database, so that the IT folks can automate things. That's exactly the problem: I simply don't know how set up the equations by looking at the model:

ARIMA(1,0,1)(2,0,1)[12] with non-zero mean   Coefficients:         ar1     ma1    sar1    sar2     sma1   intercept    prec0    prec1      0.3561  0.3290  0.6857  0.2855  -0.7079  11333.240   15.5291  28.0817  s.e. 0.2079  0.1845  0.2764  0.2251   0.3887   2211.302    6.2147   6.0906 

I have 2 regressor variables (prec0 and prec1). Given the residuals, the ARIMA vector ARIMA(1,0,1)(2,0,1)[12], the time series up to period $t$, the number $h$ of forecasting periods and the regressor matrix reg, how can I set a function to return the forecast values? I.e:

do.forecast = function(residuals, ARIMA, timeSeries, h, regMatrix) {   p = ARIMA[1]   q = ARIMA[3]    ## arima equations here... } 

Thanks!

PS: I know this is a possible duplicate of Reproducing ARIMA model outside R, but my model seems very different, and I really don't know how to start with.

You don’t need to write a forecast function. It has been already written in the “forecast” package. First save the fitted object, then use forecast function. Here is an example:

> library(forecast) > fit <- Arima(WWWusage,order=c(3,1,0)) > forecast(fit,h=20)    Point Forecast    Lo 80    Hi 80     Lo 95    Hi 95 101       219.6608 215.7393 223.5823 213.66339 225.6582 102       219.2299 209.9265 228.5332 205.00164 233.4581 103       218.2766 203.8380 232.7151 196.19471 240.3585 104       217.3484 198.3212 236.3756 188.24885 246.4479 105       216.7633 193.2807 240.2458 180.84976 252.6768 106       216.3785 188.3324 244.4246 173.48575 259.2713 107       216.0062 183.3651 248.6473 166.08598 265.9264 108       215.6326 178.5027 252.7624 158.84738 272.4178 109       215.3175 173.8431 256.7919 151.88792 278.7471 110       215.0749 169.3780 260.7719 145.18743 284.9625 111       214.8767 165.0662 264.6873 138.69805 291.0554 112       214.7015 160.8934 268.5097 132.40907 296.9940 113       214.5483 156.8653 272.2312 126.32982 302.7667 114       214.4201 152.9828 275.8573 120.45992 308.3803 115       214.3142 149.2367 279.3917 114.78670 313.8417 116       214.2248 145.6158 282.8337 109.29641 319.1531 117       214.1482 142.1126 286.1837 103.97933 324.3171 118       214.0831 138.7215 289.4446  98.82752 329.3386 119       214.0282 135.4363 292.6202  93.83221 334.2243 120       213.9821 132.2502 295.7140  88.98400 338.9802 

Similar Posts:

Rate this post

Leave a Comment