Class ExtendedGARCH
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
EGARCH
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 ClassesModifier and TypeClassDescriptionstatic enumAn enumeration of the types of solvers available to the estimation procedure.static interfacePublic interface for specifying the distribution of \(z_t\). -
Constructor Summary
ConstructorsConstructorDescriptionExtendedGARCH(TimeSeries ts, int p, int q, int[] meanModel) Constructor for the extended GARCH class. -
Method Summary
Modifier and TypeMethodDescriptionabstract doubleconditionalVarianceFunction(double sigma2) Abstract specification for the conditional variance \(\sigma^2_t\) function.abstract doubleconditionalVarianceInverseFunction(double f) Abstract specification for the conditional variance \(\sigma^2_t\) inverse function.voidestimate()Performs the estimation for the specified model.doublefilter(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.intgetARCH()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.doubleReturns the value of the log-likelihood at the final estimates of the parameters.intgetGARCH()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.intReturns 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).intgetT()Returns the length of the GARCH time series.abstract doublegFunction(double epsilon, double sigma, int lag, double[] params, double... values) Abstract method for the function \(g(\epsilon_t,\sigma_t)\).final booleanReturns the flag to include or not include an ARMA model for the mean.final booleanReturns the value ofmustEstimateFlag.voidsetInitialConditionalVariance(double initialSigma2) Sets the initial value of the conditional variance.voidsetMaxNumberOfEvaluations(int maxEval) Sets the maximum number of function evaluations to allow in the Nelder-Mead method.final voidsetMeanModel(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.voidsetMustEstimate(boolean mustEstimate) Sets the value ofmustEstimateFlag.final voidsetNumberOfParameters(int numberOfParameters) Sets the number of parameters in the Extended GARCH model.voidsetNumberOfThreads(int numberOfThreads) Sets the number ofjava.lang.Threadinstances to be used for parallel processing.final voidsetParameterLowerBounds(double[] lowerBounds) Sets the lower bounds for the parameter estimates.voidsetParameters(double[] parameters) Sets the values of the parameters.final voidsetParameterUpperBounds(double[] upperBounds) Sets the upper bounds for the parameter estimates.voidSets the random object.voidsetSolverMethod(ExtendedGARCH.Solver solver) Sets the solver to use for parameter estimation.voidsetTolerance(double tolerance) Sets the convergence tolerance.final voidsetValues(double[] values) Sets the optional values needed in the specification forgFunction.voidsetZDistribution(ExtendedGARCH.zDistribution userZDistribution) Sets the distribution to use for the random variable, \(z\), in the extended GARCH model.
-
Constructor Details
-
ExtendedGARCH
Constructor for the extended GARCH class.- Parameters:
ts- aTimeSeriesobject 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-negativeint, the GARCH order or number of GARCH lagsq- a non-negativeint, the ARCH order or number of ARCH lagsmeanModel- anintarray containing the specification for the ARMA mean model optionally fit to the return series. Extending classes should encodemeanModel=nullunless a mean model is to be included.
-
-
Method Details
-
setRandomObject
Sets the random object. The Nelder-Mead solver uses a random object to generate the initial complex.- Parameters:
r- aRandomobjectSpecifying a seed for the
Randomobject 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 ofp
-
getARCH
public int getARCH()Returns the value of the ARCH lag parameter for the given instance.- Returns:
- an
int, the value ofq
-
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
intarray 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- anintarray of length 3 specifying the ARMA model to fit to the return series
-
setZDistribution
Sets the distribution to use for the random variable, \(z\), in the extended GARCH model.- Parameters:
userZDistribution- azDistributionobject containing a user defined distribution
-
setValues
public final void setValues(double[] values) Sets the optional values needed in the specification forgFunction.- Parameters:
values- adoublearray, 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
doublearray containing the data series
-
getResidualSeries
public final double[] getResidualSeries()Returns the epsilon series (the current residuals).- Returns:
- a
doublearray containing the residuals
-
setSolverMethod
Sets the solver to use for parameter estimation.- Parameters:
solver- aSolverobject. 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- aint, the maximum number of function evaluationsBy default,
maxEval= 300.
-
getConditionalVariance
public final double[] getConditionalVariance()Returns the current conditional variance array.- Returns:
- a
doublearray containing the conditional variance
-
setNumberOfThreads
public void setNumberOfThreads(int numberOfThreads) Sets the number ofjava.lang.Threadinstances to be used for parallel processing.- Parameters:
numberOfThreads- anintspecifying the number ofjava.lang.Threadinstances to be used for parallel processing.Default:
numberOfThreads= 1.
-
setTolerance
public void setTolerance(double tolerance) Sets the convergence tolerance.- Parameters:
tolerance- adoublecontaining the convergence toleranceBy default, tolerance = 1.0e-8.
-
isMustEstimate
public final boolean isMustEstimate()Returns the value ofmustEstimateFlag. A value oftruemeans that the model parameter estimates are stale given a recent configuration change, whereas a value offalsemeans 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 ofmustEstimateFlag.- Parameters:
mustEstimate- aboolean, the setting of the flag. A value oftruemeans that the model parameter estimates are stale given a recent configuration change, whereas a value offalsemeans the estimates are up to date with the configuration.
-
setParameterUpperBounds
public final void setParameterUpperBounds(double[] upperBounds) Sets the upper bounds for the parameter estimates. ThemustEstimateflag is set totruewithin this method.- Parameters:
upperBounds- adoublearray containing upper bounds for the parameter estimates
-
getParameterUpperBounds
public double[] getParameterUpperBounds()Returns the parameter upper bounds.- Returns:
- a
doublearray containing the upper bounds
-
getParameterLowerBounds
public double[] getParameterLowerBounds()Returns the parameter lower bounds.- Returns:
- a
doublearray containing the lower bounds
-
setParameterLowerBounds
public final void setParameterLowerBounds(double[] lowerBounds) Sets the lower bounds for the parameter estimates. ThemustEstimateflag is set totruewithin this method.- Parameters:
lowerBounds- adoublearray 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 isfalse, 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. ThemustEstimateflag is set totruewithin this method.- Parameters:
initialSigma2- adouble, 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. ThemustEstimateflag is set totruewithin this method.- Parameters:
numberOfParameters- anint, 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 length1 + 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]. Anullarray is returned if none have been estimated.- Returns:
- a
doublearray containing the mean model parameter estimates
-
getParameters
public double[] getParameters()Returns the (current) parameter estimates of the extended GARCH object. If the flagmustEstimateistrue, 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
doublearray 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- adoublearray containing parameter values
-
estimate
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- anint, the number of snapshotsnumberOfStepsAhead- anint, the number of steps ahead- Returns:
- a
doublearray of dimensionnumberOfSnapshotsbynumberOfStepsAheadby2containing the forecasts for the innovations process (or residuals) and the conditional variance. For \(i = 1,...,\)numberOfSnapshotsand \(h = 1,2,...,\)numberOfStepsAheadforecasts[i-1][h-1][0]is the forecast for the residual andforecasts[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- adouble, 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- adouble, 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- adouble, the value of \(\epsilon_{t-k}\)sigma- adouble, the value of \(\sigma_{t-k}\)lag- anint, the lag \(k\)params- adoublearray containing parameter values for time \(t-k\)values- adoubleobject 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- adoublearray containing fixed parameter values- Returns:
- a
double, the value of the log-likelihood at the given parameter values
-