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.
- y: ndarray | DataFrame | Series | None =
- Raises:¶
TypeError – If
lagsorhold_backis not an integer (a float, including 5.0, and a bool are not accepted), ifconstantorrescaleis not a bool (rescalecan also be None), or ifvolatilityordistributionis not an instance ofVolatilityProcessorDistribution.ValueError – If
lagsis smaller than 1 orhold_backis 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
constantis 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_backor 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.
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.
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.
Return starting values for the mean model.
Properties
Get or set the error distribution.
The name of the model.
Number of parameters in the model.
Get or set the volatility process.
The dependent variable.