Introduction to ARCH Models¶
ARCH models are a popular class of volatility models that use observed values of returns or residuals as volatility shocks. A basic GARCH model is specified as
A complete ARCH model is divided into three components:
However, the simplest method to construct this model is to use the constructor
function arch_model()
import datetime as dt
import pandas_datareader.data as web
from arch import arch_model
start = dt.datetime(2000, 1, 1)
end = dt.datetime(2014, 1, 1)
sp500 = web.DataReader('^GSPC', 'yahoo', start=start, end=end)
returns = 100 * sp500['Adj Close'].pct_change().dropna()
am = arch_model(returns)
Alternatively, the same model can be manually assembled from the building blocks of an ARCH model
from arch import ConstantMean, GARCH, Normal
am = ConstantMean(returns)
am.volatility = GARCH(1, 0, 1)
am.distribution = Normal()
In either case, model parameters are estimated using
res = am.fit()
with the following output
Iteration: 1, Func. Count: 6, Neg. LLF: 5159.58323938
Iteration: 2, Func. Count: 16, Neg. LLF: 5156.09760149
Iteration: 3, Func. Count: 24, Neg. LLF: 5152.29989336
Iteration: 4, Func. Count: 31, Neg. LLF: 5146.47531817
Iteration: 5, Func. Count: 38, Neg. LLF: 5143.86337547
Iteration: 6, Func. Count: 45, Neg. LLF: 5143.02096168
Iteration: 7, Func. Count: 52, Neg. LLF: 5142.24105141
Iteration: 8, Func. Count: 60, Neg. LLF: 5142.07138907
Iteration: 9, Func. Count: 67, Neg. LLF: 5141.416653
Iteration: 10, Func. Count: 73, Neg. LLF: 5141.39212288
Iteration: 11, Func. Count: 79, Neg. LLF: 5141.39023885
Iteration: 12, Func. Count: 85, Neg. LLF: 5141.39023359
Optimization terminated successfully. (Exit mode 0)
Current function value: 5141.39023359
Iterations: 12
Function evaluations: 85
Gradient evaluations: 12
print(res.summary())
yields
Constant Mean  GARCH Model Results
==============================================================================
Dep. Variable: Adj Close Rsquared: 0.001
Mean Model: Constant Mean Adj. Rsquared: 0.001
Vol Model: GARCH LogLikelihood: 5141.39
Distribution: Normal AIC: 10290.8
Method: Maximum Likelihood BIC: 10315.4
No. Observations: 3520
Date: Fri, Dec 02 2016 Df Residuals: 3516
Time: 22:22:28 Df Model: 4
Mean Model
==============================================================================
coef std err t P>t 95.0% Conf. Int.

mu 0.0531 1.487e02 3.569 3.581e04 [2.392e02,8.220e02]
Volatility Model
==============================================================================
coef std err t P>t 95.0% Conf. Int.

omega 0.0156 4.932e03 3.155 1.606e03 [5.892e03,2.523e02]
alpha[1] 0.0879 1.140e02 7.710 1.260e14 [6.554e02, 0.110]
beta[1] 0.9014 1.183e02 76.163 0.000 [ 0.878, 0.925]
==============================================================================
Covariance estimator: robust
Core Model Constructor¶
While models can be carefully specified using the individual components, most common specifications can be specified using a simple model constructor.

arch.
arch_model
(y, x=None, mean='Constant', lags=0, vol='Garch', p=1, o=0, q=1, power=2.0, dist='Normal', hold_back=None)[source]¶ Convenience function to simplify initialization of ARCH models
Parameters:  y ({ndarray, Series, None}) – The dependent variable
 x ({np.array, DataFrame}, optional) – Exogenous regressors. Ignored if model does not permit exogenous regressors.
 mean (str, optional) – Name of the mean model. Currently supported options are: ‘Constant’, ‘Zero’, ‘ARX’ and ‘HARX’
 lags (int or list (int), optional) – Either a scalar integer value indicating lag length or a list of integers specifying lag locations.
 vol (str, optional) – Name of the volatility model. Currently supported options are: ‘GARCH’ (default), ‘ARCH’, ‘EGARCH’, ‘FIARCH’ and ‘HARCH’
 p (int, optional) – Lag order of the symmetric innovation
 o (int, optional) – Lag order of the asymmetric innovation
 q (int, optional) – Lag order of lagged volatility or equivalent
 power (float, optional) – Power to use with GARCH and related models
 dist (int, optional) –
Name of the error distribution. Currently supported options are:
 Normal: ‘normal’, ‘gaussian’ (default)
 Students’s t: ‘t’, ‘studentst’
 Skewed Student’s t: ‘skewstudent’, ‘skewt’
 Generalized Error Distribution: ‘ged’, ‘generalized error”
 hold_back (int) – Number of observations at the start of the sample to exclude when estimating model parameters. Used when comparing models with different lag lengths to estimate on the common sample.
Returns: model – Configured ARCH model
Return type: Examples
>>> import datetime as dt >>> import pandas_datareader.data as web >>> djia = web.get_data_fred('DJIA') >>> returns = 100 * djia['DJIA'].pct_change().dropna()
A basic GARCH(1,1) with a constant mean can be constructed using only the return data
>>> from arch.univariate import arch_model >>> am = arch_model(returns)
Alternative mean and volatility processes can be directly specified
>>> am = arch_model(returns, mean='AR', lags=2, vol='harch', p=[1, 5, 22])
This example demonstrates the construction of a zero mean process with a TARCH volatility process and Student t error distribution
>>> am = arch_model(returns, mean='zero', p=1, o=1, q=1, ... power=1.0, dist='StudentsT')
Notes
Input that are not relevant for a particular specification, such as lags when mean=’zero’, are silently ignored.
Model Results¶
All model return the same object, a results class (ARCHModelResult
)

class
arch.univariate.base.
ARCHModelResult
(params, param_cov, r2, resid, volatility, cov_type, dep_var, names, loglikelihood, is_pandas, optim_output, fit_start, fit_stop, model)[source]¶ Results from estimation of an ARCHModel model
Parameters:  params (ndarray) – Estimated parameters
 param_cov ({ndarray, None}) – Estimated variancecovariance matrix of params. If none, calls method to compute variance from model when parameter covariance is first used from result
 r2 (float) – Model Rsquared
 resid (ndarray) – Residuals from model. Residuals have same shape as original data and contain nanvalues in locations not used in estimation
 volatility (ndarray) – Conditional volatility from model
 cov_type (str) – String describing the covariance estimator used
 dep_var (Series) – Dependent variable
 names (list (str)) – Model parameter names
 loglikelihood (float) – Loglikelihood at estimated parameters
 is_pandas (bool) – Whether the original input was pandas
 fit_start (int) – Integer index of the first observation used to fit the model
 fit_stop (int) – Integer index of the last observation used to fit the model using slice notation fit_start:fit_stop
 model (ARCHModel) – The model object used to estimate the parameters

plot
()¶ Produce a plot of the volatility and standardized residuals

loglikelihood
¶ float – Value of the loglikelihood

params
¶ Series – Estimated parameters

param_cov
¶ DataFrame – Estimated variancecovariance of the parameters

resid
¶ {ndarray, Series} – nobs element array containing model residuals

model
¶ ARCHModel – Model instance used to produce the fit

conf_int
(alpha=0.05)[source] Parameters: alpha (float, optional) – Size (prob.) to use when constructing the confidence interval. Returns: ci – Array where the ith row contains the confidence interval for the ith parameter Return type: ndarray

forecast
(params=None, horizon=1, start=None, align='origin', method='analytic', simulations=1000, rng=None)¶ Construct forecasts from estimated model
Parameters:  params (ndarray, optional) – Alternative parameters to use. If not provided, the parameters estimated when fitting the model are used. Must be identical in shape to the parameters computed by fitting the model.
 horizon (int, optional) – Number of steps to forecast
 start ({int, datetime, Timestamp, str}, optional) – An integer, datetime or str indicating the first observation to produce the forecast for. Datetimes can only be used with pandas inputs that have a datetime index. Strings must be convertible to a date time, such as in ‘19450101’.
 align (str, optional) – Either ‘origin’ or ‘target’. When set of ‘origin’, the tth row of forecasts contains the forecasts for t+1, t+2, …, t+h. When set to ‘target’, the tth row contains the 1step ahead forecast from time t1, the 2 step from time t2, …, and the hstep from time th. ‘target’ simplified computing forecast errors since the realization and hstep forecast are aligned.
 method ({'analytic', 'simulation', 'bootstrap'}, optional) – Method to use when producing the forecast. The default is analytic. The method only affects the variance forecast generation. Not all volatility models support all methods. In particular, volatility models that do not evolve in squares such as EGARCH or TARCH do not support the ‘analytic’ method for horizons > 1.
 simulations (int, optional) – Number of simulations to run when computing the forecast using either simulation or bootstrap.
 rng (callable, optional) – Custom random number generator to use in simulationbased forecasts. Must produce random samples using the syntax rng(size) where size the 2element tuple (simulations, horizon).
Returns: forecasts – t by h data frame containing the forecasts. The alignment of the forecasts is controlled by align.
Return type: Notes
The most basic 1step ahead forecast will return a vector with the same length as the original data, where the tth value will be the timet forecast for time t + 1. When the horizon is > 1, and when using the default value for align, the forecast value in position [t, h] is the timet, h+1 step ahead forecast.
If model contains exogenous variables (model.x is not None), then only 1step ahead forecasts are available. Using horizon > 1 will produce a warning and all columns, except the first, will be nanfilled.
If align is ‘origin’, forecast[t,h] contains the forecast made using y[:t] (that is, up to but not including t) for horizon h + 1. For example, y[100,2] contains the 3step ahead forecast using the first 100 data points, which will correspond to the realization y[100 + 2]. If align is ‘target’, then the same forecast is in location [102, 2], so that it is aligned with the observation to use when evaluating, but still in the same column.

hedgehog_plot
(params=None, horizon=10, step=10, start=None, type='volatility', method='analytic', simulations=1000)¶ Plot forecasts from estimated model
Parameters:  params ({ndarray, Series}) – Alternative parameters to use. If not provided, the parameters computed by fitting the model are used. Must be 1d and identical in shape to the parameters computed by fitting the model.
 horizon (int, optional) – Number of steps to forecast
 step (int, optional) – Nonnegative number of forecasts to skip between spines
 start (int, datetime or str, optional) – An integer, datetime or str indicating the first observation to produce the forecast for. Datetimes can only be used with pandas inputs that have a datetime index. Strings must be convertible to a date time, such as in ‘19450101’. If not provided, the start is set to the earliest forecastable date.
 type ({'volatility', 'mean'}) – Quantity to plot, the forecast volatility or the forecast mean
 method ({'analytic', 'simulation', 'bootstrap'}) – Method to use when producing the forecast. The default is analytic. The method only affects the variance forecast generation. Not all volatility models support all methods. In particular, volatility models that do not evolve in squares such as EGARCH or TARCH do not support the ‘analytic’ method for horizons > 1.
 simulations (int) – Number of simulations to run when computing the forecast using either simulation or bootstrap.
Returns: fig – Handle to the figure
Return type: figure
Examples
>>> import pandas as pd >>> from arch import arch_model >>> am = arch_model(None,mean='HAR',lags=[1,5,22],vol='Constant') >>> sim_data = am.simulate([0.1,0.4,0.3,0.2,1.0], 250) >>> sim_data.index = pd.date_range('20000101',periods=250) >>> am = arch_model(sim_data['data'],mean='HAR',lags=[1,5,22], vol='Constant') >>> res = am.fit() >>> fig = res.hedgehog_plot(type='mean')

plot
(annualize=None, scale=None) Plot standardized residuals and conditional volatility
Parameters:  annualize (str, optional) – String containing frequency of data that indicates plot should contain annualized volatility. Supported values are ‘D’ (daily), ‘W’ (weekly) and ‘M’ (monthly), which scale variance by 252, 52, and 12, respectively.
 scale (float, optional) – Value to use when scaling returns to annualize. If scale is provides, annualize is ignored and the value in scale is used.
Returns: fig – Handle to the figure
Return type: figure
Examples
>>> from arch import arch_model >>> am = arch_model(None) >>> sim_data = am.simulate([0.0, 0.01, 0.07, 0.92], 2520) >>> am = arch_model(sim_data['data']) >>> res = am.fit(update_freq=0, disp='off') >>> fig = res.plot()
Produce a plot with annualized volatility
>>> fig = res.plot(annualize='D')
Override the usual scale of 252 to use 360 for an asset that trades most days of the year
>>> fig = res.plot(scale=360)

summary
()[source] Constructs a summary of the results from a fit model.
Returns: summary – Object that contains tables and facilitated export to text, html or latex Return type: Summary instance
When using the fix
method, a (ARCHModelFixedResult
) is produced
that lacks some properties of a (ARCHModelResult
) that are not
relevant when parameters are not estimated.

class
arch.univariate.base.
ARCHModelFixedResult
(params, resid, volatility, dep_var, names, loglikelihood, is_pandas, model)[source]¶ Results for fixed parameters for an ARCHModel model
Parameters:  params (ndarray) – Estimated parameters
 resid (ndarray) – Residuals from model. Residuals have same shape as original data and contain nanvalues in locations not used in estimation
 volatility (ndarray) – Conditional volatility from model
 dep_var (Series) – Dependent variable
 names (list (str)) – Model parameter names
 loglikelihood (float) – Loglikelihood at specified parameters
 is_pandas (bool) – Whether the original input was pandas
 model (ARCHModel) – The model object used to estimate the parameters

loglikelihood
¶ float – Value of the loglikelihood

params
¶ Series – Estimated parameters

resid
¶ {ndarray, Series} – nobs element array containing model residuals

model
¶ ARCHModel – Model instance used to produce the fit

forecast
(params=None, horizon=1, start=None, align='origin', method='analytic', simulations=1000, rng=None)[source] Construct forecasts from estimated model
Parameters:  params (ndarray, optional) – Alternative parameters to use. If not provided, the parameters estimated when fitting the model are used. Must be identical in shape to the parameters computed by fitting the model.
 horizon (int, optional) – Number of steps to forecast
 start ({int, datetime, Timestamp, str}, optional) – An integer, datetime or str indicating the first observation to produce the forecast for. Datetimes can only be used with pandas inputs that have a datetime index. Strings must be convertible to a date time, such as in ‘19450101’.
 align (str, optional) – Either ‘origin’ or ‘target’. When set of ‘origin’, the tth row of forecasts contains the forecasts for t+1, t+2, …, t+h. When set to ‘target’, the tth row contains the 1step ahead forecast from time t1, the 2 step from time t2, …, and the hstep from time th. ‘target’ simplified computing forecast errors since the realization and hstep forecast are aligned.
 method ({'analytic', 'simulation', 'bootstrap'}, optional) – Method to use when producing the forecast. The default is analytic. The method only affects the variance forecast generation. Not all volatility models support all methods. In particular, volatility models that do not evolve in squares such as EGARCH or TARCH do not support the ‘analytic’ method for horizons > 1.
 simulations (int, optional) – Number of simulations to run when computing the forecast using either simulation or bootstrap.
 rng (callable, optional) – Custom random number generator to use in simulationbased forecasts. Must produce random samples using the syntax rng(size) where size the 2element tuple (simulations, horizon).
Returns: forecasts – t by h data frame containing the forecasts. The alignment of the forecasts is controlled by align.
Return type: Notes
The most basic 1step ahead forecast will return a vector with the same length as the original data, where the tth value will be the timet forecast for time t + 1. When the horizon is > 1, and when using the default value for align, the forecast value in position [t, h] is the timet, h+1 step ahead forecast.
If model contains exogenous variables (model.x is not None), then only 1step ahead forecasts are available. Using horizon > 1 will produce a warning and all columns, except the first, will be nanfilled.
If align is ‘origin’, forecast[t,h] contains the forecast made using y[:t] (that is, up to but not including t) for horizon h + 1. For example, y[100,2] contains the 3step ahead forecast using the first 100 data points, which will correspond to the realization y[100 + 2]. If align is ‘target’, then the same forecast is in location [102, 2], so that it is aligned with the observation to use when evaluating, but still in the same column.

hedgehog_plot
(params=None, horizon=10, step=10, start=None, type='volatility', method='analytic', simulations=1000)[source]¶ Plot forecasts from estimated model
Parameters:  params ({ndarray, Series}) – Alternative parameters to use. If not provided, the parameters computed by fitting the model are used. Must be 1d and identical in shape to the parameters computed by fitting the model.
 horizon (int, optional) – Number of steps to forecast
 step (int, optional) – Nonnegative number of forecasts to skip between spines
 start (int, datetime or str, optional) – An integer, datetime or str indicating the first observation to produce the forecast for. Datetimes can only be used with pandas inputs that have a datetime index. Strings must be convertible to a date time, such as in ‘19450101’. If not provided, the start is set to the earliest forecastable date.
 type ({'volatility', 'mean'}) – Quantity to plot, the forecast volatility or the forecast mean
 method ({'analytic', 'simulation', 'bootstrap'}) – Method to use when producing the forecast. The default is analytic. The method only affects the variance forecast generation. Not all volatility models support all methods. In particular, volatility models that do not evolve in squares such as EGARCH or TARCH do not support the ‘analytic’ method for horizons > 1.
 simulations (int) – Number of simulations to run when computing the forecast using either simulation or bootstrap.
Returns: fig – Handle to the figure
Return type: figure
Examples
>>> import pandas as pd >>> from arch import arch_model >>> am = arch_model(None,mean='HAR',lags=[1,5,22],vol='Constant') >>> sim_data = am.simulate([0.1,0.4,0.3,0.2,1.0], 250) >>> sim_data.index = pd.date_range('20000101',periods=250) >>> am = arch_model(sim_data['data'],mean='HAR',lags=[1,5,22], vol='Constant') >>> res = am.fit() >>> fig = res.hedgehog_plot(type='mean')

plot
(annualize=None, scale=None)[source] Plot standardized residuals and conditional volatility
Parameters:  annualize (str, optional) – String containing frequency of data that indicates plot should contain annualized volatility. Supported values are ‘D’ (daily), ‘W’ (weekly) and ‘M’ (monthly), which scale variance by 252, 52, and 12, respectively.
 scale (float, optional) – Value to use when scaling returns to annualize. If scale is provides, annualize is ignored and the value in scale is used.
Returns: fig – Handle to the figure
Return type: figure
Examples
>>> from arch import arch_model >>> am = arch_model(None) >>> sim_data = am.simulate([0.0, 0.01, 0.07, 0.92], 2520) >>> am = arch_model(sim_data['data']) >>> res = am.fit(update_freq=0, disp='off') >>> fig = res.plot()
Produce a plot with annualized volatility
>>> fig = res.plot(annualize='D')
Override the usual scale of 252 to use 360 for an asset that trades most days of the year
>>> fig = res.plot(scale=360)

summary
()[source] Constructs a summary of the results from a fit model.
Returns: summary – Object that contains tables and facilitated export to text, html or latex Return type: Summary instance