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, model estimation, simulation and forecasting

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

nobs element vector 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.

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.

lags

The order of the moving average

Type:

int

constant

Whether the model includes a constant

Type:

bool

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])

Computes 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])

Allows an ARCHModelFixedResult to be constructed from fixed parameters.

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

Construct forecasts from estimated model

parameter_names()

List of parameters names

resids(params[, y, regressors])

Compute model residuals

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

Simulates data from a moving average model

starting_values()

Returns starting values for the mean model, often the same as the values returned from fit

Properties

distribution

Set or gets the error distribution

name

The name of the model.

num_params

Returns the number of parameters

volatility

Set or gets the volatility process

y

Returns the dependent variable