arch.univariate.MAMean

class arch.univariate.MAMean(y: ndarray | DataFrame | Series | None = None, lags: int = 1, constant: bool = True, hold_back: int | None = None, volatility: VolatilityProcess | None = None, distribution: Distribution | None = None, rescale: bool | None = None)[source]

Moving average (MA) mean model, with optional constant.

Provides model estimation, simulation and forecasting.

Parameters:
y: ndarray | DataFrame | Series | None = None

Vector of nobs elements containing the dependent variable.

lags: int = 1

The order of the moving average, q. Must be at least 1.

constant: bool = True

Flag whether the model should include a constant.

hold_back: int | None = None

Number of observations at the start of the sample to exclude when estimating model parameters. Must be a non-negative integer.

volatility: VolatilityProcess | None = None

Volatility process to use in the model.

distribution: Distribution | None = None

Error distribution to use in the model.

rescale: bool | None = None

Flag indicating whether to automatically rescale data if the scale of the data is likely to produce convergence issues when estimating model parameters. If False, the model is estimated on the data without transformation. If True, then y is rescaled and the new scale is reported in the estimation results. If None, the data is not rescaled and a warning is issued when its scale is likely to produce convergence issues.

lags

The order of the moving average

Type:

int

constant

Whether the model includes a constant

Type:

bool

Raises:
  • TypeError – If lags or hold_back is not an integer (a float, including 5.0, and a bool are not accepted), if constant or rescale is not a bool (rescale can also be None), or if volatility or distribution is not an instance of VolatilityProcess or Distribution.

  • ValueError – If lags is smaller than 1 or hold_back is negative.

Notes

The MA(q) model is

\[y_t = \mu + \epsilon_t + \theta_1 \epsilon_{t-1} + \ldots + \theta_q \epsilon_{t-q}\]

where the innovations \(\epsilon_t=\sigma_t e_t\) have the conditional variance \(\sigma^2_t\) of the volatility process and \(e_t\) has the distribution of the model. The parameters are ordered \([\mu, \theta_1, \ldots, \theta_q]\), and \(\mu\) is not included when constant is False.

The innovations are not observed. They are computed recursively using

\[\epsilon_t = y_t - \mu - \theta_1 \epsilon_{t-1} - \ldots - \theta_q \epsilon_{t-q}\]

where the innovations before the first observation in the estimation sample are 0. This is the conditional likelihood, and its effect vanishes when the process is invertible, that is when all roots of \(1+\theta_1 z+\ldots+\theta_q z^q\) are outside of the unit circle. Starting values are invertible. Invertibility is imposed when q is 1 or 2 (by bounds and linear constraints, respectively), but is not imposed for larger q since the restrictions are nonlinear. The sample used to estimate the parameters is also the sample used to compute the innovations, and so observations excluded using hold_back or when fitting are not used.

The mean forecast of \(y_{T+h}\) is \(\mu + \sum_{j=h}^{q}\theta_j\epsilon_{T+h-j}\), which uses the last \(q-h+1\) innovations if \(h \leq q\), and is \(\mu\) after that. The forecast variance is \(\sum_{j=0}^{h-1}\psi_j^2\sigma^2_{T+h-j}\) with \(\psi_0=1\), \(\psi_j=\theta_j\) for \(j\leq q\) and 0 otherwise.

Exogenous regressors are not supported.

Examples

Simulate an MA(2) with GARCH errors and estimate the parameters

>>> import numpy as np
>>> from arch.univariate import GARCH, MAMean
>>> model = MAMean(lags=2, volatility=GARCH())
>>> params = np.array([0.1, 0.6, 0.2, 0.05, 0.1, 0.85])
>>> sim_data = model.simulate(params, 1000)
>>> model = MAMean(sim_data["data"], lags=2, volatility=GARCH())
>>> res = model.fit(disp="off")

Forecasts from an MA(q) are not constant for the first q steps

>>> forecasts = res.forecast(horizon=4, reindex=False)

Methods

append(y[, x])

Append observations to the model in-place.

bounds()

Construct bounds for parameters to use in non-linear optimization.

compute_param_cov(params[, backcast, robust])

Compute parameter covariances using numerical derivatives.

constraints()

Construct linear constraint arrays for use in non-linear optimization.

fit([update_freq, disp, starting_values, ...])

Estimate model parameters.

fix(params[, first_obs, last_obs])

Construct an ARCHModelFixedResult from fixed parameters.

forecast(params[, horizon, start, align, ...])

Construct forecasts from estimated model.

parameter_names()

Return the names of the parameters of the mean model.

resids(params[, y, regressors])

Compute model residuals.

simulate(params, nobs[, burn, ...])

Simulate data from a moving average model.

starting_values()

Return starting values for the mean model.

Properties

distribution

Get or set the error distribution.

name

The name of the model.

num_params

Number of parameters in the model.

volatility

Get or set the volatility process.

y

The dependent variable.