Solved – 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…

Similar Posts:

Rate this post

Leave a Comment