Skip to content
Tutorials Center
My learning

Topics

Lesson 21 of 40 ยท ARIMA and SARIMA

Moving Average (MA) Models

Understand the MA(q) model as a weighted sum of past shocks, how it differs from a smoothing average, how to read its ACF cutoff, invertibility, and how to fit one in Python.

The name "moving average model" is a trap. In forecasting, a moving average usually means smoothing: average the last 7 days to get a calmer line. An MA model is something different. It says that today's value is a weighted sum of today's shock and a few past shocks (the forecast errors of earlier steps). It models short-lived effects that echo for a few periods and then vanish completely.

Where the AR model has a long, fading memory of values, an MA model has a hard memory limit of exactly q steps. Together they form ARMA, and with differencing, ARIMA.

The MA(q) equation

y[t] = mu + e[t] + theta1 * e[t-1] + theta2 * e[t-2] + ... + thetaq * e[t-q]

  • mu is the process mean.
  • e[t] is white noise (the shock arriving at time t).
  • theta1 ... thetaq weigh how much each past shock still leaks into today's value.

Think of a shop that runs a flash sale announced by a surprise email. The shock (the email) lifts sales today and tomorrow, and then it is gone. A shock older than q periods has exactly zero effect, which is why an MA model is always stationary in its mean and variance, whatever the thetas are.

Invertibility

Different theta values can produce identical autocorrelations (for MA(1), theta and 1/theta do). To make the fit unique, software requires the model to be invertible, meaning it can be rewritten as an AR process of infinite order. For MA(1) that means |theta| < 1. Do not worry about this when fitting; statsmodels enforces it.

The ACF fingerprint: a hard cutoff

For MA(q), the ACF is exactly zero after lag q. That is the mirror image of the AR rule:

Model ACF PACF
AR(p) tails off gradually cuts off after p
MA(q) cuts off after q tails off gradually
ARMA(p, q) tails off tails off
Python MA(2): ACF cuts off after lag 2

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Lags 1 and 2 stand out; lags 3, 4 and 5 sit inside the band. The theoretical lag-1 autocorrelation of this process is (theta1 + theta1*theta2) / (1 + theta1^2 + theta2^2), about 0.59, and the simulation lands close to it.

flowchart TD
    A["Look at the ACF"] --> B{"Cuts off sharply after lag q?"}
    B -->|"yes"| C["Try MA(q)"]
    B -->|"no, decays slowly"| D["Look at the PACF"]
    D --> E{"PACF cuts off at p?"}
    E -->|"yes"| F["Try AR(p)"]
    E -->|"no"| G["Try ARMA(p, q) and compare AIC"]

A rough identification flow for stationary series. Always confirm with AIC and residual checks.

Fit an MA model

An MA model has no closed-form least squares solution, because the shocks are not observed. It is estimated by maximum likelihood. In statsmodels an MA(q) model is ARIMA(order=(0, 0, q)).

Python Recover the thetas with ARIMA(0,0,2)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The names ma.L1 and ma.L2 are the estimates of theta1 and theta2. Look at the forecast: the first two steps still use known past shocks, but from the third step on the forecast is exactly the mean (about 5). That is the memory limit in action: beyond q steps ahead, an MA model has nothing to say.

MA models versus smoothing averages

These two ideas share a name but nothing else.

Smoothing moving average MA(q) model
Averages past observations past shocks (errors)
Purpose remove noise to show a trend model short-term dependence
Shocks observed? not needed estimated by the model
Forecast flat or lagging line converges to the mean after q steps

Smoothing belongs to the earlier chapters on smoothing methods; in this chapter "MA" always means the model.

Compare candidate models with AIC

When the ACF and PACF are ambiguous, fit a few small models and let AIC arbitrate.

Python MA order by AIC

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

AIC drops sharply from MA(0) to MA(2), then flattens or rises slightly. The elbow marks the true order; extra terms buy almost no fit and pay a penalty.

Common mistakes

  • Confusing the model with smoothing. If someone says "use a 3-period moving average", ask whether they want smoothing or an MA(3) model.
  • Over-differencing. Differencing a series that is already stationary creates a spurious negative MA(1) term (theta near -1). If an estimated theta1 is close to -1, suspect that you differenced too much.
  • Expecting long forecasts. After q steps the forecast is the mean. Use AR terms or seasonal terms when you need structure further out.
  • Reading theta signs from the ACF. A positive theta gives a positive ACF at lag 1, a negative theta a negative one.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does an MA(q) model regress the current value on?

    An MA model is a weighted sum of the current and past q white-noise shocks, not of past observed values.
  2. 2. A series' ACF is large at lags 1 and 2 and zero afterwards. Which model is suggested?

    A sharp ACF cutoff after lag q is the signature of an MA(q) process.
  3. 3. In forecasts from an MA(2) model, what happens from step 3 onward?

    Shocks older than q periods have no effect, so beyond q steps the best prediction is just the mean.
  4. 4. An estimated MA(1) coefficient is -0.98. What is the most likely cause?

    Differencing an already stationary series introduces a unit-root MA term, so theta close to -1 is a classic sign of over-differencing.

Summary

  • An MA(q) model writes the value as a mean plus the current shock and q past shocks.
  • Its ACF cuts off after lag q; its PACF tails off. It is always stationary and is kept invertible for a unique fit.
  • Fit it with ARIMA(order=(0, 0, q)); forecasts become the mean after q steps.
  • Do not confuse the MA model with a smoothing moving average.

Next: ARIMA Model Fitting