I would like to implement a moving average model in python as when I try to use the statsmodels library, specifically the ARMA(p,q) function and setting $p=0$ I get a lot of convergence errors in the underlying libraries and I don't really understand why a moving average model would cause such problems, so I would like to implement it myself.
From wikipedia a moving average model is defined as:
$$X_t=\mu+\epsilon_t+\theta_1\epsilon_{t-1}+\cdots+\theta_q\epsilon_{t-q},$$
where $\mu$ is the mean of the series, the $\theta_1,\cdots,\theta_q$ are the parameters and the $\epsilon_t,\cdots,\epsilon_{t-q}$ are white noise error terms. The value of $q$ is the order of the MA model. The article even makes a point of stating that a moving average model should not be confused with the moving average.
In looking for resources on how to implement this in python I came across many articles and blog posts which simply implement what I understand to be a moving average whereby a sliding window of size $n$ is defined and the value at the next step is simply the mean of samples within that sliding window.
If I wish to produce forecasts for time series data, are both techniques valid and inherently different or is a moving average model as defined here different from that of a moving average, which many people and resources seem to implement and call a moving average model, despite the defintion and their implementation being different. Is there a reason why there seem to be many implemenations of a moving average but relatively few implementations of what wikipedia defines to be a moving average model?
moving-average
tag: split into two?. $\endgroup$ – Richard Hardy Aug 24 '18 at 11:26