# Re: Question about ARMA in new C# version of Suanshu

Home 21090308 Forums Re: Question about ARMA in new C# version of Suanshu

#2223
gawrrell
Member

Hello Johannes,

Thank you very much for the quick response, much appreciated  🙂

I am trying to use ARMA (or ARIMA) and GARCH to create a model on a log return time series.

I would like to find the optimal values of the AR & MA parameters by creating various
combinations of AR & MA and grading them via the AIC (you can think of it as a brute force
like grid search, so for example for a particular series ARMA(2,1) is the best model).

Afterwards, I would like to take the residual from the ARMA and apply it to GARCH (probably GARCH(1,1))
and get a prediction (for the variance and also the mean).

I did not see a way to get the residual series from ARMA or ARIMA – do you provide such a functionality.

In Matlab this can be done using a combined ARMA/GARCH model (I do not need to get the residuals from ARMA,
only get the optimal AR & MA coefficients), here is what I do in Matlab :

I am using the ‘arima’ function to find the best arima parameters (I use the log likelyhood as the AIC)
then I build a ‘garchset’ object :

spec = garchset(‘R’, p, ‘M’, q, ‘P’, 1, ‘Q’, 1);

where p & q – are the best AR & MA from ARIMA,
and the rest are for GARCH(1,1), and then I use
‘garchfit’ and ‘garchpred’ to fit a GARCH and get a prediction
for the variance and the mean

Could you please let me know if this be done using your library.

Also, I tried the following code
(series is a double[] containing the log return series)

When I run the code it gets stuck on the last line – arimaForecast.next(), and finally after several minutes
an exception pops us saying ‘order’ must be positive : 0′