# 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

\begin{eqnarray} r_t & = & \mu + \epsilon_t \\ \epsilon_t & = & \sigma_t e_t \\ \sigma^2_t & = & \omega + \alpha \epsilon_{t-1}^2 + \beta \sigma^2_{t-1} \end{eqnarray}

A complete ARCH model is divided into three components:

In most applications, 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

print(res.summary())


yields

                     Constant Mean - GARCH Model Results
==============================================================================
Dep. Variable:              Adj Close   R-squared:                      -0.001
Mean Model:             Constant Mean   Adj. R-squared:                 -0.001
Vol Model:                      GARCH   Log-Likelihood:               -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.487e-02      3.569  3.581e-04   [2.392e-02,8.220e-02]
Volatility Model
==============================================================================
coef    std err          t      P>|t|        95.0% Conf. Int.
------------------------------------------------------------------------------
omega          0.0156  4.932e-03      3.155  1.606e-03   [5.892e-03,2.523e-02]
alpha       0.0879  1.140e-02      7.710  1.260e-14     [6.554e-02,  0.110]
beta        0.9014  1.183e-02     76.163      0.000       [  0.878,  0.925]
==============================================================================

Covariance estimator: robust


## 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, rescale=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. model – Configured ARCH model ARCHModel

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 variance-covariance matrix of params. If none, calls method to compute variance from model when parameter covariance is first used from result r2 (float) – Model R-squared resid (ndarray) – Residuals from model. Residuals have same shape as original data and contain nan-values 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 optim_output (OptimizeResult) – Result of log-likelihood optimization 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
summary()[source]

Produce a summary of the results

plot()

Produce a plot of the volatility and standardized residuals

conf_int()[source]

Confidence intervals

loglikelihood

Value of the log-likelihood

Type: float
params

Estimated parameters

Type: Series
param_cov[source]

Estimated variance-covariance of the parameters

Type: DataFrame
resid

nobs element array containing model residuals

Type: {ndarray, Series}
model

Model instance used to produce the fit

Type: ARCHModel
arch_lm_test(lags=None, standardized=False)

ARCH LM test for conditional heteroskedasticity

Parameters: lags (int, optional) – Number of lags to include in the model. If not specified, standardized (bool, optional) – Flag indicating to test the model residuals divided by their conditional standard deviations. If False, directly tests the estimated residuals. result – Result of ARCH-LM test WaldTestStatistic
conf_int(alpha=0.05)[source]
Parameters: alpha (float, optional) – Size (prob.) to use when constructing the confidence interval. ci – Array where the ith row contains the confidence interval for the ith parameter ndarray
forecast(params=None, horizon=1, start=None, align='origin', method='analytic', simulations=1000, rng=None, random_state=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 ‘1945-01-01’. align (str, optional) – Either ‘origin’ or ‘target’. When set of ‘origin’, the t-th row of forecasts contains the forecasts for t+1, t+2, …, t+h. When set to ‘target’, the t-th row contains the 1-step ahead forecast from time t-1, the 2 step from time t-2, …, and the h-step from time t-h. ‘target’ simplified computing forecast errors since the realization and h-step 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 simulation-based forecasts. Must produce random samples using the syntax rng(size) where size the 2-element tuple (simulations, horizon). random_state (RandomState, optional) – NumPy RandomState instance to use when method is ‘bootstrap’ forecasts – t by h data frame containing the forecasts. The alignment of the forecasts is controlled by align. ARCHModelForecast

Notes

The most basic 1-step ahead forecast will return a vector with the same length as the original data, where the t-th value will be the time-t 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 time-t, h+1 step ahead forecast.

If model contains exogenous variables (model.x is not None), then only 1-step ahead forecasts are available. Using horizon > 1 will produce a warning and all columns, except the first, will be nan-filled.

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 3-step 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 1-d and identical in shape to the parameters computed by fitting the model. horizon (int, optional) – Number of steps to forecast step (int, optional) – Non-negative 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 ‘1945-01-01’. 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. fig – Handle to the figure 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('2000-01-01',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. fig – Handle to the figure 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 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 nan-values 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
summary()[source]

Produce a summary of the results

plot()[source]

Produce a plot of the volatility and standardized residuals

forecast()[source]

Construct forecasts from a model

loglikelihood[source]

Value of the log-likelihood

Type: float
params[source]

Estimated parameters

Type: Series
resid[source]

nobs element array containing model residuals

Type: {ndarray, Series}
model

Model instance used to produce the fit

Type: ARCHModel
arch_lm_test(lags=None, standardized=False)[source]

ARCH LM test for conditional heteroskedasticity

Parameters: lags (int, optional) – Number of lags to include in the model. If not specified, standardized (bool, optional) – Flag indicating to test the model residuals divided by their conditional standard deviations. If False, directly tests the estimated residuals. result – Result of ARCH-LM test WaldTestStatistic
forecast(params=None, horizon=1, start=None, align='origin', method='analytic', simulations=1000, rng=None, random_state=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 ‘1945-01-01’. align (str, optional) – Either ‘origin’ or ‘target’. When set of ‘origin’, the t-th row of forecasts contains the forecasts for t+1, t+2, …, t+h. When set to ‘target’, the t-th row contains the 1-step ahead forecast from time t-1, the 2 step from time t-2, …, and the h-step from time t-h. ‘target’ simplified computing forecast errors since the realization and h-step 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 simulation-based forecasts. Must produce random samples using the syntax rng(size) where size the 2-element tuple (simulations, horizon). random_state (RandomState, optional) – NumPy RandomState instance to use when method is ‘bootstrap’ forecasts – t by h data frame containing the forecasts. The alignment of the forecasts is controlled by align. ARCHModelForecast

Notes

The most basic 1-step ahead forecast will return a vector with the same length as the original data, where the t-th value will be the time-t 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 time-t, h+1 step ahead forecast.

If model contains exogenous variables (model.x is not None), then only 1-step ahead forecasts are available. Using horizon > 1 will produce a warning and all columns, except the first, will be nan-filled.

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 3-step 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 1-d and identical in shape to the parameters computed by fitting the model. horizon (int, optional) – Number of steps to forecast step (int, optional) – Non-negative 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 ‘1945-01-01’. 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. fig – Handle to the figure 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('2000-01-01',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. fig – Handle to the figure 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 Summary instance