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?    
 A: 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...
A: 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.
A: the model that you are using may be the problem 
1.5314  -0.55   
indicates that you have a model that should be [1-B][1-phi1*B]  as 1.5314-.55 is approximately equal to 1.0 which suggests to me that your model violates the invertability requirements or rather that in conjunction with your MA coefficients does so. Simplifying the model may be necessary. Additionally due to the large sample size (nob=5*365*24) you are getting bogus estimates of the standard errors of both the ACF and the estimated parameters thus you probably should avoid any MA augmentation. Your ARIMA model should probably be augmented to reflect temperature or other meteorological/athmospheric "cause variables" rather than simply using the "REAR-WINDOW" ala ARIMA. It is important to use both the FRONT WINDOW i.e. causals and the REAR WINDOW (series history).
