# How are the values of residuals (white noise) calculated in ARMA model?

I am trying to implement ARMA model in Java. I have trouble with calculating residuals (white noise) in Moving average part of the model. From the answer on this question (Fitted values of ARMA model) I see that they can be calculated by certain expression: $e_t=X_t-Ar*X_{t-1}-Ma*e_{t-1}$, where $Ar$ and $Ma$ are parameters which you set in program $R$.

My question is how can I calculate or estimate residuals without having parameters $Ar$ and $Ma$? Because the goal of my application is actually to calculate these parameters and use the model for predicting.

Generally I understand residuals as the differences between real and predicted (estimated) values. So how can I estimate residuals if I don't have constructed model yet?

p.s. I looked up to some books and theory, but didn't find any example or exact explanation of what are the values of these residuals.

Thank you in advance.

For your ARMA(1,1) example, you need to assume you know the first $e_{t-1}$(you can fix it to zero). Then you run the model (starting from $X_{2}$ if you first data point is $X_{1}$) with different AR and MA coefficients , you'll obtain several errors series. For each error serie you compute the associated likelihood function. And finally the parameters (AR and MA) which gives you the highest Likelihood are the estimated parameters. Obviously you need to assume a distribution for the errors.