GARCH Toolbox | ![]() ![]() |
Accessing Specification Structures
Using garchset to Create a Specification Structure
The function garchset
provides various options for creating and modifying a specification structure. Each of the following commands uses a different garchset
syntax to create identical specification structures for the default model.
spec = garchset('R', 0, 'm', 0, 'P', 1, 'Q', 1); spec = garchset('p', 1, 'Q', 1); spec = garchset('R', 0, 'M', 0); spec = garchset(spec, 'P', 1, 'Q', 1); spec = garchset;
The first command explicitly sets all model orders: R
, M
, P
, and Q
. This command illustrates the most basic garchset
calling syntax. It specifies the structure fields as parameter/value pairs, in which the parameter name is a MATLAB character string enclosed in single quotes, followed by its corresponding value. When calling garchset
, you only need to type the leading characters that uniquely identify the parameter. As illustrated here, case is ignored for parameter names.
The second command sets model orders for a GARCH(1,1) variance process only, and relies on the ARMAX(0,0,?) default for the mean. The third command creates an initial structure, and then updates the existing structure with additional parameter/value pairs. The last command, with no input arguments, creates a structure for the default model. The last command also implies that the following commands produce exactly the same estimation results.
[coeff, errors, LLF, innovations, sigma] = garchfit(xyz); [coeff, errors, LLF, innovations, sigma] = garchfit(garchset, xyz);
Retrieving Specification Structure Values
The function garchget
retrieves the values contained in specification structure fields.
Use garchget
to retrieve the estimated coefficients from coeff
. Then use garchset
to write those coefficients to a new specification structure, spec
, that is almost identical to coeff
. For both garchget
and garchset
, you only need to type the leading characters that uniquely identify the parameter. Case is ignored for parameter names.
C = garchget(coeff, 'C') % Use a separate garchget call to % get each estimated coefficient. C = 4.9183e-004 K = garchget(coeff, 'K') K = 8.2736e-007 G = garchget(coeff, 'GARCH') G = 0.9628 A = garchget(coeff, 'ARCH') A = 0.0318 % Use garchset to create a new % structure, spec. spec = garchset('C', C, 'K', K, 'GARCH', G, 'ARCH', A) spec = Comment: 'Mean: ARMAX(0,0,?); Variance: GARCH(1,1)' R: 0 M: 0 P: 1 Q: 1 Distribution: 'Gaussian' C: 4.9183e-004 AR: [] MA: [] Regress: [] K: 8.2736e-007 GARCH: 0.9628 ARCH: 0.0318 FixC: [] FixAR: [] FixMA: [] FixRegress: [] FixK: [] FixGARCH: [] FixARCH: [] Optimization: [1x1 struct]
In this example, garchset
automatically generates the first six fields (i.e., Comment
, R
, M
, P
, Q
, and Distribution
). Specifically, garchset
infers the comment and model orders (R
, M
, P
, Q
) from the corresponding coefficient vectors (AR
, MA
, ARCH
, GARCH
). The converse is not true. If you specify only the model orders, garchset
creates the coefficient vectors as empty matrices ([]
). If you later call garchfit
, it estimates the coefficient vectors for models of the order you specify, and updates the AR
, MA
, ARCH
, and GARCH
fields with these values.
Note
The only difference between the coeff and spec structures above lies in their Comment fields. In coeff , garchfit explicitly sets the number of explanatory (i.e., regression) variables in the Comment field of coeff to 0 . This is because coeff represents an actual model whose conditional mean has no regression component. On the other hand, garchset inserts a '?' because it has no knowledge when it creates spec , whether you will include a regression component when you call garchfit to estimate the model parameters.
|
Accessing Fields Directly
In addition to using garchset
and garchget
to access the values of specification structure fields, you can also manipulate the fields of a structure directly. For example, the commands
both retrieve the order P
in the structure spec
. Similarly, the commands
The first command in each case uses a GARCH Toolbox function to retrieve or write the value of a field. In this case the toolbox performs error checking (e.g., to ensure compatibility between inputs and guarantee that ARMA models are stationary/invertible). You also have the convenience of partial field names and case insensitivity.
In each case, the second command manipulates the structure directly. Although this approach does not support partial field names and case insensitivity, it can be convenient when you work interactively at the MATLAB command line. However, it does not provide error checking. For this reason, you should avoid manipulating a specification structure directly when writing code.
Note that the call to garchset
above fails in your example workspace because the corresponding coefficient vector, GARCH
, has only one element. Setting spec.P = 3
directly succeeds but leaves you with an inconsistent specification structure.
![]() | Valid Model Specifications | Using the Specification Structure for Estimation, Simulation, and Forecasting | ![]() |