Univariate time series forecasting based on auto.arima

I have univariate time series data (windspeed at a particular place) measured at 1 hour interval for 5 years.

I used auto.arima() to get the following parameters:

              ar1      ar2     ma1     ma2    intercept
1.5314  -0.55   -0.1261  0.032    10.1223
s.e.    0.0105  0.0103   0.011   0.006     0.1211

sigma^2 estimated as 0.4865 : log likelihood = -83546.65
AIC = 167105.3   AICc = 167105.3    BIC = 167161


I am forecasting using the following equation:

e[t] <- rnorm(1, 0, sqrt(sigma^2))
x[t] <- ar1*x[t-1] + ar2*x[t-2] + e[t] + ma1*e[t-1] + ma2*e[t-2]


When the result is compared with forecast() function, I get completely different answers. The freq spectrum of forecast() function's output resembles original time-series freq spectrum. While the manual forecast signal looks like noise in freq spectrum.

I can't use forecast() function because the application is in C++. Are the equations correct? What's the right way of forecasting from coefficients?

-

If you type forecast.Arima you can see the source of the forecast.Arima function. This function calls the predict.Arima function, which is probably what you want to implement. You can view the source by typing stats:::predict.Arima. You will probably additionally need to look at the source of the KalmanForecast function, which is called by predict.Arima.

You can then port the source code from R to C++. You can probably remove the parts that refer to xreg and drift as you don't use them in your model.

e[t] <- rnorm(1, 0, sqrt(sigma^2)) What is the point of adding random noise to your forecast? As you have observed, it makes your forecast noisy...

-

I apologize but I am not familiar with R. But it looks like you are inputting randomly generated errors. The fitted ARIMA model will base the forecasts on the estimated errors, i.e., the residuals. Also, does your R command need the constant term (i.e., the intercept)? I don't see you using it.

-
Invertibility conditions do not involve AR coefficients. In backshift notation the model is: $(1-1.5314 B + 0.55 B^{2}) (z_{t} - \mu) = (1 + 0.1261 B - 0.032 B^{2})$. The invertibility conditions for this model are: $|\theta_{2}| <1$, $\theta_{2} - \theta_{1} <1$ , $\theta_{2} + \theta_{1}<1$, and these are satisfied. The stationarity conditions are: $|\phi_{2}| <1$, $\phi_{2} - \phi_{1} <1$ , $\phi_{2} + \phi_{1}<1$. These are also satisfied, however, $\phi_{2} + \phi_{1} = 0.9814 \approx 1$ does raise concern about stationarity, not invertibility. –  Graeme Walsh May 26 at 4:30