# How to calculate ARMA model manually without R or Python

I kindly ask if someone at this forum knows how to manually calculate the arma model using time series data. I know how to do this using Python and R but im in need to do this manually. The data would be volatile. For example: 3.375, 3.200, 3.160, 3.110, 3.105, 3.230, 3.295, 3.375, 3.445, 3.315, 3.675. So it would both increase and decrease.

How would I, by using the example data, build an ARMA forecast model?

edit: Im new to this forum and if the question is not relevant, I apologize! Thanks in advance!

• What counts as "manually"? On your fingers? Pencil and paper? – The Laconic Feb 3 at 0:10
• Sorry for being unclear but yeah, pretty much. It would be ''easy'' doing this in R and/or python. However, im trying to incorporate the ARMA model into a programme where I can not use any advanced functions and have to do this manually. Im asking for someone to give an example of how to practically/manually calculate the model. I've found many examples of this online but I found them too theoretical without any pracitcal examples on how to apply data to the function – Vichtor Feb 3 at 0:25
• Can you please edit that new info into the Q? Some wants to close as 7nclear, with this incorporated it can stand – kjetil b halvorsen Feb 3 at 1:40
• Which is what I tried to do here stats.stackexchange.com/questions/77663/… – forecaster Feb 3 at 1:49
• Tack Kjetil, will do! – Vichtor Feb 3 at 2:46

## 1 Answer

It is unclear in your question what "manual calculation" excludes, and your comment that you cannot use "advanced functions" is also not very helpful. In any case, fitting an ARMA model via maximum-likelihood estimation is an optimisation problem where you need to maximise a function over a set of parameters. For example, the log-likelihood function in a stationary Gaussian ARMA is:

$$\ell_{x}(\mu,\boldsymbol{\phi},\boldsymbol{\theta}) = - \frac{1}{2} \ln | \boldsymbol{\Sigma}(\boldsymbol{\phi},\boldsymbol{\theta})| + (\mathbf{x} - \mu \boldsymbol{1})^\text{T} \boldsymbol{\Sigma}(\boldsymbol{\phi},\boldsymbol{\theta})^{-1} (\mathbf{x} - \mu \boldsymbol{1}),$$

where the covariance matrix $$\boldsymbol{\Sigma}(\boldsymbol{\phi},\boldsymbol{\theta})$$ depends on the parameters $$\boldsymbol{\phi}$$ and $$\boldsymbol{\theta}$$ according to the auto-covariance function for the ARMA model. This function has two terms. The second is a standard sum-of-squares term, but the first is a more complicated term involving the logarithm of the determinant of the covariance matrix.

The exact MLE method has critical point equations that cannot be put into closed form, so this would entail the use of iterative methods (e.g., Newton-Raphson iteration) to find the maximising values. If you are willing to deviate slightly from the exact MLE and use the partial likelihood function ---excluding the logarithmic term--- this gives MLEs that can be obtained as standard OLS estimates. Once you estimate the parameters in the model you can make forecasts as point-estimates by substituting the parameter estimates.

It is certainly possible to program this optimisation problem "manually", in the sense that you can directly program an iterative procedure to optimise the above function, without using pre-programmed optimisation procedures. It would be quite laborious, but it could probably done in a few hours.

• Thank you Ben for taking your time replying. I will defiently try your suggested method! – Vichtor Feb 3 at 2:49
• I think there are some important nuances in the mechanics of ARMA estimation which makes the conceptually straightforward way you describe rather burdensome computationally (so much so that estimation of even low-order models implemented this way is practically infeasible). I am no expert in this, but state space models and Kalman filters should probably be mentioned here as realistic alternatives. Also, I wonder if MLEs can really be obtained as standard OLS estimates for an ARMA(p,q) model with q>0, since the lagged error terms are unobservable, making OLS infeasible. – Richard Hardy Feb 4 at 8:29