www.gusucode.com > econ 案例源码程序 matlab代码 > econ/DotNotationGARCHExample.m
%% Dot Notation % A model created by |garch|, |egarch|, or |gjr| has values assigned to all % model properties. To change any of these property values, you do not need % to reconstruct the whole model. You can modify property values of an % existing model using dot notation. That is, type the model name, then the % property name, separated by |'.'| (a period). %% % For example, start with this model specification: % Copyright 2015 The MathWorks, Inc. Mdl = garch(1,1) %% % The default model has no mean offset, so the |Offset| property does not % appear in the model output. The property exists, however: Offset = Mdl.Offset %% % Modify the model to add an unknown mean offset term: Mdl.Offset = NaN %% % |Offset| now appears in the model output, with the updated nonzero value. %% % Be aware that every model property has a data type. Any modifications you % make to a property value must be consistent with the data type of the % property. For example, |GARCH| and |ARCH| (and |Leverage| for |egarch| % and |gjr| models) are all cell vectors. This means you must index them % using cell array syntax. %% % For example, start with the following model: GJRMdl = gjr(1,1) %% % To modify the property value of |GARCH|, assign |GARCH| a cell array. % Here, assign known GARCH coefficient values: GJRMdl.GARCH = {0.6,0.2} %% % The updated model now has two GARCH terms (at lags 1 and 2) with % the specified equality constraints. %% % Similarly, the data type of |Distribution| is a data structure. The % default data structure has only one field, |Name|, with value % |'Gaussian'|. Distribution = GJRMdl.Distribution %% % To modify the innovation distribution, assign |Distribution| a new name % or data structure. The data structure can have up to two fields, |Name| % and |DoF|. The second field corresponds to the degrees of freedom for a % Student's _t_ distribution, and is only required if |Name| has the value % |'t'|. %% % To specify a Student's _t_ distribution with unknown degrees of freedom, % enter: GJRMdl.Distribution = 't' %% % The updated model has a Student's _t_ distribution with |NaN| degrees of % freedom. To specify a _t_ distribution with eight degrees of freedom, say: GJRMdl.Distribution = struct('Name','t','DoF',8) %% % The degrees of freedom property in the model is updated. Note that the % |DoF| field of |Distribution| is not directly assignable. For example, % |GJRMdl.Distribution.DoF = 8| is not a valid assignment. However, you can % get the individual fields: DistributionDoF = GJRMdl.Distribution.DoF