GARCH Toolbox | ![]() ![]() |
Incorporating a Regression Model in an Estimation
This section uses the asymptotic equivalence of auto-regressive models and linear regression models to illustrate the use of a regression component in the GARCH Toolbox. The example is presented in two parts:
Fitting an AR/GARCH Model to a Simulated Return Series
This section defines a specification structure for an AR/GARCH model, and then uses that model to fit a simulated return series to the defined model.
Define the AR/GARCH Model. Start by creating a specification structure for an AR(2)/GARCH(1,1) composite model with successive calls to garch
set. Set the Display
flag to off
to suppress the optimization details that garchfit
normally prints to the screen.
spec = garchset('K', 0.005, 'GARCH', 0.7, 'ARCH', 0.1); spec = garchset(spec, 'C', 0); spec = garchset(spec, 'R', 2, 'AR', [0.5 -0.8]); spec = garchset(spec, 'Regress', [0.5 -0.8]) spec = garchset(spec, 'Display', 'off'); spec = Comment: 'Mean: ARMAX(2,0,?); Variance: GARCH(1,1)' R: 2 M: 0 P: 1 Q: 1 Distribution: 'Gaussian' C: 0 AR: [0.5000 -0.8000] MA: [] Regress: [0.5000 -0.8000] K: 0.0050 GARCH: 0.7000 ARCH: 0.1000 FixC: [] FixAR: [] FixMA: [] FixRegress: [] FixK: [] FixGARCH: [] FixARCH: [] Optimization: [1x1 struct]
Notice that in this specification structure, spec
:
R
, M
, P
, and Q
are consistent with the number of coefficients in the AR
, MA
, GARCH
, and ARCH
vectors, respectively.
Regress
field indicates two regression coefficients, the Comment
field still contains a question mark as a placeholder for the number of explanatory variables.
Regress
vector, analogous to the R
, M
, P
, and Q
orders of an ARMA(R,M)/GARCH(P,Q) model.
Fit the Model to a Simulated Return Series. Simulate 2000 observations of the innovations, conditional standard deviations, and returns for the AR(2)/GARCH(1,1) process defined in spec
. Use the model defined in spec
to estimate the parameters of the simulated return series and then compare the parameter estimates to the original coefficients in spec
.
[e,s,y] = garchsim(spec, 2000); [coeff, errors] = garchfit(spec, y); garchdisp(coeff, errors) Number of Parameters Estimated: 6 Standard T Parameter Value Error Statistic ----------- ----------- ------------ ----------- C -0.00045653 0.0034627 -0.1318 AR(1) 0.50256 0.013926 36.0875 AR(2) -0.80022 0.013987 -57.2134 K 0.0049947 0.0019528 2.5577 GARCH(1) 0.71232 0.094514 7.5366 ARCH(1) 0.082964 0.022582 3.6740
The estimated parameters, shown in the Value
column, are quite close to the original coefficients in spec
.
Because you specified no explanatory regression matrix as input to garchsim
and garchfit
, these functions ignore the regression coefficients (Regress
). Display the Comment
field of the resulting garchfit
output structure. It shows a 0
for the order of the regression component.
Fitting a Regression Model to the Same Return Series
To illustrate the use of a regression matrix, fit the return series y
, an AR(2) process in the mean, to a regression model with two explanatory variables. The regression matrix consists of the first- and second-order lags of the simulated return series y
.
Remove AR Component. First, remove the AR component from the specification structure.
spec = garchset(spec, 'R', 0, 'AR', []) spec = Comment: 'Mean: ARMAX(0,0,?); Variance: GARCH(1,1)' R: 0 M: 0 P: 1 Q: 1 Distribution: 'Gaussian' C: 0 AR: [] MA: [] Regress: [0.5000 -0.8000] K: 0.0050 GARCH: 0.7000 ARCH: 0.1000 FixC: [] FixAR: [] FixMA: [] FixRegress: [] FixK: [] FixGARCH: [] FixARCH: [] Optimization: [1x1 struct]
Create the Regression Matrix. Create a regression matrix of first- and second-order lags using the simulated returns vector y
as input. Examine the first 10 rows of y
and the corresponding rows of the lags.
X = lagmatrix(y, [1 2]); [y(1:10) X(1:10,:)] ans = 0.0562 NaN NaN 0.0183 0.0562 NaN -0.0024 0.0183 0.0562 -0.1506 -0.0024 0.0183 -0.3937 -0.1506 -0.0024 -0.0867 -0.3937 -0.1506 0.1075 -0.0867 -0.3937 0.2225 0.1075 -0.0867 0.1044 0.2225 0.1075 0.1288 0.1044 0.2225
A NaN
(an IEEE arithmetic standard for Not-a-Number) in the resulting matrix X
indicates the presence of a missing observation. If you use X
to fit a regression model to y
, garchfit
produces an error.
[coeff, errors] = garchfit(spec, y, X); ??? Error using ==> garchfit Regression matrix 'X' has insufficient number of observations.
The error occurs because there are fewer valid rows (i.e., those rows without a NaN
) in the regression matrix X
than there are observations in y
. The returns vector y
has 2000 observations but the most recent number of valid observations in X
is only 1998.
You can do one of two things to enable you to proceed. For a return series of this size it makes little difference which option you choose:
This example continues by replacing all NaN
s with the sample mean of y
. Use the MATLAB function isnan
to identify NaN
s and the function mean
to compute the mean of y
.
X(isnan(X)) = mean(y); [y(1:10), X(1:10,:)] ans = 0.0562 0.0004 0.0004 0.0183 0.0562 0.0004 -0.0024 0.0183 0.0562 -0.1506 -0.0024 0.0183 -0.3937 -0.1506 -0.0024 -0.0867 -0.3937 -0.1506 0.1075 -0.0867 -0.3937 0.2225 0.1075 -0.0867 0.1044 0.2225 0.1075 0.1288 0.1044 0.2225
Note
If the number of valid rows in X exceeds the number of observations in y , then garchfit includes in the estimation only the most recent rows of X , equal to the number of observations in y .
|
Fit the Regression Model. Now that the explanatory regression matrix X
is compatible with the return series vector y
, use garchfit
to estimate the model coefficients for the return series using the regression matrix and display the results.
[coeffX, errorsX] = garchfit(spec, y, X); garchdisp (coeffX, errorsX) Number of Parameters Estimated: 6 Standard T Parameter Value Error Statistic ----------- ----------- ------------ ----------- C -0.00044818 0.0034618 -0.1295 Regress(1) 0.50257 0.01392 36.1049 Regress(2) -0.8002 0.013981 -57.2344 K 0.0050529 0.0019709 2.5637 GARCH(1) 0.70955 0.095315 7.4443 ARCH(1) 0.083293 0.022664 3.6751
These estimation results are similar to those shown for the AR model in the section Fitting an AR/GARCH Model to a Simulated Return Series. This similarity illustrates the asymptotic equivalence of auto-regressive models and linear regression models.
By illustrating the extra steps involved in formatting the explanatory matrix, this part of the example also highlights the additional complexity involved in modeling conditional means with regression components.
![]() | Conditional Mean Models with Regression Components | Simulation and Inference Using a Regression Component | ![]() |