Package com.imsl.stat

Class ExtendedGARCH

java.lang.Object
com.imsl.stat.ExtendedGARCH
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
EGARCH

public abstract class ExtendedGARCH extends Object implements Serializable, Cloneable
Abstract class for extended GARCH models.

The classical GARCH\((p,q)\) process \(\epsilon_t\) satisfies $$ \left\{ \begin{array}{ll} \epsilon_t = \sigma_t z_t & \\ \sigma_t^2 = Var(\epsilon_t|\epsilon_u, u \lt t) = \omega + \alpha(B)\epsilon^2_{t} + \beta(B)\sigma^2_{t} & \end{array} \right. $$ where \(\omega, \alpha_i, \beta_j\) are non-negative constants, \(\alpha(B)=\sum_{i=1}^q \alpha_iB^i\), \(\beta(B)=\sum_{j=1}^p \beta_jB^j\), and \(B\) is the backshift operator defined as \(B^jx_t = x_{t-j}\). The \(z_t\) are \(iid\) random variables where usually the distribution is assumed to be the normal distribution.

If \(y_t = \frac{p_t}{p_{t-1}}\) is the daily (percentage or log percentage) return on a stock or stock index, the residuals \(\epsilon_t = y_t - \mu_t \) may follow a GARCH process. Rather than being observed directly, the process \(\epsilon_t\) may be the innovations of an ARMA(\(p^\prime,q^\prime\)) process. That is, \( \Phi(B)y_t = \Theta(B)\epsilon_t\) where \(\Phi(B) = 1 - \sum_{i=1}^{p^\prime} \phi_i B^i\) and \(\Theta(B) = 1-\sum_{j=1}^{q^{\prime}} \theta_j B^j\). The mean process \(\mu_t\) then can be expressed as $$ \mu_t = \mu + \sum_{i=1}^{p^\prime} \phi_i B^i y_t + \sum_{j=1}^{q^\prime}\theta_jB^j\epsilon_t$$ To estimate the mean model, an ARMA(\(p^\prime,q^\prime\)) is fit to the returns process. See setMeanModel(int[]). The conditional variance \(Var(\epsilon_t|\epsilon_u, u \lt t)=\sigma^2_t\) is known as \(volatility\).

The GARCH model provides for inference and forecasting of market volatility and captures certain artifacts such as fat tails and volatility clustering. Autoregressive conditionally heteroscedastic (ARCH) models were introduced by Engle (1982) and their generalized version (Generalized ARCH, or GARCH) is due to Bollerslev (1986). See the class GARCH for further information.

Some features of real market data are not captured by the classical model. For example, it is often observed that market drops result in higher volatility than market increases, an asymmetric behavior known as leverage. A number of extensions to the standard model have been proposed to account for characteristics like leverage.

Extensions to the standard GARCH model have $$ \left\{ \begin{array}{ll} \epsilon_t = \sigma_t z_t & \\ h(\sigma_t) = \omega + I(B)g(\epsilon_{t}) + \beta(B)h(\sigma_{t}) & \end{array} \right. $$ where the functions \(h_t = h(\sigma_t)\) and \(g_t=g(\epsilon_t)\) are specified. Note that in this treatment, \(g(\epsilon_t)\) depends on the set of parameters \(\{\alpha_i\}\) and possibly others, and \(I(B)=\sum_{i=1}^q B^i\).

In addition, a mean model can be specified through an ARMA(\(p^{\prime},q^{\prime})\) model on the returns process as described above. The ARMA parameters are jointly estimated with the GARCH parameters.

For example, the exponential GARCH (EGARCH) puts $$ \left\{ \begin{array}{ll} \epsilon_t = \sigma_tz_t & \\ \log \sigma_t^2 = \omega + I(B) g(\epsilon_t,\sigma_t) + \beta(B)log(\sigma^2_{t}) & \end{array} \right.$$ where $$g(\epsilon_{t-k},\sigma_{t-k})=\alpha_k z_{t-k} + \gamma_k(|z_{t-k}| - E|z_{t-k}|) $$ and \(\omega,\alpha_i,\beta_j,\) and \(\gamma_i\) are real numbers. Estimation and forecasting for the exponential GARCH is provided in class EGARCH.

References
1. Bollerslev, T. (1986), Generalized Autoregressive Conditional Heteroscedasticity, Journal of Econometrics, Volume 31, 307-327.
2. Engle, Robert F. (1982), Autoregressive Conditional Heteroscedasticity with Estimates of the Variance of United Kingdom Inflation, Econometrica, Volume 50, Issue 4, 987–1008.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    An enumeration of the types of solvers available to the estimation procedure.
    static interface 
    Public interface for specifying the distribution of \(z_t\).
  • Constructor Summary

    Constructors
    Constructor
    Description
    ExtendedGARCH(TimeSeries ts, int p, int q, int[] meanModel)
    Constructor for the extended GARCH class.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract double
    Abstract specification for the conditional variance \(\sigma^2_t\) function.
    abstract double
    Abstract specification for the conditional variance \(\sigma^2_t\) inverse function.
    void
    Performs the estimation for the specified model.
    double
    filter(double[] parameters)
    Performs filtering as specified by the conditional variance and the mean model configuration using a set of fixed parameters.
    double[][][]
    forecast(int numberOfSnapshots, int numberOfStepsAhead)
    Forecasts the conditional variance and the residual series for the fitted extended GARCH model.
    int
    Returns the value of the ARCH lag parameter for the given instance.
    final double[]
    Returns the current conditional variance array.
    final double[]
    Returns the data series, usually the time series of asset returns.
    double
    Returns the value of the log-likelihood at the final estimates of the parameters.
    int
    Returns the value of the GARCH lag parameter for the given instance.
    final int[]
    Returns the mean ARMA model specification as an integer array, \(\{p,d,q\}\).
    final double[]
    Returns the current estimates of the mean model parameters.
    int
    Returns the number of parameters in the Extended GARCH model.
    double[]
    Returns the parameter lower bounds.
    double[]
    Returns the (current) parameter estimates of the extended GARCH object.
    double[]
    Returns the parameter upper bounds.
    final double[]
    Returns the epsilon series (the current residuals).
    int
    Returns the length of the GARCH time series.
    abstract double
    gFunction(double epsilon, double sigma, int lag, double[] params, double... values)
    Abstract method for the function \(g(\epsilon_t,\sigma_t)\).
    final boolean
    Returns the flag to include or not include an ARMA model for the mean.
    final boolean
    Returns the value of mustEstimateFlag.
    void
    setInitialConditionalVariance(double initialSigma2)
    Sets the initial value of the conditional variance.
    void
    Sets the maximum number of function evaluations to allow in the Nelder-Mead method.
    final void
    setMeanModel(int[] meanModel)
    Sets the mean ARMA model specification as an integer array \(\{p,d,q\}\), where \(p\) is the number of AR lags and \(q\) is the number of MA lags.
    void
    setMustEstimate(boolean mustEstimate)
    Sets the value of mustEstimateFlag.
    final void
    setNumberOfParameters(int numberOfParameters)
    Sets the number of parameters in the Extended GARCH model.
    void
    setNumberOfThreads(int numberOfThreads)
    Sets the number of java.lang.Thread instances to be used for parallel processing.
    final void
    setParameterLowerBounds(double[] lowerBounds)
    Sets the lower bounds for the parameter estimates.
    void
    setParameters(double[] parameters)
    Sets the values of the parameters.
    final void
    setParameterUpperBounds(double[] upperBounds)
    Sets the upper bounds for the parameter estimates.
    void
    Sets the random object.
    void
    Sets the solver to use for parameter estimation.
    void
    setTolerance(double tolerance)
    Sets the convergence tolerance.
    final void
    setValues(double[] values)
    Sets the optional values needed in the specification for gFunction.
    void
    Sets the distribution to use for the random variable, \(z\), in the extended GARCH model.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ExtendedGARCH

      public ExtendedGARCH(TimeSeries ts, int p, int q, int[] meanModel)
      Constructor for the extended GARCH class.
      Parameters:
      ts - a TimeSeries object containing the data series. Typically the data series is the log or percentage daily returns for a particular stock or stock index.
      p - a non-negative int, the GARCH order or number of GARCH lags
      q - a non-negative int, the ARCH order or number of ARCH lags
      meanModel - an int array containing the specification for the ARMA mean model optionally fit to the return series. Extending classes should encode meanModel=null unless a mean model is to be included.
  • Method Details

    • setRandomObject

      public void setRandomObject(Random r)
      Sets the random object. The Nelder-Mead solver uses a random object to generate the initial complex.
      Parameters:
      r - a Random object

      Specifying a seed for the Random object can produce repeatable/deterministic output.

    • getGARCH

      public int getGARCH()
      Returns the value of the GARCH lag parameter for the given instance.
      Returns:
      an int, the value of p
    • getARCH

      public int getARCH()
      Returns the value of the ARCH lag parameter for the given instance.
      Returns:
      an int, the value of q
    • getMeanModel

      public final int[] getMeanModel()
      Returns the mean ARMA model specification as an integer array, \(\{p,d,q\}\). Currently, the model ignores any value for \(d \ne 0\).
      Returns:
      an int array containing the model specification
    • setMeanModel

      public final void setMeanModel(int[] meanModel)
      Sets the mean ARMA model specification as an integer array \(\{p,d,q\}\), where \(p\) is the number of AR lags and \(q\) is the number of MA lags. Currently, the model ignores any value for \(d \ne 0\).
      Parameters:
      meanModel - an int array of length 3 specifying the ARMA model to fit to the return series
    • setZDistribution

      public void setZDistribution(ExtendedGARCH.zDistribution userZDistribution)
      Sets the distribution to use for the random variable, \(z\), in the extended GARCH model.
      Parameters:
      userZDistribution - a zDistribution object containing a user defined distribution
    • setValues

      public final void setValues(double[] values)
      Sets the optional values needed in the specification for gFunction.
      Parameters:
      values - a double array, containing the additional values
    • getT

      public int getT()
      Returns the length of the GARCH time series.
      Returns:
      an int, the length of the series
    • getDataSeries

      public final double[] getDataSeries()
      Returns the data series, usually the time series of asset returns.
      Returns:
      a double array containing the data series
    • getResidualSeries

      public final double[] getResidualSeries()
      Returns the epsilon series (the current residuals).
      Returns:
      a double array containing the residuals
    • setSolverMethod

      public void setSolverMethod(ExtendedGARCH.Solver solver)
      Sets the solver to use for parameter estimation.
      Parameters:
      solver - a Solver object. By default, Solver=QUASI_NEWTON.
    • setMaxNumberOfEvaluations

      public void setMaxNumberOfEvaluations(int maxEval)
      Sets the maximum number of function evaluations to allow in the Nelder-Mead method.
      Parameters:
      maxEval - a int, the maximum number of function evaluations

      By default, maxEval = 300.

    • getConditionalVariance

      public final double[] getConditionalVariance()
      Returns the current conditional variance array.
      Returns:
      a double array containing the conditional variance
    • setNumberOfThreads

      public void setNumberOfThreads(int numberOfThreads)
      Sets the number of java.lang.Thread instances to be used for parallel processing.
      Parameters:
      numberOfThreads - an int specifying the number of java.lang.Thread instances to be used for parallel processing.

      Default: numberOfThreads = 1.

    • setTolerance

      public void setTolerance(double tolerance)
      Sets the convergence tolerance.
      Parameters:
      tolerance - a double containing the convergence tolerance

      By default, tolerance = 1.0e-8.

    • isMustEstimate

      public final boolean isMustEstimate()
      Returns the value of mustEstimateFlag. A value of true means that the model parameter estimates are stale given a recent configuration change, whereas a value of false means the estimates are up to date with the configuration.
      Returns:
      a boolean, the value of the flag
    • setMustEstimate

      public void setMustEstimate(boolean mustEstimate)
      Sets the value of mustEstimateFlag.
      Parameters:
      mustEstimate - a boolean, the setting of the flag. A value of true means that the model parameter estimates are stale given a recent configuration change, whereas a value of false means the estimates are up to date with the configuration.
    • setParameterUpperBounds

      public final void setParameterUpperBounds(double[] upperBounds)
      Sets the upper bounds for the parameter estimates. The mustEstimate flag is set to true within this method.
      Parameters:
      upperBounds - a double array containing upper bounds for the parameter estimates
    • getParameterUpperBounds

      public double[] getParameterUpperBounds()
      Returns the parameter upper bounds.
      Returns:
      a double array containing the upper bounds
    • getParameterLowerBounds

      public double[] getParameterLowerBounds()
      Returns the parameter lower bounds.
      Returns:
      a double array containing the lower bounds
    • setParameterLowerBounds

      public final void setParameterLowerBounds(double[] lowerBounds)
      Sets the lower bounds for the parameter estimates. The mustEstimate flag is set to true within this method.
      Parameters:
      lowerBounds - a double array containing lower bounds for the parameter estimates
    • isIncludeMean

      public final boolean isIncludeMean()
      Returns the flag to include or not include an ARMA model for the mean. By default the flag is false, do not include a model for the mean.
      Returns:
      a boolean, the flag to include the mean.
    • setInitialConditionalVariance

      public void setInitialConditionalVariance(double initialSigma2)
      Sets the initial value of the conditional variance. The mustEstimate flag is set to true within this method.
      Parameters:
      initialSigma2 - a double, the initial value of the conditional variance
    • getNumberOfParameters

      public int getNumberOfParameters()
      Returns the number of parameters in the Extended GARCH model.
      Returns:
      an int, the number of parameters in the model
    • setNumberOfParameters

      public final void setNumberOfParameters(int numberOfParameters)
      Sets the number of parameters in the Extended GARCH model. Extending classes may use this method to set the number of parameters after processing different configuration options. The mustEstimate flag is set to true within this method.
      Parameters:
      numberOfParameters - an int, the number of parameters in the model
    • getMeanModelParameters

      public final double[] getMeanModelParameters()
      Returns the current estimates of the mean model parameters. If the model has been estimated, the returned array will have length 1 + meanModel[0] + meanModel[2] and contain ARMA parameters in the following order: \((\mu,\phi_1,...,\phi_{p^\prime}, \theta_1,...,\theta_{q^\prime})\), with \(p^\prime\)=meanModel[0] and \(q^\prime\)=meanModel[2]. A null array is returned if none have been estimated.
      Returns:
      a double array containing the mean model parameter estimates
    • getParameters

      public double[] getParameters()
      Returns the (current) parameter estimates of the extended GARCH object. If the flag mustEstimate is true, a warning is printed. A null array is allowed on return so that extending classes can set default values. The order of the parameters contained in the array will depend on the implementation. For example, EGARCH (@link com.imsl.stat.EGARCH} returns \((\omega, \alpha_1, \alpha_2, ...,\alpha_q, \beta_1,...,\beta_p, \gamma_1,...,\gamma_q) \), where \(\{\beta_i, i=1,...,p\}\) are the autoregressive parameters on \(h(\sigma_t)\) and \(\{(\alpha_j,\gamma_j) j=1,...,q \}\) are the parameters in \(g(z_t)\).
      Returns:
      a double array containing parameter estimates
    • setParameters

      public void setParameters(double[] parameters)
      Sets the values of the parameters. Extending classes may use this method to set the values of the parameters after estimation or for filtering with fixed values.
      Parameters:
      parameters - a double array containing parameter values
    • estimate

      public void estimate() throws Exception
      Performs the estimation for the specified model.
      Throws:
      Exception
    • getFinalLogLikelihood

      public double getFinalLogLikelihood()
      Returns the value of the log-likelihood at the final estimates of the parameters.
      Returns:
      a double, the log-likelihood evaluated at the final parameter estimates
    • forecast

      public double[][][] forecast(int numberOfSnapshots, int numberOfStepsAhead)
      Forecasts the conditional variance and the residual series for the fitted extended GARCH model. For \(i =1,...,\) numberOfSnapshots \( \lt T \) and \(h = 1,2,...,\) numberOfStepsAhead, a forecast at time \(T-i+h\) is the conditional expectation given the data to time \(T-i\).
      Parameters:
      numberOfSnapshots - an int, the number of snapshots
      numberOfStepsAhead - an int, the number of steps ahead
      Returns:
      a double array of dimension numberOfSnapshots by numberOfStepsAhead by 2 containing the forecasts for the innovations process (or residuals) and the conditional variance. For \(i = 1,...,\)numberOfSnapshots and \(h = 1,2,...,\)numberOfStepsAhead forecasts[i-1][h-1][0] is the forecast for the residual and forecasts[i-1][h-1][1] is the forecast for the conditional variance.
    • conditionalVarianceFunction

      public abstract double conditionalVarianceFunction(double sigma2)
      Abstract specification for the conditional variance \(\sigma^2_t\) function.
      Parameters:
      sigma2 - a double, the value of \(\sigma^2_t\)
      Returns:
      a double, the value of the conditional variance function at \(\sigma^2_t\)
    • conditionalVarianceInverseFunction

      public abstract double conditionalVarianceInverseFunction(double f)
      Abstract specification for the conditional variance \(\sigma^2_t\) inverse function.
      Parameters:
      f - a double, the value of the conditional variance function at \(\sigma^2_t\)
      Returns:
      a double, the value of \(\sigma^2_t\)
    • gFunction

      public abstract double gFunction(double epsilon, double sigma, int lag, double[] params, double... values)
      Abstract method for the function \(g(\epsilon_t,\sigma_t)\).
      Parameters:
      epsilon - a double, the value of \(\epsilon_{t-k}\)
      sigma - a double, the value of \(\sigma_{t-k}\)
      lag - an int, the lag \(k\)
      params - a double array containing parameter values for time \(t-k\)
      values - a double object containing additional values as needed by the implementation
      Returns:
      a double, the function value
    • filter

      public double filter(double[] parameters)
      Performs filtering as specified by the conditional variance and the mean model configuration using a set of fixed parameters.
      Parameters:
      parameters - a double array containing fixed parameter values
      Returns:
      a double, the value of the log-likelihood at the given parameter values