Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Moving Average (MA) Models | Section
Forecasting With Classical Models

bookMoving Average (MA) Models

Deslize para mostrar o menu

The moving average model, often abbreviated as MA(q), is a foundational concept in time series forecasting. Unlike moving average smoothing, which is a technique used to smooth out short-term fluctuations in observed data, the MA(q) model is a statistical model that describes a time series based on past error terms. The distinction is important: moving average smoothing is a data preprocessing tool, while the MA(q) model is a probabilistic model used for forecasting.

The MA(q) model assumes that the current value of a time series can be expressed as a linear combination of the current and previous random shocks (also called error terms or white noise). The general form of an MA(q) model is:

yt=μ+εt+θ1εt1+θ2εt2++θqεtqy_t = \mu + \varepsilon_t + \theta_1 \varepsilon_{t-1} + \theta_2 \varepsilon_{t-2} + \ldots + \theta_q \varepsilon_{t-q}

where:

  • yty_t is the value of the time series at time tt;
  • μμ is the mean of the series;
  • εtε_t is the white noise error term at time tt;
  • θ1,θ2,...,θqθ_1, θ_2, ..., θ_q are the parameters of the model;
  • qq is the order of the model, indicating how many lagged error terms are used.

This formulation means the present value is influenced by the current and previous qq shocks, rather than past observed values. In contrast, moving average smoothing simply averages observed data points over a window to reduce noise, without modeling the underlying data-generating process.

Understanding this distinction is essential for selecting the right approach for your forecasting problem. When you use an MA(q) model, you are assuming the underlying data follows a pattern where random shocks have a lasting impact for up to qq periods. This is fundamentally different from smoothing, which is only meant to clarify existing trends or cycles in the data.

123456789101112131415161718192021222324252627282930
import numpy as np import pandas as pd import matplotlib.pyplot as plt from statsmodels.tsa.arima.model import ARIMA # Simulate a time series with an MA(1) process np.random.seed(42) n = 200 mu = 5 theta1 = 0.7 errors = np.random.normal(0, 1, n + 1) y = [mu + errors[0]] for t in range(1, n): y.append(mu + errors[t] + theta1 * errors[t-1]) y = np.array(y) # Fit an MA(1) model model = ARIMA(y, order=(0, 0, 1)) fit = model.fit() # Plot original series and residuals fig, axs = plt.subplots(2, 1, figsize=(10, 6), sharex=True) axs[0].plot(y, label="Simulated MA(1) Series") axs[0].set_title("Simulated MA(1) Time Series") axs[0].legend() axs[1].plot(fit.resid, label="Residuals", color="orange") axs[1].set_title("Residuals of Fitted MA(1) Model") axs[1].legend() plt.tight_layout() plt.show()
copy
question mark

Which statement best describes the difference between an MA(q) model and moving average smoothing?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 7

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Seção 1. Capítulo 7
some-alt