Introduction and type hierarchy

Introduction and type hierarchy

Consider a sample of daily asset returns $\{r_t\}_{t\in\{1,\ldots,T\}}$. All models covered in this package share the same basic structure, in that they decompose the return into a conditional mean and a mean-zero innovation:

\[r_t=\mu_t+\sigma_tz_t,\quad \mu_t\equiv\mathbb{E}[r_t\mid\mathcal{F}_{t-1}],\quad \sigma_t^2\equiv\mathbb{E}[(r_t-\mu_t)^2\mid\mathcal{F}_{t-1}],\]

where $z_t$ is identically and independently distributed according to some law with mean zero and unit variance and $\\{\mathcal{F}_t\\}$ is the natural filtration of $\\{r_t\\}$ (i.e., it encodes information about past returns).

This package represents a univariate (G)ARCH model as an instance of UnivariateARCHModel, which implements the interface of StatisticalModel from StatsBase. An instance of this type contains a vector of data (such as equity returns), and encapsulates information about the volatility specification (e.g., GARCH or EGARCH), the mean specification (e.g., whether an intercept is included), and the error distribution.

Volatility specifications

Volatility specifications describe the evolution of $\sigma_t$. They are modelled as subtypes of VolatilitySpec. There is one type for each class of (G)ARCH model, parameterized by the number(s) of lags (e.g., $p$, $q$ for a GARCH(p, q) model). For each volatility specification, the order of the parameters in the coefficient vector is such that all parameters pertaining to the first type parameter ($p$) appear before those pertaining to the second ($q$).

ARCH

With $a_t\equiv r_t-\mu_t$, the ARCH(q) volatility specification, due to Engle (1982), is

\[\sigma_t^2=\omega+\sum_{i=1}^q\alpha_i a_{t-i}^2, \quad \omega, \alpha_i>0,\quad \sum_{i=1}^{q} \alpha_i<1.\]

The corresponding type is ARCH{q}. For example, an ARCH(2) model with $ω=1$, $α₁=.5$, and $α₂=.4$ is obtained with

julia> using ARCHModels

julia> ARCH{2}([1., .5, .4])
TGARCH{0,0,2} specification.

               ω  α₁  α₂
Parameters:  1.0 0.5 0.4

GARCH

The GARCH(p, q) model, due to Bollerslev (1986), specifies the volatility as

\[\sigma_t^2=\omega+\sum_{i=1}^p\beta_i \sigma_{t-i}^2+\sum_{i=1}^q\alpha_i a_{t-i}^2, \quad \omega, \alpha_i, \beta_i>0,\quad \sum_{i=1}^{\max p,q} \alpha_i+\beta_i<1.\]

It is available as GARCH{p, q}:

julia> using ARCHModels

julia> GARCH{1, 1}([1., .9, .05])
TGARCH{0,1,1} specification.

               ω  β₁   α₁
Parameters:  1.0 0.9 0.05

This creates a GARCH(1, 1) specification with $ω=1$, $β=.9$, and $α=.05$.

TGARCH

As may have been guessed from the output above, the ARCH and GARCH models are actually special cases of a more general class of models, known as TGARCH (Threshold GARCH), due to Glosten, Jagannathan, and Runkle. The TGARCH{o, p, q} model takes the form

\[\sigma_t^2=\omega+\sum_{i=1}^o\gamma_i a_{t-i}^2 1_{a_{t-i}<0}+\sum_{i=1}^p\beta_i \sigma_{t-i}^2+\sum_{i=1}^q\alpha_i a_{t-i}^2, \quad \omega, \alpha_i, \beta_i, \gamma_i>0, \sum_{i=1}^{\max o,p,q} \alpha_i+\beta_i+\gamma_i/2<1.\]

The TGARCH model allows the volatility to react differently (typically more strongly) to negative shocks, a feature known as the (statistical) leverage effect. Is available as TGARCH{o, p, q}:

julia> using ARCHModels

julia> TGARCH{1, 1, 1}([1., .04, .9, .01])
TGARCH{1,1,1} specification.

               ω   γ₁  β₁   α₁
Parameters:  1.0 0.04 0.9 0.01

EGARCH

The EGARCH{o, p, q} volatility specification, due to Nelson (1991), is

\[\log(\sigma_t^2)=\omega+\sum_{i=1}^o\gamma_i z_{t-i}+\sum_{i=1}^p\beta_i \log(\sigma_{t-i}^2)+\sum_{i=1}^q\alpha_i (|z_{t-i}|-\sqrt{2/\pi}), \quad z_t=r_t/\sigma_t,\quad \sum_{i=1}^{p}\beta_i<1.\]

Like the TGARCH model, it can account for the leverage effect. The corresponding type is EGARCH{o, p, q}:

julia> EGARCH{1, 1, 1}([-0.1, .1, .9, .04])
EGARCH{1,1,1} specification.

                ω  γ₁  β₁   α₁
Parameters:  -0.1 0.1 0.9 0.04

Mean specifications

Mean specifications serve to specify $\mu_t$. They are modelled as subtypes of MeanSpec. They contain their parameters as (possibly empty) vectors, but convenience constructors are provided where appropriate. Currently, three specifications are available:

julia> NoIntercept() # convenience constructor, eltype defaults to Float64
NoIntercept{Float64}(Float64[])
julia> Intercept(3) # convenience constructor
Intercept{Float64}([3.0])
julia> ARMA{1, 1}([1., .9, -.1])
ARMA{1,1,Float64}([1.0, 0.9, -0.1])

Pure AR(p) and MA(q) models are obtained as follows:

julia> AR{1}([1., .9])
ARMA{1,0,Float64}([1.0, 0.9])
julia> MA{1}([1., -.1])
ARMA{0,1,Float64}([1.0, -0.1])

As an example, an ARMA(1, 1)-EGARCH(1, 1, 1) model is fitted as follows:

julia> fit(EGARCH{1, 1, 1}, BG96; meanspec=ARMA{1, 1})

EGARCH{1,1,1} model with Gaussian errors, T=1974.


Mean equation parameters:

       Estimate Std.Error  z value Pr(>|z|)
c    -0.0215594 0.0136142 -1.58359   0.1133
φ₁    -0.525702   0.20819  -2.5251   0.0116
θ₁     0.574669  0.198072  2.90131   0.0037

Volatility parameters:

       Estimate Std.Error  z value Pr(>|z|)
ω     -0.132921 0.0496466 -2.67735   0.0074
γ₁   -0.0399304 0.0258478 -1.54483   0.1224
β₁     0.908516 0.0319702  28.4175   <1e-99
α₁     0.343967 0.0680369  5.05559    <1e-6

Distributions

Built-in distributions

Different standardized (mean zero, variance one) distributions for $z_t$ are available as subtypes of StandardizedDistribution. StandardizedDistribution in turn subtypes Distribution{Univariate, Continuous} from Distributions.jl, though not the entire interface must necessarily be implemented. StandardizedDistributions again hold their parameters as vectors, but convenience constructors are provided. The following are currently available:

julia> StdNormal() # convenience constructor
StdNormal{Float64}(coefs=Float64[])
julia> StdT(3) # convenience constructor
StdT{Float64}(coefs=[3.0])
julia> StdGED(1) # convenience constructor
StdGED{Float64}(coefs=[1.0])

User-defined standardized distributions

Apart from the natively supported standardized distributions, it is possible to wrap a continuous univariate distribution from the Distributions package in the Standardized wrapper type. Below, we reimplement the standardized normal distribution:

julia> using Distributions

julia> const MyStdNormal = Standardized{Normal};

MyStdNormal can be used whereever a built-in distribution could, albeit with a speed penalty. Note also that if the underlying distribution (such as Normal in the example above) contains location and/or scale parameters, then these are no longer identifiable, which implies that the estimated covariance matrix of the estimators will be singular.

A final remark concerns the domain of the parameters: the estimation process relies on a starting value for the parameters of the distribution, say $\theta\equiv(\theta_1, \ldots, \theta_p)'$. For a distribution wrapped in Standardized, the starting value for $\theta_i$ is taken to be a small positive value ϵ. This will fail if ϵ is not in the domain of $\theta_i$; as an example, the standardized Student's $t$ distribution is only defined for degrees of freedom larger than 2, because a finite variance is required for standardization. In that case, it is necessary to define a method of the (non-exported) function startingvals that returns a feasible vector of starting values, as follows:

julia> const MyStdT = Standardized{TDist};

julia> ARCHModels.startingvals(::Type{<:MyStdT}, data::Vector{T}) where T = T[3.]

Working with UnivariateARCHModels

The constructor for UnivariateARCHModel takes two mandatory arguments: an instance of a subtype of VolatilitySpec, and a vector of returns. The mean specification and error distribution can be changed via the keyword arguments meanspec and dist, which respectively default to NoIntercept and StdNormal.

For example, to construct a GARCH(1, 1) model with an intercept and $t$-distributed errors, one would do

julia> spec = GARCH{1, 1}([1., .9, .05]);

julia> data = BG96;

julia> am = UnivariateARCHModel(spec, data; dist=StdT(3.), meanspec=Intercept(1.))

TGARCH{0,1,1} model with Student's t errors, T=1974.


                             μ
Mean equation parameters:  1.0

                             ω  β₁   α₁
Volatility parameters:     1.0 0.9 0.05

                             ν
Distribution parameters:   3.0

The model can then be fitted as follows:

julia> fit!(am)

TGARCH{0,1,1} model with Student's t errors, T=1974.


Mean equation parameters:

       Estimate  Std.Error  z value Pr(>|z|)
μ    0.00227251 0.00686802 0.330882   0.7407

Volatility parameters:

       Estimate  Std.Error z value Pr(>|z|)
ω    0.00232225 0.00163909 1.41679   0.1565
β₁     0.884488   0.036963  23.929   <1e-99
α₁     0.124866  0.0405471 3.07952   0.0021

Distribution parameters:

     Estimate Std.Error z value Pr(>|z|)
ν     4.11211  0.400384 10.2704   <1e-24

It should, however, rarely be necessary to construct an UnivariateARCHModel manually via its constructor; typically, instances of it are created by calling fit, selectmodel, or simulate.

As discussed earlier, UnivariateARCHModel implements the interface of StatisticalModel from StatsBase, so you can call coef, coefnames, confint, dof, informationmatrix, isfitted, loglikelihood, nobs, score, stderror, vcov, etc. on its instances:

julia> nobs(am)
1974

Other useful methods include means, volatilities and residuals.